Skip to content

Commit 742b3da

Browse files
authored
force-reapply also if lastAppliedAt is missing (#220)
1 parent c880295 commit 742b3da

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

pkg/reconciler/reconciler.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -658,10 +658,9 @@ func (r *Reconciler) Apply(ctx context.Context, inventory *[]*InventoryItem, obj
658658
numUnready++
659659
} else if existingObject.GetDeletionTimestamp().IsZero() &&
660660
// TODO: make force-reconcile period (60 minutes as of now) configurable
661-
(existingObject.GetAnnotations()[r.annotationKeyDigest] != item.Digest || item.LastAppliedAt != nil && item.LastAppliedAt.Time.Before(now.Add(-60*time.Minute))) {
661+
(existingObject.GetAnnotations()[r.annotationKeyDigest] != item.Digest || item.LastAppliedAt == nil || item.LastAppliedAt.Time.Before(now.Add(-60*time.Minute))) {
662662
switch updatePolicy {
663663
case UpdatePolicyRecreate:
664-
// TODO: perform an additional owner id check
665664
if err := r.deleteObject(ctx, object, existingObject, hashedOwnerId); err != nil {
666665
return false, errors.Wrapf(err, "error deleting (while recreating) object %s", item)
667666
}
@@ -755,9 +754,9 @@ func (r *Reconciler) Apply(ctx context.Context, inventory *[]*InventoryItem, obj
755754

756755
// note: objects becoming obsolete during an apply are no longer honoring deletion policy (orphan)
757756
// TODO: not sure if there is a case where someone would like to orphan such resources while applying;
758-
// if so, then we probably should introduce a third deletion policy, OrphanApply or similar ...
757+
// if so, then we probably should introduce a third deletion policy, OrphanAlsoOnApply or OrphanAlways or similar ...
758+
// maybe even more values could be required, such as OrphanOnlyOnApply ...
759759
// in any case, the following code should be revisited; cleaned up or adjusted
760-
// orphan := item.DeletePolicy == DeletePolicyOrphan
761760
orphan := false
762761

763762
switch item.Phase {
@@ -771,7 +770,6 @@ func (r *Reconciler) Apply(ctx context.Context, inventory *[]*InventoryItem, obj
771770
} else {
772771
// note: here is a theoretical risk that we delete an existing foreign object, because informers are not yet synced
773772
// however not sending the delete request is also not an option, because this might lead to orphaned own dependents
774-
// TODO: perform an additional owner id check
775773
if err := r.deleteObject(ctx, item, existingObject, hashedOwnerId); err != nil {
776774
return false, errors.Wrapf(err, "error deleting object %s", item)
777775
}
@@ -878,7 +876,6 @@ func (r *Reconciler) Delete(ctx context.Context, inventory *[]*InventoryItem, ow
878876
// delete the object
879877
// note: here is a theoretical risk that we delete an existing (foreign) object, because informers are not yet synced
880878
// however not sending the delete request is also not an option, because this might lead to orphaned own dependents
881-
// TODO: perform an additional owner id check
882879
if err := r.deleteObject(ctx, item, existingObject, hashedOwnerId); err != nil {
883880
return false, errors.Wrapf(err, "error deleting object %s", item)
884881
}

0 commit comments

Comments
 (0)