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 for double definition #15670

Merged
Show file tree
Hide file tree
Changes from 1 commit
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
12 changes: 12 additions & 0 deletions controller/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,18 @@ func (m *appStateManager) CompareAppState(app *v1alpha1.Application, project *v1
LastTransitionTime: &now,
})
}

// If we reach this path, this means that a namespace has been both defined in Git, as well in the
// application's managedNamespaceMetadata. We want to emit a warning in such cases.
if isManagedNamespace(targetObj, app) {
conditions = append(conditions, v1alpha1.ApplicationCondition{
Type: v1alpha1.ApplicationConditionRepeatedResourceWarning,
blakepettersson marked this conversation as resolved.
Show resolved Hide resolved
Message: fmt.Sprintf("Namespace %s has been defined in both the application's managedNamespaceMetadata as well as in the application source", targetObj.GetName()),
LastTransitionTime: &now,
})

failedToLoadObjs = true
}
}
ts.AddCheckpoint("dedup_ms")

Expand Down
3 changes: 2 additions & 1 deletion test/e2e/app_management_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1774,7 +1774,8 @@ func TestSourceNamespaceCanBeMigratedToManagedNamespaceWithoutBeingPrunedOrOutOf
Sync().
Then().
Expect(OperationPhaseIs(OperationSucceeded)).
Expect(SyncStatusIs(SyncStatusCodeSynced)).
Expect(Condition(ApplicationConditionRepeatedResourceWarning, fmt.Sprintf("Namespace %s has been defined in both the application's managedNamespaceMetadata as well as in the application source", DeploymentNamespace()))).
Expect(SyncStatusIs(SyncStatusCodeUnknown)).
And(func(app *Application) {
assert.Equal(t, &ManagedNamespaceMetadata{Labels: map[string]string{"foo": "bar"}}, app.Spec.SyncPolicy.ManagedNamespaceMetadata)
}).
Expand Down