From 0078b320a76df1d1a4d63124899bc3dd248f30df Mon Sep 17 00:00:00 2001 From: Pavan <25031267+Pavan-SAP@users.noreply.github.com> Date: Mon, 1 Jun 2026 23:16:33 +0200 Subject: [PATCH 1/2] [Misc] Operator: Dependencies updated code/website: - Update to the latest version of dependencies. --- go.mod | 4 ++-- go.sum | 12 ++++++------ website/package-lock.json | 30 +++++++++++++++--------------- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/go.mod b/go.mod index 0a91460d..a724045a 100644 --- a/go.mod +++ b/go.mod @@ -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 @@ -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 diff --git a/go.sum b/go.sum index 048f82b2..c65ffd55 100644 --- a/go.sum +++ b/go.sum @@ -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= @@ -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= @@ -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= diff --git a/website/package-lock.json b/website/package-lock.json index f322ad5b..f578c5ec 100644 --- a/website/package-lock.json +++ b/website/package-lock.json @@ -112,9 +112,9 @@ } }, "node_modules/baseline-browser-mapping": { - "version": "2.10.32", - "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.10.32.tgz", - "integrity": "sha512-wbPvpyjJPC0zdfdKXxqEL3Ea+bOMD/87X4lftiJkkaBiuG6ALQy1SLmEd7BSmVCuwCQsBrCamgBoLyfFDD1EPg==", + "version": "2.10.33", + "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.10.33.tgz", + "integrity": "sha512-bA6+tcSLpz2tIEdDXZPpPTIuxBcC4+w6SieaYyfigIa4h8GlFxbA17v22Vx3JUtuZQj9SgOsnbK+aTBzyDyEuw==", "dev": true, "license": "Apache-2.0", "bin": { @@ -286,9 +286,9 @@ } }, "node_modules/electron-to-chromium": { - "version": "1.5.363", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.363.tgz", - "integrity": "sha512-VjUKPyWzGnT1fujlkEGC/BvN70Hh70KXtAqcmniXviYlJC/ivcT+BWGPyxWVbJZLfvtKR6dqg1L7T7pgAMBtWA==", + "version": "1.5.364", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.364.tgz", + "integrity": "sha512-G/dYE3+AYhyHwzTwg8UbnXf7zqMERYh7l2jJ3QujhFsH8agSYwtnGAR2aZ7f0AakIKJXd5En/Hre4igIUrdlYw==", "dev": true, "license": "ISC" }, @@ -397,9 +397,9 @@ "license": "ISC" }, "node_modules/hugo-extended": { - "version": "0.162.0", - "resolved": "https://registry.npmjs.org/hugo-extended/-/hugo-extended-0.162.0.tgz", - "integrity": "sha512-wn02alVlq3BQ90K67qQqtnqtwCZjdjCZWRvK8/7LQ5yuj2vT0saQAzCJLT0PhHEud4shxCyuUGyR7Sb300J32g==", + "version": "0.162.1", + "resolved": "https://registry.npmjs.org/hugo-extended/-/hugo-extended-0.162.1.tgz", + "integrity": "sha512-CaAoEP4TbqhE15OU/zorG67/9A5lWYOOQxUXpo+qnEdaFhVaFOUngguYp9XiWIoCCHauuSod391jgrhwyzo6uQ==", "dev": true, "hasInstallScript": true, "license": "MIT", @@ -819,9 +819,9 @@ } }, "node_modules/tar": { - "version": "7.5.15", - "resolved": "https://registry.npmjs.org/tar/-/tar-7.5.15.tgz", - "integrity": "sha512-dzGK0boVlC4W5QFuQN1EFSl3bIDYsk7Tj40U6eIBnK2k/8ml7TZ5agbI5j5+qnoVcAA+rNtBml8SEiLxZpNqRQ==", + "version": "7.5.16", + "resolved": "https://registry.npmjs.org/tar/-/tar-7.5.16.tgz", + "integrity": "sha512-56adEpPMouktRlBLXiaYFFzZ/3+JXa8P9n7WbR+ibIjtviN55mEaOkiysCnPnWm+7kkui1Dn8J9l+g6zV8731w==", "dev": true, "license": "BlueOak-1.0.0", "dependencies": { @@ -843,9 +843,9 @@ "license": "Apache-2.0" }, "node_modules/tinyglobby": { - "version": "0.2.16", - "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.16.tgz", - "integrity": "sha512-pn99VhoACYR8nFHhxqix+uvsbXineAasWm5ojXoN8xEwK5Kd3/TrhNn1wByuD52UxWRLy8pu+kRMniEi6Eq9Zg==", + "version": "0.2.17", + "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.17.tgz", + "integrity": "sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g==", "dev": true, "license": "MIT", "dependencies": { From 0d292043a48c89431075caa58d398e5fd40e9690 Mon Sep 17 00:00:00 2001 From: Pavan <25031267+Pavan-SAP@users.noreply.github.com> Date: Tue, 19 May 2026 22:38:58 +0200 Subject: [PATCH 2/2] [Misc] Operator: Reconciles improved Ignore some unnecessary reconciles. --- internal/controller/informers.go | 14 +++++++++++--- internal/controller/informers_test.go | 20 ++++++++++++++------ internal/controller/reconcile-captenant.go | 22 ++++++++++++---------- 3 files changed, 37 insertions(+), 19 deletions(-) diff --git a/internal/controller/informers.go b/internal/controller/informers.go index 529c6e00..9b6dbbd9 100644 --- a/internal/controller/informers.go +++ b/internal/controller/informers.go @@ -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" @@ -33,6 +34,8 @@ const ( const queuing = "queuing resource for reconciliation" +const defaultDependantDelay = 5 * time.Second + var ( KindMap = map[int]string{ ResourceCAPApplication: v1alpha1.CAPApplicationKind, @@ -106,7 +109,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) }, } } @@ -183,6 +186,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 } @@ -208,12 +212,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()}}, defaultDependantDelay) } 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}}, defaultDependantDelay) } } } diff --git a/internal/controller/informers_test.go b/internal/controller/informers_test.go index 16c3d194..dfce2cb4 100644 --- a/internal/controller/informers_test.go +++ b/internal/controller/informers_test.go @@ -33,6 +33,7 @@ func TestController_initializeInformers(t *testing.T) { tests := []struct { name string expectedResult bool + ownerOnlyCheck bool invalidOwnerRef bool res int itemName string @@ -55,6 +56,7 @@ func TestController_initializeInformers(t *testing.T) { { name: "Test enqueueModifiedResource (ResourceCertificate) valid owner", res: ResourceCertificate, + ownerOnlyCheck: true, expectedResult: true, itemName: "test-cert", itemNamespace: corev1.NamespaceDefault, @@ -62,6 +64,7 @@ func TestController_initializeInformers(t *testing.T) { { name: "Test enqueueModifiedResource (ResourceCertificate) invalid owner", res: ResourceCertificate, + ownerOnlyCheck: true, expectedResult: false, invalidOwnerRef: true, itemName: "test-cert", @@ -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) @@ -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) } diff --git a/internal/controller/reconcile-captenant.go b/internal/controller/reconcile-captenant.go index ea81baa7..e0d40752 100644 --- a/internal/controller/reconcile-captenant.go +++ b/internal/controller/reconcile-captenant.go @@ -20,8 +20,8 @@ import ( ) type IdentifiedCAPTenantOperations struct { - active []v1alpha1.CAPTenantOperation - processed []v1alpha1.CAPTenantOperation + active []*v1alpha1.CAPTenantOperation + processed []*v1alpha1.CAPTenantOperation } type CAPTenantOperationTypeSelector string @@ -75,6 +75,8 @@ const ( EventActionUpgrade = "Upgrade" ) +const tenantOperationTimeout = 30 * time.Second + var operationTypeMsgMap = map[v1alpha1.CAPTenantOperationType]string{ v1alpha1.CAPTenantOperationTypeProvisioning: string(Provisioning), v1alpha1.CAPTenantOperationTypeUpgrade: string(Upgrading), @@ -129,7 +131,7 @@ var TenantOperationStatusMap = map[v1alpha1.CAPTenantOperationType]StatusInfo{ func getTenantReconcileResultConsideringDeletion(cat *v1alpha1.CAPTenant, fallback *ReconcileResult) *ReconcileResult { if cat.DeletionTimestamp != nil && cat.Status.State != v1alpha1.CAPTenantStateDeleting { - return NewReconcileResultWithResource(ResourceCAPTenant, cat.Name, cat.Namespace, 15*time.Second) + return NewReconcileResultWithResource(ResourceCAPTenant, cat.Name, cat.Namespace, tenantOperationTimeout) } return fallback } @@ -138,7 +140,7 @@ var handleWaitingForTenantOperation = func(ctx context.Context, c *Controller, c // NOTE: not returning a requeue item is ok, as changes in CAPTenantOperation status will queue the item via the informer util.LogInfo("Waiting for tenant operation to complete", operationTypeMsgMap[ctop.Spec.Operation], cat, ctop, "tenantId", cat.Spec.TenantId, "version", cat.Spec.Version) cat.SetStatusWithReadyCondition(target.state, target.conditionStatus, target.conditionReason, fmt.Sprintf("waiting for %s %s.%s of type %s to complete", v1alpha1.CAPTenantOperationKind, ctop.Namespace, ctop.Name, ctop.Spec.Operation)) - return NewReconcileResultWithResource(ResourceCAPTenant, cat.Name, cat.Namespace, 15*time.Second), nil // requeue while the tenant operation is being processed + return NewReconcileResultWithResource(ResourceCAPTenant, cat.Name, cat.Namespace, tenantOperationTimeout), nil // requeue while the tenant operation is being processed } var handleCompletedProvisioningUpgradeOperation = func(ctx context.Context, c *Controller, cat *v1alpha1.CAPTenant, target StateCondition, ctop *v1alpha1.CAPTenantOperation) (*ReconcileResult, error) { @@ -270,7 +272,7 @@ func (c *Controller) updateCAPTenant(ctx context.Context, cat *v1alpha1.CAPTenan return } -func findLatestCreatedTenantOperation(ops []v1alpha1.CAPTenantOperation, selector CAPTenantOperationTypeSelector) (latest *v1alpha1.CAPTenantOperation) { +func findLatestCreatedTenantOperation(ops []*v1alpha1.CAPTenantOperation, selector CAPTenantOperationTypeSelector) (latest *v1alpha1.CAPTenantOperation) { for _, op := range ops { // workaround to fix pointer resolution after loop -> https://stackoverflow.com/questions/45967305/copying-the-address-of-a-loop-variable-in-go ctop := op @@ -278,7 +280,7 @@ func findLatestCreatedTenantOperation(ops []v1alpha1.CAPTenantOperation, selecto continue } if latest == nil || ctop.CreationTimestamp.After(latest.CreationTimestamp.Time) { - latest = &ctop + latest = ctop } } @@ -545,14 +547,14 @@ func (c *Controller) getCAPTenantOperationsByType(ctx context.Context, cat *v1al return nil, err } - // NOTE: do not use cache for listing (this is not a very frequent operation) - ops, err := c.crdClient.SmeV1alpha1().CAPTenantOperations(cat.Namespace).List(ctx, metav1.ListOptions{LabelSelector: selector.String()}) + // Check if tenant operations already exist via cache + ops, err := c.crdInformerFactory.Sme().V1alpha1().CAPTenantOperations().Lister().CAPTenantOperations(cat.Namespace).List(selector) if err != nil { return nil, err } - var results = IdentifiedCAPTenantOperations{active: []v1alpha1.CAPTenantOperation{}, processed: []v1alpha1.CAPTenantOperation{}} - for _, ctop := range ops.Items { + var results = IdentifiedCAPTenantOperations{active: []*v1alpha1.CAPTenantOperation{}, processed: []*v1alpha1.CAPTenantOperation{}} + for _, ctop := range ops { if isCROConditionReady(ctop.Status.GenericStatus) { results.processed = append(results.processed, ctop) } else {