Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: check if application has prune only changes and automated prune is disabled when doing progressive sync (Fixes #21528) #21542

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion applicationset/controllers/applicationset_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -1095,7 +1095,20 @@ func (r *ApplicationSetReconciler) updateApplicationSetApplicationStatus(ctx con

appOutdated := false
if progressiveSyncsRollingSyncStrategyEnabled(applicationSet) {
appOutdated = syncStatusString == "OutOfSync"
appOutdated = syncStatusString == string(argov1alpha1.SyncStatusCodeOutOfSync)
pruneEnabled := app.Spec.SyncPolicy != nil && app.Spec.SyncPolicy.Automated != nil && app.Spec.SyncPolicy.Automated.Prune
if !pruneEnabled {
requirePruneOnly := true
for _, r := range app.Status.Resources {
if r.Status != argov1alpha1.SyncStatusCodeSynced && !r.RequiresPruning {
requirePruneOnly = false
break
}
}
crenshaw-dev marked this conversation as resolved.
Show resolved Hide resolved
if requirePruneOnly {
appOutdated = false
}
}
}

if appOutdated && currentAppStatus.Status != "Waiting" && currentAppStatus.Status != "Pending" {
Expand Down
83 changes: 83 additions & 0 deletions applicationset/controllers/applicationset_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4642,6 +4642,11 @@ func TestUpdateApplicationSetApplicationStatus(t *testing.T) {
Status: v1alpha1.SyncStatusCodeOutOfSync,
Revision: "Next",
},
Resources: []v1alpha1.ResourceStatus{
{
RequiresPruning: false,
},
},
},
},
{
Expand All @@ -4653,6 +4658,11 @@ func TestUpdateApplicationSetApplicationStatus(t *testing.T) {
Status: v1alpha1.SyncStatusCodeOutOfSync,
Revisions: []string{"Next", "OtherNext"},
},
Resources: []v1alpha1.ResourceStatus{
{
RequiresPruning: false,
},
},
},
},
},
Expand All @@ -4677,6 +4687,79 @@ func TestUpdateApplicationSetApplicationStatus(t *testing.T) {
},
},
},
{
name: "doesn't move an OutOfSync RollingSync application to waiting if only prune changes are needed and prune is disabled",
appSet: v1alpha1.ApplicationSet{
ObjectMeta: metav1.ObjectMeta{
Name: "name",
Namespace: "argocd",
},
Spec: v1alpha1.ApplicationSetSpec{
Strategy: &v1alpha1.ApplicationSetStrategy{
Type: "RollingSync",
RollingSync: &v1alpha1.ApplicationSetRolloutStrategy{
Steps: []v1alpha1.ApplicationSetRolloutStep{
{
MatchExpressions: []v1alpha1.ApplicationMatchExpression{},
},
{
MatchExpressions: []v1alpha1.ApplicationMatchExpression{},
},
},
},
},
},
Status: v1alpha1.ApplicationSetStatus{
ApplicationStatus: []v1alpha1.ApplicationSetApplicationStatus{
{
Application: "app1",
Message: "",
Status: "Healthy",
Step: "1",
TargetRevisions: []string{"Previous"},
},
},
},
},
apps: []v1alpha1.Application{
{
ObjectMeta: metav1.ObjectMeta{
Name: "app1",
},
Status: v1alpha1.ApplicationStatus{
Sync: v1alpha1.SyncStatus{
Status: v1alpha1.SyncStatusCodeOutOfSync,
Revision: "Next",
},
Resources: []v1alpha1.ResourceStatus{
{
Status: v1alpha1.SyncStatusCodeOutOfSync,
RequiresPruning: true,
},
},
},
Spec: v1alpha1.ApplicationSpec{
SyncPolicy: &v1alpha1.SyncPolicy{
Automated: &v1alpha1.SyncPolicyAutomated{
Prune: false,
},
},
},
},
},
appStepMap: map[string]int{
"app1": 0,
},
expectedAppStatus: []v1alpha1.ApplicationSetApplicationStatus{
{
Application: "app1",
Message: "",
Status: "Healthy",
Step: "1",
TargetRevisions: []string{"Previous"},
},
},
},
{
name: "progresses a pending progressing application to progressing",
appSet: v1alpha1.ApplicationSet{
Expand Down
Loading