Skip to content

Commit

Permalink
Prevent unnecessary update of observatorium in MCO (stolostron#1473)
Browse files Browse the repository at this point in the history
* logs

Signed-off-by: Coleen Iona Quadros <[email protected]>

* prevent unnecessary update of observatorium

Signed-off-by: Coleen Iona Quadros <[email protected]>

* prevent unnecessary update of observatorium

Signed-off-by: Coleen Iona Quadros <[email protected]>

* remove logs

Signed-off-by: Coleen Iona Quadros <[email protected]>

* remove logs

Signed-off-by: Coleen Iona Quadros <[email protected]>

---------

Signed-off-by: Coleen Iona Quadros <[email protected]>
  • Loading branch information
coleenquadros authored Jun 10, 2024
1 parent b489cd8 commit bcbdee1
Showing 1 changed file with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down

0 comments on commit bcbdee1

Please sign in to comment.