-
Notifications
You must be signed in to change notification settings - Fork 5k
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: unable to delete an Application if its target cluster is deleted, Argo CD enters infinite app deletion reconciliation loop #6557
Conversation
…, Argo CD enters infinite app deletion reconciliation loop Signed-off-by: Jonathan West <jonwest@redhat.com>
6f48002
to
3906c5b
Compare
Codecov Report
@@ Coverage Diff @@
## master #6557 +/- ##
==========================================
+ Coverage 41.14% 41.27% +0.12%
==========================================
Files 153 156 +3
Lines 20313 20677 +364
==========================================
+ Hits 8358 8534 +176
- Misses 10796 10936 +140
- Partials 1159 1207 +48
Continue to review full report at Codecov.
|
|
||
filteredObjs := FilterObjectsForDeletion(objs) | ||
objsMap, err := ctrl.getPermittedAppLiveObjects(app, proj) | ||
if err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For reviewers: FYI the code inside this if block is unchanged from the original (there aren't any changes hidden in there 😄 ), with the only exception being moving the call to ctrl.db.GetCluster
to above the block.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks @jgwest !
Before you merge this PR, please assign it to yourself.
// This call to 'ValidateDestination' ensures that the .spec.destination field of all Applications | ||
// returned by the informer/lister will have server field set (if not already set) based on the name. | ||
// (or, if not found, an error app condition) | ||
|
||
// If the server field is not set, set it based on the cluster name; if the cluster name can't be found, | ||
// log an error as an App Condition. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
// An ApplicationDestination has an 'inferred server' if the ApplicationDestination | ||
// contains a Name, but not a Server URL. In this case it is necessary to retrieve | ||
// the Server URL by looking up the cluster name. | ||
// | ||
// As of this writing, looking up the cluster name, and setting the URL, is | ||
// performed by 'utils.ValidateDestination(...)', which then calls SetInferredServer. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
// ValidateDestination sets the 'Server' value of the ApplicationDestination, if it is not set. | ||
// NOTE: this function WILL write to the object pointed to by the 'dest' parameter. | ||
// | ||
// If an ApplicationDestination has a Name field, but has an empty Server (URL) field, | ||
// ValidationDestination will look up the cluster by name (to get the server URL), and | ||
// set the corresponding Server field value. | ||
// | ||
// It also checks: | ||
// - If we used both name and server then we return an invalid spec error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Previously verified downstream: argoproj/applicationset#175 (comment) so removing tag. |
Description
On Application deletion, this PR verifies whether the target cluster (defined in the
destination
field of theApplication
resource) is defined within Argo CD (exists as a cluster secret, or is a local cluster). If the target cluster is not defined, it allows the Application to be deleted (rather than returning an error, as before).Details
If the target cluster is not defined, it is assumed that either:
a) the cluster was deleted from Argo CD (for example, via the Argo CD settings UI, or by deleting the cluster secret)
or
b) the Application spec is invalid (referencing a cluster that doesn't exist).
In both cases, since there are no cluster resources to clean up, we can safely allow the
Application
resource to be deleted.So, if we detect that the Application targets a valid cluster:
OTOH, if we detect the Application contains an invalid cluster:
Application
resource to be deleted (eg we remove the finalizer from the Application)See parent issue for reproduction steps and details.
Fixes #5817
Note on DCO:
If the DCO action in the integration test fails, one or more of your commits are not signed off. Please click on the Details link next to the DCO action for instructions on how to resolve this.
Checklist: