Skip to content

Commit 52cb6b4

Browse files
authored
do not force-reapply if reconcile policy is "once" (#300)
* do not force-reapply if reconcile policy is "once" * fix typo (quotes)
1 parent 209239e commit 52cb6b4

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

pkg/reconciler/reconciler.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ const (
5858
maxOrder = math.MaxInt16
5959
)
6060

61+
const (
62+
digestOnce = "__once__"
63+
)
64+
6165
const (
6266
defaultReapplyInterval = 60 * time.Minute
6367
)
@@ -719,6 +723,7 @@ func (r *Reconciler) Apply(ctx context.Context, inventory *[]*InventoryItem, obj
719723
item.LastAppliedAt = &metav1.Time{Time: now}
720724
numUnready++
721725
} else if existingObject.GetDeletionTimestamp().IsZero() &&
726+
(existingObject.GetAnnotations()[r.annotationKeyDigest] != digestOnce || item.Digest != digestOnce) &&
722727
(existingObject.GetAnnotations()[r.annotationKeyDigest] != item.Digest || item.LastAppliedAt == nil || item.LastAppliedAt.Time.Before(now.Add(-reapplyInterval))) {
723728
switch updatePolicy {
724729
case UpdatePolicyRecreate:

pkg/reconciler/util.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func checkRange(x int, min int, max int) error {
6060

6161
func calculateObjectDigest(obj client.Object, componentDigest string, reconcilePolicy ReconcilePolicy) (string, error) {
6262
if reconcilePolicy == ReconcilePolicyOnce {
63-
return "__once__", nil
63+
return digestOnce, nil
6464
}
6565

6666
resourceVersion := obj.GetResourceVersion()

0 commit comments

Comments
 (0)