-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
chore(refactor): remove app destination inferrence logic #21189
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: Michael Crenshaw <[email protected]>
🔴 Preview Environment stopped on BunnyshellSee: Environment Details | Pipeline Logs Available commands (reply to this comment):
|
Signed-off-by: Michael Crenshaw <[email protected]>
Signed-off-by: Michael Crenshaw <[email protected]>
Signed-off-by: Michael Crenshaw <[email protected]>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #21189 +/- ##
==========================================
+ Coverage 55.21% 55.24% +0.03%
==========================================
Files 337 337
Lines 56945 56843 -102
==========================================
- Hits 31441 31405 -36
+ Misses 22828 22756 -72
- Partials 2676 2682 +6 ☔ View full report in Codecov by Sentry. |
Signed-off-by: Michael Crenshaw <[email protected]>
Signed-off-by: Michael Crenshaw <[email protected]>
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.
Note to self: there are probably a lot of code paths where we just need the destServerURL
, not the whole Cluster object. Consider simplifying those code paths.
Signed-off-by: Michael Crenshaw <[email protected]>
Signed-off-by: Michael Crenshaw <[email protected]>
Signed-off-by: Michael Crenshaw <[email protected]>
Signed-off-by: Michael Crenshaw <[email protected]>
Signed-off-by: Michael Crenshaw <[email protected]>
Signed-off-by: Michael Crenshaw <[email protected]>
Signed-off-by: Michael Crenshaw <[email protected]>
Signed-off-by: Michael Crenshaw <[email protected]>
Signed-off-by: Michael Crenshaw <[email protected]>
Signed-off-by: Michael Crenshaw <[email protected]>
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. Minor comments. Other people should review this I think because the potential side-effects are extremely hard to spot! Hopefully, we have enough unit test :)
cmd/argocd/commands/admin/app.go
Outdated
@@ -437,7 +442,7 @@ func reconcileApplications( | |||
sources = append(sources, app.Spec.GetSource()) | |||
revisions = append(revisions, app.Spec.GetSource().TargetRevision) | |||
|
|||
res, err := appStateManager.CompareAppState(&app, proj, revisions, sources, false, false, nil, false, false) | |||
res, err := appStateManager.CompareAppState(destCluster, &app, proj, revisions, sources, false, false, nil, false, false) |
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.
I feel like it would be better to do the inference again in CompareAppState instead of adding a parameter here. Or maybe have a private property with an accessor in the app destination object?
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.
As discussed, this is a refactor and can be improved further in another PR. No blocker.
Signed-off-by: Michael Crenshaw <[email protected]>
Signed-off-by: Michael Crenshaw <[email protected]>
Signed-off-by: Michael Crenshaw <[email protected]>
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.
From the description this seems to be a breaking change. Can you please confirm?
@leoluz not breaking, behavior should be 100% identical from a user's perspective. |
Signed-off-by: Michael Crenshaw <[email protected]>
if destination.Name != "" && destination.Server != "" { | ||
return nil, fmt.Errorf("application destination can't have both name and server defined: %s %s", destination.Name, destination.Server) | ||
} |
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.
Is this constraint existing at the CRD level today? I suspect that nothing fails today if both fields are present. Can you please confirm?
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.
Not exactly at the CRD level, but it is currently enforced at runtime: https://github.com/argoproj/argo-cd/pull/21189/files#diff-87b3b573e8c40af95af4dbda83f7dbc467219b02182415ff8e1f0ad73a82dc59L518
I tested locally in 2.14.0-rc5. If I set both fields, the app goes into an Unknown state with an error application destination can't have both name and server defined
.
The
utils.ValidateDestination
function has the side-effect of setting the app destination's server URL if it is not present.This side effect makes the code hard to read and has introduced subtle bugs and race conditions.
This PR is an attempt to remove the side effect and instead have the code load in the cluster details whenever they're needed. It may result in more network calls, so we need to be aware of performance. We also need to look out for places that still assume the old side-effect behavior and fix them to explicitly pull the cluster details instead.
The code is called in five places in the app controller:
finalizeApplicationDeletion
; since not all code paths inprocessAppOperationQueueItem
require a destCluster, we delegate that tofinalizeApplicationDeletion
when an app deletion is in progressprocessRequestedAppOperation
, which is another code path accessible fromprocessAppOperationQueueItem
; we call it as late as possible, and we need it in order to callSyncAppState
; there are some error paths inSyncAppState
which don't requiredestCluster
, but I think they'll be relatively rareprocessAppRefreshQueueItem
; here again there are a few code paths which could potentially short-circuit the need to get the cluster, but the most common paths require itcanProcessApp
, which is called in 5 places; I'd much rather avoid this work for most of those cases, but that requires a bigger refactor