-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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?
Changes from 1 commit
858a48b
af34343
c5153c5
312dd15
9ef20a5
9790d93
265536c
ac12366
fe3686e
564b7cb
8449bab
693ccd2
6f13f63
0061e3f
e69263c
7c13a30
61caf4e
74b736e
0984859
9bd679e
6c69778
a44bde2
49ad06f
13e9e8d
5106b19
e228de8
2b375f5
6b4bdf1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
…ore printFinalStatus on sync command Signed-off-by: Almo Elda <almogldbh@gmail.com>
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -337,6 +337,7 @@ func NewApplicationGetCommand(clientOpts *argocdclient.ClientOptions) *cobra.Com | |||||
refresh bool | ||||||
hardRefresh bool | ||||||
output string | ||||||
timeout int | ||||||
showParams bool | ||||||
showOperation bool | ||||||
appNamespace string | ||||||
|
@@ -382,7 +383,7 @@ func NewApplicationGetCommand(clientOpts *argocdclient.ClientOptions) *cobra.Com | |||||
`), | ||||||
|
||||||
Run: func(c *cobra.Command, args []string) { | ||||||
ctx := c.Context() | ||||||
ctx, cancel := context.WithCancel(c.Context()) | ||||||
almoelda marked this conversation as resolved.
Show resolved
Hide resolved
almoelda marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
if len(args) == 0 { | ||||||
c.HelpFunc()(c, args) | ||||||
os.Exit(1) | ||||||
|
@@ -393,6 +394,13 @@ func NewApplicationGetCommand(clientOpts *argocdclient.ClientOptions) *cobra.Com | |||||
|
||||||
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 commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
I don't think it's necessary. |
||||||
cancel() | ||||||
almoelda marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
}) | ||||||
} | ||||||
|
||||||
app, err := appIf.Get(ctx, &application.ApplicationQuery{ | ||||||
Name: &appName, | ||||||
Refresh: getRefreshType(refresh, hardRefresh), | ||||||
|
@@ -462,6 +470,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 commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
command.Flags().BoolVar(&showOperation, "show-operation", false, "Show application operation") | ||||||
command.Flags().BoolVar(&showParams, "show-params", false, "Show application parameters and overrides") | ||||||
command.Flags().BoolVar(&refresh, "refresh", false, "Refresh application data when retrieving") | ||||||
|
@@ -2588,8 +2597,8 @@ func waitOnApplicationStatus(ctx context.Context, acdClient argocdclient.Client, | |||||
fmt.Println("This is the state of the app after `wait` timed out:") | ||||||
} | ||||||
|
||||||
printFinalStatus(app) | ||||||
cancel() | ||||||
printFinalStatus(app) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
why are you printing after the There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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. |
||||||
|
||||||
if printSummary { | ||||||
fmt.Println() | ||||||
|
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 should be
uint
.