Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ require (
github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring v0.91.0
github.com/prometheus-operator/prometheus-operator/pkg/client v0.91.0
github.com/prometheus/client_golang v1.23.2
github.com/prometheus/common v0.67.5
github.com/prometheus/common v0.68.0
go.uber.org/zap v1.28.0
golang.org/x/mod v0.36.0
golang.org/x/sync v0.20.0
Expand All @@ -43,7 +43,7 @@ require (
github.com/fxamacker/cbor/v2 v2.9.2 // indirect
github.com/gardener/gardener/pkg/apis v1.143.0 // indirect
github.com/go-openapi/jsonpointer v0.23.1 // indirect
github.com/go-openapi/jsonreference v0.21.5 // indirect
github.com/go-openapi/jsonreference v0.21.6 // indirect
github.com/go-openapi/swag v0.26.0 // indirect
github.com/go-openapi/swag/cmdutils v0.26.0 // indirect
github.com/go-openapi/swag/conv v0.26.0 // indirect
Expand Down
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ github.com/go-logr/zapr v1.3.0 h1:XGdV8XW8zdwFiwOA2Dryh1gj2KRQyOOoNmBy4EplIcQ=
github.com/go-logr/zapr v1.3.0/go.mod h1:YKepepNBd1u/oyhd/yQmtjVXmm9uML4IXUgMOwR8/Gg=
github.com/go-openapi/jsonpointer v0.23.1 h1:1HBACs7XIwR2RcmItfdSFlALhGbe6S92p0ry4d1GWg4=
github.com/go-openapi/jsonpointer v0.23.1/go.mod h1:iWRmZTrGn7XwYhtPt/fvdSFj1OfNBngqRT2UG3BxSqY=
github.com/go-openapi/jsonreference v0.21.5 h1:6uCGVXU/aNF13AQNggxfysJ+5ZcU4nEAe+pJyVWRdiE=
github.com/go-openapi/jsonreference v0.21.5/go.mod h1:u25Bw85sX4E2jzFodh1FOKMTZLcfifd1Q+iKKOUxExw=
github.com/go-openapi/jsonreference v0.21.6 h1:NZ5nGfnaM1n4I43Xjm1e5/M2GjOwQwndQz22uhxwD+Y=
github.com/go-openapi/jsonreference v0.21.6/go.mod h1:xzbgtQ3ZbWxvET3AxdzCJlJt6vkovbf+IfSPJjD0tUY=
github.com/go-openapi/swag v0.26.0 h1:GVDXCmfvhfu1BxiHo8/FA+BbKmhecHnG3varjON5/RI=
github.com/go-openapi/swag v0.26.0/go.mod h1:82g3193sZJRbocs7bNCqGfIgq8pkuwVwCfhKIRlEQF0=
github.com/go-openapi/swag/cmdutils v0.26.0 h1:iowihOcvq7y4egO8cOq0dmfohz6wfeQ63U1EnuhO2TU=
Expand Down Expand Up @@ -64,8 +64,8 @@ github.com/go-openapi/swag/yamlutils v0.26.0 h1:H7O8l/8NJJQ/oiReEN+oMpnGMyt8G0hl
github.com/go-openapi/swag/yamlutils v0.26.0/go.mod h1:1evKEGAtP37Pkwcc7EWMF0hedX0/x3Rkvei2wtG/TbU=
github.com/go-openapi/testify/enable/yaml/v2 v2.5.0 h1:3hZD1fwydvCx/cc1R2uYNQirHqf2s6lqpKV3FcNTURA=
github.com/go-openapi/testify/enable/yaml/v2 v2.5.0/go.mod h1:TvDZKBH7ZbMaF3EqH2AwTvNQCmzyZq8K1agRjf1B+Nk=
github.com/go-openapi/testify/v2 v2.5.0 h1:UOCr63aAsMIDydZbZGqo5Ev01D4eydItRbekDuZMJLw=
github.com/go-openapi/testify/v2 v2.5.0/go.mod h1:SgsVHtfooshd0tublTtJ50FPKhujf47YRqauXXOUxfw=
github.com/go-openapi/testify/v2 v2.5.1 h1:TMdhCaw8fUNraVSf3Omoob1dO/AzBfhtFAPW0an6sBo=
github.com/go-openapi/testify/v2 v2.5.1/go.mod h1:SgsVHtfooshd0tublTtJ50FPKhujf47YRqauXXOUxfw=
github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI=
github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8=
github.com/goccy/go-json v0.10.6 h1:p8HrPJzOakx/mn/bQtjgNjdTcN+/S6FcG2CTtQOrHVU=
Expand Down Expand Up @@ -136,8 +136,8 @@ github.com/prometheus/client_golang v1.23.2 h1:Je96obch5RDVy3FDMndoUsjAhG5Edi49h
github.com/prometheus/client_golang v1.23.2/go.mod h1:Tb1a6LWHB3/SPIzCoaDXI4I8UHKeFTEQ1YCr+0Gyqmg=
github.com/prometheus/client_model v0.6.2 h1:oBsgwpGs7iVziMvrGhE53c/GrLUsZdHnqNwqPLxwZyk=
github.com/prometheus/client_model v0.6.2/go.mod h1:y3m2F6Gdpfy6Ut/GBsUqTWZqCUvMVzSfMLjcu6wAwpE=
github.com/prometheus/common v0.67.5 h1:pIgK94WWlQt1WLwAC5j2ynLaBRDiinoAb86HZHTUGI4=
github.com/prometheus/common v0.67.5/go.mod h1:SjE/0MzDEEAyrdr5Gqc6G+sXI67maCxzaT3A2+HqjUw=
github.com/prometheus/common v0.68.0 h1:8rQJvQmYltsR2L7h8Zw0Iyj8WYNNmpwikoQTZXwfVeA=
github.com/prometheus/common v0.68.0/go.mod h1:4soH+U8yJSROk7OJ//hmTiWKsxapv6zRGgTt3keN8gQ=
github.com/prometheus/procfs v0.20.1 h1:XwbrGOIplXW/AU3YhIhLODXMJYyC1isLFfYCsTEycfc=
github.com/prometheus/procfs v0.20.1/go.mod h1:o9EMBZGRyvDrSPH1RqdxhojkuXstoe4UlK79eF5TGGo=
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
Expand Down
12 changes: 9 additions & 3 deletions internal/controller/informers.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package controller

import (
"reflect"
"time"

"github.com/sap/cap-operator/pkg/apis/sme.sap.com/v1alpha1"
"k8s.io/apimachinery/pkg/api/meta"
Expand Down Expand Up @@ -106,7 +107,7 @@ func (c *Controller) getEventHandlerFuncsForResource(res int) cache.ResourceEven
c.enqueueModifiedResource(res, new, old)
},
DeleteFunc: func(old any) {
c.enqueueModifiedResource(res, old, nil)
c.enqueueModifiedResource(res, nil, old)
},
}
}
Expand Down Expand Up @@ -183,6 +184,7 @@ func (c *Controller) registerGardenerDNSEntrytListeners() {

func (c *Controller) enqueueModifiedResource(sourceKey int, new, old any) {
newObj, ok := getMetaObject(new)
// Skip deletes in general!
if !ok {
return
}
Expand All @@ -208,12 +210,16 @@ func (c *Controller) enqueueModifiedResource(sourceKey int, new, old any) {
}
klog.InfoS(queuing, "namespace", newObj.GetNamespace(), "name", newObj.GetName(), "kind", dependentKind)
q.Add(QueueItem{Key: dependentKey, ResourceKey: NamespacedResourceKey{Name: newObj.GetName(), Namespace: newObj.GetNamespace()}})
}
// Only queue parent items on updates
if old == nil {
continue
} else if owner, ok := getOwnerByKind(newObj.GetOwnerReferences(), dependentKind); ok {
klog.InfoS(queuing, "namespace", newObj.GetNamespace(), "name", owner.Name, "kind", dependentKind)
q.Add(QueueItem{Key: dependentKey, ResourceKey: NamespacedResourceKey{Name: owner.Name, Namespace: newObj.GetNamespace()}})
q.AddAfter(QueueItem{Key: dependentKey, ResourceKey: NamespacedResourceKey{Name: owner.Name, Namespace: newObj.GetNamespace()}}, time.Second)
} else if owner, ok := getOwnerFromObjectMetadata(newObj, dependentKind); ok {
klog.InfoS(queuing, "namespace", owner.Namespace, "name", owner.Name, "kind", dependentKind)
q.Add(QueueItem{Key: dependentKey, ResourceKey: NamespacedResourceKey{Name: owner.Name, Namespace: owner.Namespace}})
q.AddAfter(QueueItem{Key: dependentKey, ResourceKey: NamespacedResourceKey{Name: owner.Name, Namespace: owner.Namespace}}, time.Second)
}
}
}
Expand Down
20 changes: 14 additions & 6 deletions internal/controller/informers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ func TestController_initializeInformers(t *testing.T) {
tests := []struct {
name string
expectedResult bool
ownerOnlyCheck bool
invalidOwnerRef bool
res int
itemName string
Expand All @@ -55,13 +56,15 @@ func TestController_initializeInformers(t *testing.T) {
{
name: "Test enqueueModifiedResource (ResourceCertificate) valid owner",
res: ResourceCertificate,
ownerOnlyCheck: true,
expectedResult: true,
itemName: "test-cert",
itemNamespace: corev1.NamespaceDefault,
},
{
name: "Test enqueueModifiedResource (ResourceCertificate) invalid owner",
res: ResourceCertificate,
ownerOnlyCheck: true,
expectedResult: false,
invalidOwnerRef: true,
itemName: "test-cert",
Expand Down Expand Up @@ -114,7 +117,7 @@ func TestController_initializeInformers(t *testing.T) {
}

testC.initializeInformers()
var res any
var res, oldRes any
switch tt.res {
case ResourceCAPApplication:
res = createCaCRO(tt.itemName, false)
Expand All @@ -135,17 +138,22 @@ func TestController_initializeInformers(t *testing.T) {
cert.Annotations[AnnotationOwnerIdentifier] = tt.itemNamespace + "." + tt.itemName
cert.Labels[LabelOwnerIdentifierHash] = sha1Sum(tt.itemNamespace, tt.itemName)
}
res = cert
oldRes = cert
newCert := cert.DeepCopy()
newCert.SetResourceVersion("2")
res = newCert
case 999:
res = &corev1.Pod{ObjectMeta: metav1.ObjectMeta{Name: tt.itemName}}
}
// Add/delete
testC.enqueueModifiedResource(tt.res, res, nil)
if expectedResult != tt.expectedResult {
t.Error("Unexpected result", expectedResult)
if !tt.ownerOnlyCheck {
testC.enqueueModifiedResource(tt.res, res, nil)
if expectedResult != tt.expectedResult {
t.Error("Unexpected result", expectedResult)
}
}
// Update
testC.enqueueModifiedResource(tt.res, res, res)
testC.enqueueModifiedResource(tt.res, res, oldRes)
if expectedResult != tt.expectedResult {
t.Error("Unexpected result", expectedResult)
}
Expand Down
30 changes: 15 additions & 15 deletions website/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading