-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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): Prevent Get & Sync from Hanging on Invalid Application Spec #21702
base: master
Are you sure you want to change the base?
Conversation
🔴 Preview Environment stopped on BunnyshellSee: Environment Details | Pipeline Logs Available commands (reply to this comment):
|
3057641
to
753d4f8
Compare
…ore printFinalStatus on sync command Signed-off-by: Almo Elda <[email protected]>
…rgoproj#21433) Signed-off-by: Jagpreet Singh Tamber <[email protected]> Signed-off-by: Alexandre Gaudreault <[email protected]> Co-authored-by: Alexandre Gaudreault <[email protected]> Signed-off-by: Almo Elda <[email protected]>
…rgoproj#21698) Signed-off-by: Keith Chong <[email protected]> Signed-off-by: Almo Elda <[email protected]>
argoproj#21677) Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Signed-off-by: Almo Elda <[email protected]>
…rgoproj#21676) Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Signed-off-by: Almo Elda <[email protected]>
Signed-off-by: Michael Crenshaw <[email protected]> Signed-off-by: Almo Elda <[email protected]>
Signed-off-by: Almo Elda <[email protected]>
Signed-off-by: Almo Elda <[email protected]>
58ef4e8
to
ac12366
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #21702 +/- ##
==========================================
+ Coverage 55.59% 55.61% +0.01%
==========================================
Files 340 340
Lines 57419 57474 +55
==========================================
+ Hits 31924 31965 +41
- Misses 22807 22817 +10
- Partials 2688 2692 +4 ☔ View full report in Codecov by Sentry. |
…lid-spec Signed-off-by: Almo Elda <[email protected]>
cmd/argocd/commands/app.go
Outdated
cancel() | ||
printFinalStatus(app) |
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.
printFinalStatus(app) | |
printFinalStatus(app) |
why are you printing after the cancel()
has been called?
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.
Good point, thanks
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.
This is correct otherwise the ctx never gets called in the Get function. It is better to give a cancellation signal when the timeout has occured.
cmd/argocd/commands/app.go
Outdated
|
||
appName, appNs := argo.ParseFromQualifiedName(args[0], appNamespace) | ||
|
||
if timeout != 0 { | ||
time.AfterFunc(time.Duration(timeout)*time.Second, func() { | ||
fmt.Println("Context cancelled due to timeout") |
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.
fmt.Println("Context cancelled due to timeout") |
I don't think it's necessary.
cmd/argocd/commands/app.go
Outdated
@@ -337,6 +337,7 @@ func NewApplicationGetCommand(clientOpts *argocdclient.ClientOptions) *cobra.Com | |||
refresh bool | |||
hardRefresh bool | |||
output string | |||
timeout int |
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.
timeout int | |
timeout uiint |
This should be uint
.
cmd/argocd/commands/app.go
Outdated
@@ -462,6 +473,7 @@ func NewApplicationGetCommand(clientOpts *argocdclient.ClientOptions) *cobra.Com | |||
}, | |||
} | |||
command.Flags().StringVarP(&output, "output", "o", "wide", "Output format. One of: json|yaml|wide|tree") | |||
command.Flags().IntVar(&timeout, "timeout", 15, "Specifies the maximum duration for the operation to complete. The command will terminate if the timeout is exceeded.") |
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.
command.Flags().IntVar(&timeout, "timeout", 15, "Specifies the maximum duration for the operation to complete. The command will terminate if the timeout is exceeded.") | |
command.Flags().UintVar(&timeout, "timeout", defaultCheckTimeoutSeconds, "Time out after this many seconds") |
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.
Works perfectly. I've left a few comments before we merge this PR. The changes work well for the sync command too even though you only added the timeout
flag to the get command. I wonder how and why?
Signed-off-by: Almo Elda <[email protected]>
…n also Signed-off-by: Almo Elda <[email protected]>
…lid-spec Signed-off-by: Almo Elda <[email protected]>
Thanks @nitishfy argo-cd/cmd/argocd/commands/app.go Line 2588 in 8449bab
|
why can't you call the waitOnApplicationStatus() in the get command too like the way we are calling for |
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.
PTAL now.
Co-authored-by: Alexandre Gaudreault <[email protected]> Signed-off-by: almoelda <[email protected]>
Signed-off-by: Almo Elda <[email protected]>
Signed-off-by: Almo Elda <[email protected]>
Signed-off-by: Almo Elda <[email protected]>
…lid-spec Signed-off-by: Almo Elda <[email protected]>
Signed-off-by: Almo Elda <[email protected]>
…timeout Signed-off-by: Almo Elda <[email protected]>
Signed-off-by: Almo Elda <[email protected]>
Signed-off-by: Almo Elda <[email protected]>
Signed-off-by: Almo Elda <[email protected]>
Signed-off-by: Almo Elda <[email protected]>
Signed-off-by: Almo Elda <[email protected]>
Signed-off-by: Almo Elda <[email protected]>
Closes #21613
Adding context cancellation to get cmd and cancelling the context before printFinalStatus on sync command
Checklist: