@@ -210,16 +210,16 @@ func (r *ApplicationSetReconciler) Reconcile(ctx context.Context, req ctrl.Reque
210
210
appSyncMap := map [string ]bool {}
211
211
212
212
if r .EnableProgressiveSyncs {
213
- if applicationSetInfo . Spec . Strategy == nil && len (applicationSetInfo .Status .ApplicationStatus ) > 0 {
214
- // If appset used progressive sync but stopped , clean up the progressive sync application statuses
213
+ if ! isRollingSyncStrategy ( & applicationSetInfo ) && len (applicationSetInfo .Status .ApplicationStatus ) > 0 {
214
+ // If an appset was previously syncing with a `RollingSync` strategy but it has switched to the default strategy , clean up the progressive sync application statuses
215
215
logCtx .Infof ("Removing %v unnecessary AppStatus entries from ApplicationSet %v" , len (applicationSetInfo .Status .ApplicationStatus ), applicationSetInfo .Name )
216
216
217
217
err := r .setAppSetApplicationStatus (ctx , logCtx , & applicationSetInfo , []argov1alpha1.ApplicationSetApplicationStatus {})
218
218
if err != nil {
219
219
return ctrl.Result {}, fmt .Errorf ("failed to clear previous AppSet application statuses for %v: %w" , applicationSetInfo .Name , err )
220
220
}
221
- } else if applicationSetInfo . Spec . Strategy != nil {
222
- // appset uses progressive sync
221
+ } else if isRollingSyncStrategy ( & applicationSetInfo ) {
222
+ // The appset uses progressive sync with `RollingSync` strategy
223
223
for _ , app := range currentApplications {
224
224
appMap [app .Name ] = app
225
225
}
@@ -1000,8 +1000,14 @@ func appSyncEnabledForNextStep(appset *argov1alpha1.ApplicationSet, app argov1al
1000
1000
return true
1001
1001
}
1002
1002
1003
+ func isRollingSyncStrategy (appset * argov1alpha1.ApplicationSet ) bool {
1004
+ // It's only RollingSync if the type specifically sets it
1005
+ return appset .Spec .Strategy != nil && appset .Spec .Strategy .Type == "RollingSync" && appset .Spec .Strategy .RollingSync != nil
1006
+ }
1007
+
1003
1008
func progressiveSyncsRollingSyncStrategyEnabled (appset * argov1alpha1.ApplicationSet ) bool {
1004
- return appset .Spec .Strategy != nil && appset .Spec .Strategy .RollingSync != nil && appset .Spec .Strategy .Type == "RollingSync" && len (appset .Spec .Strategy .RollingSync .Steps ) > 0
1009
+ // ProgressiveSync is enabled if the strategy is set to `RollingSync` + steps slice is not empty
1010
+ return isRollingSyncStrategy (appset ) && len (appset .Spec .Strategy .RollingSync .Steps ) > 0
1005
1011
}
1006
1012
1007
1013
func isApplicationHealthy (app argov1alpha1.Application ) bool {
0 commit comments