-
Notifications
You must be signed in to change notification settings - Fork 6.3k
chore(refactor): remove app destination inferrence logic #21189
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
Conversation
Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com>
❌ Preview Environment deleted from BunnyshellAvailable commands (reply to this comment):
|
Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com>
Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #21189 +/- ##
==========================================
+ Coverage 55.25% 55.27% +0.01%
==========================================
Files 337 337
Lines 56940 56837 -103
==========================================
- Hits 31461 31414 -47
+ Misses 22801 22730 -71
- Partials 2678 2693 +15 ☔ View full report in Codecov by Sentry. |
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 <350466+crenshaw-dev@users.noreply.github.com>
Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com>
Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com>
Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com>
Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com>
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 <350466+crenshaw-dev@users.noreply.github.com>
Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com>
Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com>
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 <350466+crenshaw-dev@users.noreply.github.com>
Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com>
Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com>
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
) * refactor: remove app destination inferrence logic Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> * simplify Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> * more fixes Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> * more fixes Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> * codegen Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> * fix mocks Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> * simplify Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> * clusters all the way down Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> * simplify Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> * test Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> * lint Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> * tidy Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> * be less radical Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> --------- Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> Signed-off-by: Brett C. Dudo <brett@dudo.io>
) * refactor: remove app destination inferrence logic Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> * simplify Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> * more fixes Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> * more fixes Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> * codegen Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> * fix mocks Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> * simplify Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> * clusters all the way down Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> * simplify Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> * test Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> * lint Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> * tidy Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> * be less radical Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> --------- Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com>
) * refactor: remove app destination inferrence logic Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> * simplify Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> * more fixes Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> * more fixes Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> * codegen Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> * fix mocks Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> * simplify Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> * clusters all the way down Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> * simplify Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> * test Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> * lint Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> * tidy Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> * be less radical Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> --------- Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> Signed-off-by: flbla <flbla@users.noreply.github.com>
) * refactor: remove app destination inferrence logic Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> * simplify Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> * more fixes Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> * more fixes Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> * codegen Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> * fix mocks Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> * simplify Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> * clusters all the way down Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> * simplify Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> * test Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> * lint Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> * tidy Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> * be less radical Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> --------- Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com>
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