Skip to content

Commit 4552a49

Browse files
Ensure hash annotation propagation on provider
Signed-off-by: Danil-Grigorev <[email protected]>
1 parent f4cbe27 commit 4552a49

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

internal/controller/genericprovider_controller.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ func (p *PhaseReconciler) ApplyFromCache(ctx context.Context) (*Result, error) {
381381
}
382382

383383
cacheHash := fmt.Sprintf("%x", hash.Sum(nil))
384-
if secret.GetAnnotations()[appliedSpecHashAnnotation] != cacheHash {
384+
if secret.GetAnnotations()[appliedSpecHashAnnotation] != cacheHash || p.provider.GetAnnotations()[appliedSpecHashAnnotation] != cacheHash {
385385
log.Info("Provider or cache state has changed", "cacheHash", cacheHash, "providerHash", secret.GetAnnotations()[appliedSpecHashAnnotation])
386386

387387
return &Result{}, nil
@@ -494,5 +494,14 @@ func setCacheHash(ctx context.Context, cl client.Client, provider genericprovide
494494
annotations[appliedSpecHashAnnotation] = cacheHash
495495
secret.SetAnnotations(annotations)
496496

497+
// Set hash on the provider to avoid cache re-use on re-creation
498+
annotations = provider.GetAnnotations()
499+
if annotations == nil {
500+
annotations = map[string]string{}
501+
}
502+
503+
annotations[appliedSpecHashAnnotation] = cacheHash
504+
provider.SetAnnotations(annotations)
505+
497506
return helper.Patch(ctx, secret)
498507
}

0 commit comments

Comments
 (0)