From bcbdee1e952d572ed190cbb968af5991e45d3313 Mon Sep 17 00:00:00 2001 From: Coleen Iona Quadros Date: Mon, 10 Jun 2024 15:12:24 +0200 Subject: [PATCH] Prevent unnecessary update of observatorium in MCO (#1473) * logs Signed-off-by: Coleen Iona Quadros * prevent unnecessary update of observatorium Signed-off-by: Coleen Iona Quadros * prevent unnecessary update of observatorium Signed-off-by: Coleen Iona Quadros * remove logs Signed-off-by: Coleen Iona Quadros * remove logs Signed-off-by: Coleen Iona Quadros --------- Signed-off-by: Coleen Iona Quadros --- .../multiclusterobservability/observatorium.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/operators/multiclusterobservability/controllers/multiclusterobservability/observatorium.go b/operators/multiclusterobservability/controllers/multiclusterobservability/observatorium.go index 912ffb015..0cc5d1a8e 100644 --- a/operators/multiclusterobservability/controllers/multiclusterobservability/observatorium.go +++ b/operators/multiclusterobservability/controllers/multiclusterobservability/observatorium.go @@ -161,20 +161,22 @@ func GenerateObservatoriumCR( oldSpec := observatoriumCRFound.Spec newSpec := observatoriumCR.Spec - oldSpecBytes, _ := yaml.Marshal(oldSpec) - newSpecBytes, _ := yaml.Marshal(newSpec) - if bytes.Equal(newSpecBytes, oldSpecBytes) && - labels[obsCRConfigHashLabelName] == observatoriumCRFound.Labels[obsCRConfigHashLabelName] { - return nil, nil - } - // keep the tenant id unchanged + // keep the tenant id unchanged and ensure the new spec has the same tenant ID as the old spec to prevent Observatorium + // from updating for i, newTenant := range newSpec.API.Tenants { for _, oldTenant := range oldSpec.API.Tenants { updateTenantID(&newSpec, newTenant, oldTenant, i) } } + oldSpecBytes, _ := yaml.Marshal(oldSpec) + newSpecBytes, _ := yaml.Marshal(newSpec) + if bytes.Equal(newSpecBytes, oldSpecBytes) && + labels[obsCRConfigHashLabelName] == observatoriumCRFound.Labels[obsCRConfigHashLabelName] { + return nil, nil + } + log.Info("Updating observatorium CR", "observatorium", observatoriumCR.Name, )