Skip to content

Commit 02c0de8

Browse files
sangdammadSangeetha Madamanchi
andauthored
fix(appset): When Appset is deleted, the controller should reconcile applicationset argoproj#23723 (argoproj#23823)
Signed-off-by: Sangeetha Madamanchi <[email protected]> Co-authored-by: Sangeetha Madamanchi <[email protected]>
1 parent edb3acf commit 02c0de8

File tree

2 files changed

+34
-7
lines changed

2 files changed

+34
-7
lines changed

applicationset/controllers/applicationset_controller.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1696,24 +1696,21 @@ func shouldRequeueForApplicationSet(appSetOld, appSetNew *argov1alpha1.Applicati
16961696
}
16971697

16981698
// Requeue if any ApplicationStatus.Status changed for Progressive sync strategy
1699-
// Requeue if deletionTimestamp added
17001699
if enableProgressiveSyncs {
17011700
if !cmp.Equal(appSetOld.Status.ApplicationStatus, appSetNew.Status.ApplicationStatus, cmpopts.EquateEmpty()) {
17021701
return true
17031702
}
1704-
if !cmp.Equal(appSetOld.DeletionTimestamp, appSetNew.DeletionTimestamp, cmpopts.EquateEmpty()) {
1705-
return true
1706-
}
17071703
}
17081704

1709-
// only compare the applicationset spec, annotations, labels and finalizers, specifically avoiding
1705+
// only compare the applicationset spec, annotations, labels and finalizers, deletionTimestamp, specifically avoiding
17101706
// the status field. status is owned by the applicationset controller,
17111707
// and we do not need to requeue when it does bookkeeping
17121708
// NB: the ApplicationDestination comes from the ApplicationSpec being embedded
17131709
// in the ApplicationSetTemplate from the generators
17141710
if !cmp.Equal(appSetOld.Spec, appSetNew.Spec, cmpopts.EquateEmpty(), cmpopts.EquateComparable(argov1alpha1.ApplicationDestination{})) ||
17151711
!cmp.Equal(appSetOld.GetLabels(), appSetNew.GetLabels(), cmpopts.EquateEmpty()) ||
1716-
!cmp.Equal(appSetOld.GetFinalizers(), appSetNew.GetFinalizers(), cmpopts.EquateEmpty()) {
1712+
!cmp.Equal(appSetOld.GetFinalizers(), appSetNew.GetFinalizers(), cmpopts.EquateEmpty()) ||
1713+
!cmp.Equal(appSetOld.DeletionTimestamp, appSetNew.DeletionTimestamp, cmpopts.EquateEmpty()) {
17171714
return true
17181715
}
17191716

applicationset/controllers/applicationset_controller_test.go

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7126,7 +7126,7 @@ func TestApplicationSetOwnsHandlerUpdate(t *testing.T) {
71267126
},
71277127
},
71287128
enableProgressiveSyncs: false,
7129-
want: false,
7129+
want: true,
71307130
},
71317131
}
71327132

@@ -7276,6 +7276,36 @@ func TestShouldRequeueForApplicationSet(t *testing.T) {
72767276
},
72777277
want: true,
72787278
},
7279+
{
7280+
name: "ApplicationSetWithDeletionTimestamp",
7281+
args: args{
7282+
appSetOld: &v1alpha1.ApplicationSet{
7283+
Status: v1alpha1.ApplicationSetStatus{
7284+
ApplicationStatus: []v1alpha1.ApplicationSetApplicationStatus{
7285+
{
7286+
Application: "app1",
7287+
Status: "Healthy",
7288+
},
7289+
},
7290+
},
7291+
},
7292+
appSetNew: &v1alpha1.ApplicationSet{
7293+
ObjectMeta: metav1.ObjectMeta{
7294+
DeletionTimestamp: &metav1.Time{Time: time.Now()},
7295+
},
7296+
Status: v1alpha1.ApplicationSetStatus{
7297+
ApplicationStatus: []v1alpha1.ApplicationSetApplicationStatus{
7298+
{
7299+
Application: "app1",
7300+
Status: "Waiting",
7301+
},
7302+
},
7303+
},
7304+
},
7305+
enableProgressiveSyncs: false,
7306+
},
7307+
want: true,
7308+
},
72797309
}
72807310
for _, tt := range tests {
72817311
t.Run(tt.name, func(t *testing.T) {

0 commit comments

Comments
 (0)