@@ -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
}
@@ -1008,8 +1008,14 @@ func appSyncEnabledForNextStep(appset *argov1alpha1.ApplicationSet, app argov1al
1008
1008
return true
1009
1009
}
1010
1010
1011
+ func isRollingSyncStrategy (appset * argov1alpha1.ApplicationSet ) bool {
1012
+ // It's only RollingSync if the type specifically sets it
1013
+ return appset .Spec .Strategy != nil && appset .Spec .Strategy .Type == "RollingSync" && appset .Spec .Strategy .RollingSync != nil
1014
+ }
1015
+
1011
1016
func progressiveSyncsRollingSyncStrategyEnabled (appset * argov1alpha1.ApplicationSet ) bool {
1012
- return appset .Spec .Strategy != nil && appset .Spec .Strategy .RollingSync != nil && appset .Spec .Strategy .Type == "RollingSync" && len (appset .Spec .Strategy .RollingSync .Steps ) > 0
1017
+ // ProgressiveSync is enabled if the strategy is set to `RollingSync` + steps slice is not empty
1018
+ return isRollingSyncStrategy (appset ) && len (appset .Spec .Strategy .RollingSync .Steps ) > 0
1013
1019
}
1014
1020
1015
1021
func isApplicationHealthy (app argov1alpha1.Application ) bool {
0 commit comments