11/*
2- * Copyright (c) 2020, 2024 , Oracle and/or its affiliates.
2+ * Copyright (c) 2020, 2025 , Oracle and/or its affiliates.
33 * Licensed under the Universal Permissive License v 1.0 as shown at
44 * http://oss.oracle.com/licenses/upl.
55 */
@@ -208,37 +208,12 @@ func (in *CoherenceReconciler) Reconcile(ctx context.Context, request ctrl.Reque
208208 }
209209
210210 hash := deployment .GetLabels ()[coh .LabelCoherenceHash ]
211+ storeHash , _ := storage .GetHash ()
211212 var desiredResources coh.Resources
212213
213- storeHash , found := storage .GetHash ()
214- if ! found || storeHash != hash || deployment .Status .Phase != coh .ConditionTypeReady {
215- // Storage state was saved with no hash or a different hash so is not in the desired state
216- // or the Coherence resource is not in the Ready state
217- // Create the desired resources the deployment
218- if desiredResources , err = deployment .CreateKubernetesResources (); err != nil {
219- return in .HandleErrAndRequeue (ctx , err , nil , fmt .Sprintf (createResourcesFailedMessage , request .Name , request .Namespace , err ), in .Log )
220- }
221-
222- if found {
223- // The "storeHash" is not "", so it must have been processed by the Operator (could have been a previous version).
224- // There was a bug prior to 3.2.8 where the hash was calculated at the wrong point in the defaulting web-hook,
225- // so the "currentHash" may be wrong, and hence differ from the recalculated "hash".
226- if deployment .IsBeforeVersion ("3.3.0" ) {
227- // the AnnotationOperatorVersion annotation was added in the 3.2.8 web-hook, so if it is missing
228- // the Coherence resource was added or updated prior to 3.2.8
229- // In this case we just ignore the difference in hash.
230- // There is an edge case where the Coherence resource could have legitimately been updated whilst
231- // the Operator and web-hooks were uninstalled. In that case we would ignore the update until another
232- // update is made. The simplest way for the customer to work around this is to add the
233- // AnnotationOperatorVersion annotation with some value, which will then be overwritten by the web-hook
234- // and the Coherence resource will be correctly processes.
235- desiredResources = storage .GetLatest ()
236- log .Info ("Ignoring hash difference for pre-3.2.8 resource" , "hash" , hash , "store" , storeHash )
237- }
238- }
239- } else {
240- // storage state was saved with the current hash so is already in the desired state
241- desiredResources = storage .GetLatest ()
214+ desiredResources , err = checkCoherenceHash (deployment , storage , log )
215+ if err != nil {
216+ return in .HandleErrAndRequeue (ctx , err , nil , fmt .Sprintf (createResourcesFailedMessage , request .Name , request .Namespace , err ), in .Log )
242217 }
243218
244219 // create the result
@@ -283,9 +258,6 @@ func (in *CoherenceReconciler) Reconcile(ctx context.Context, request ctrl.Reque
283258 }
284259 return reconcile.Result {}, fmt .Errorf ("one or more secondary resource reconcilers failed to reconcile" )
285260 }
286- //} else {
287- // log.Info("Skipping updates for Coherence resource, annotation " + coh.AnnotationOperatorIgnore + " is set to true")
288- //}
289261
290262 // if replica count is zero update the status to Stopped
291263 if deployment .GetReplicas () == 0 {
@@ -340,6 +312,7 @@ func (in *CoherenceReconciler) SetupWithManager(mgr ctrl.Manager, cs clients.Cli
340312func (in * CoherenceReconciler ) GetReconciler () reconcile.Reconciler { return in }
341313
342314// ensureHashApplied ensures that the hash label is present in the Coherence resource, patching it if required
315+ // Returns true if the hash label was applied to the Coherence resource, or false if the label was already present
343316func (in * CoherenceReconciler ) ensureHashApplied (ctx context.Context , c * coh.Coherence ) (bool , error ) {
344317 currentHash := ""
345318 labels := c .GetLabels ()
@@ -349,14 +322,14 @@ func (in *CoherenceReconciler) ensureHashApplied(ctx context.Context, c *coh.Coh
349322
350323 // Re-fetch the Coherence resource to ensure we have the most recent copy
351324 latest := c .DeepCopy ()
352- hash , _ := coh .EnsureHashLabel (latest )
325+ hash , _ := coh .EnsureCoherenceHashLabel (latest )
353326
354327 if currentHash != hash {
355- if c .IsBeforeVersion ("3.3.0 " ) {
356- // Before 3.3.0 there was a bug calculating the has in the defaulting web-hook
328+ if c .IsBeforeVersion ("3.4.2 " ) {
329+ // Before 3.4.2 there was a bug calculating the hash in the defaulting web-hook
357330 // This would cause the hashes to be different here, when in fact they should not be
358331 // If the Coherence resource being processes has no version annotation, or a version
359- // prior to 3.3.0 then we return as if the hashes matched
332+ // prior to 3.4.2 then we return as if the hashes matched
360333 if labels == nil {
361334 labels = make (map [string ]string )
362335 }
0 commit comments