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(cli): fail fast on errors in argocd app diff (#15164) #15167

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

shailendher
Copy link

@shailendher shailendher commented Aug 22, 2023

Closes #15164

I suppose the errors were ignored earlier because diff utilities usually exit with a non-zero code if diff is present. I'm not really proficient with golang, I hope I've handled it in the right way but please take a look.

After fix:

export KUBECTL_EXTERNAL_DIFF=abcd
argocd app diff efs-csi-driver

===== /ServiceAccount kube-system/efs-csi-controller-sa ======
FATA[0001] exec: "abcd": executable file not found in $PATH 

Checklist:

  • Either (a) I've created an enhancement proposal and discussed it with the community, (b) this is a bug fix, or (c) this does not need to be in the release notes.
  • The title of the PR states what changed and the related issues number (used for the release note).
  • The title of the PR conforms to the Toolchain Guide
  • I've included "Closes [ISSUE #]" or "Fixes [ISSUE #]" in the description to automatically close the associated issue.
  • I've updated both the CLI and UI to expose my feature, or I plan to submit a second PR with them.
  • Does this PR require documentation updates?
  • I've updated documentation as required by this PR.
  • Optional. My organization is added to USERS.md.
  • I have signed off all my commits as required by DCO
  • I have written unit and/or e2e tests for my change. PRs without these are unlikely to be merged.
  • My build is green (troubleshooting builds).
  • My new feature complies with the feature status guidelines.
  • I have added a brief description of why this PR is necessary and/or what this PR solves.

Signed-off-by: Shailendher Ramanujam <shailusmilez@gmail.com>
@crenshaw-dev crenshaw-dev changed the title fix: Fail fast on errors (#15164) fix(cli): fail fast on errors in argocd app diff (#15164) Aug 22, 2023
@@ -1099,7 +1101,12 @@ func findandPrintDiff(ctx context.Context, app *argoappv1.Application, proj *arg
if !foundDiffs {
foundDiffs = true
}
_ = cli.PrintDiff(item.key.Name, live, target)
err = cli.PrintDiff(item.key.Name, live, target)
// ignore exitError since diff utilities usually return exit status 1 when diff is present
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you mind adding a unit test for this behavior?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, let me give it a try.

@codecov
Copy link

codecov bot commented Aug 22, 2023

Codecov Report

Patch coverage: 33.33% and project coverage change: -0.02% ⚠️

Comparison is base (7317d6d) 49.87% compared to head (e31463b) 49.86%.
Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #15167      +/-   ##
==========================================
- Coverage   49.87%   49.86%   -0.02%     
==========================================
  Files         262      263       +1     
  Lines       45179    45203      +24     
==========================================
+ Hits        22535    22541       +6     
- Misses      20426    20446      +20     
+ Partials     2218     2216       -2     
Files Changed Coverage Δ
cmd/argocd/commands/app.go 21.90% <33.33%> (+0.15%) ⬆️

... and 5 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

// ignore exitError since diff utilities usually return exit status 1 when diff is present
var execError *exec.Error
if err != nil && goerrors.As(err, &execError) {
errors.CheckError(err)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw, I noticed that the diff is also used in the app sync command here and I assume failing fast would break a lot of CI jobs. Perhaps, just log with a warning that diff is missing because of so and so error?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. What if we just let this function return the error up. diff can fail, sync can just log and move on.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, I've updated it to bubble up the error. Can you please take a look again?

Signed-off-by: Shailendher Ramanujam <shailusmilez@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CLI (app diff) does not fail fast on error
2 participants