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): Prevent Get & Sync from Hanging on Invalid Application Spec #21702

Open
wants to merge 25 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
858a48b
adding context cancellation to get cmd and cancelling the context bef…
almoelda Jan 29, 2025
af34343
feat: add support for azure workload identity in Microsoft Entra SSO …
jagpreetstamber Jan 29, 2025
c5153c5
fix: Update argo-ui dependency to pull in OCI icon (#18646) (#21698)
keithchong Jan 29, 2025
312dd15
chore(deps): bump github.com/bmatcuk/doublestar/v4 from 4.8.0 to 4.8.…
dependabot[bot] Jan 29, 2025
9ef20a5
chore(deps): bump google.golang.org/protobuf from 1.36.3 to 1.36.4 (#…
dependabot[bot] Jan 29, 2025
9790d93
chore(metrics)!: remove deprecated metrics (#21697)
crenshaw-dev Jan 29, 2025
265536c
codegen
almoelda Jan 29, 2025
ac12366
add cancel call to defer on app get
almoelda Jan 29, 2025
fe3686e
Merge remote-tracking branch 'upstream/master' into cli-hangs-on-inva…
almoelda Jan 29, 2025
564b7cb
app get timeout to uint, app sync do not print after timeout reached
almoelda Jan 29, 2025
8449bab
app get timeout default change to common variable, changed descriptio…
almoelda Jan 29, 2025
693ccd2
Merge remote-tracking branch 'upstream/master' into cli-hangs-on-inva…
almoelda Jan 29, 2025
6f13f63
Update cmd/argocd/commands/app.go
almoelda Feb 1, 2025
0061e3f
codegen
almoelda Feb 2, 2025
e69263c
adding a test and a simulateTimeout to the mock client
almoelda Feb 2, 2025
7c13a30
timeout handling
almoelda Feb 2, 2025
61caf4e
Merge remote-tracking branch 'upstream/master' into cli-hangs-on-inva…
almoelda Feb 2, 2025
74b736e
lose debug code
almoelda Feb 2, 2025
0984859
introduce getAppStateWithRetry to ensure retry without refresh after …
almoelda Feb 2, 2025
9bd679e
revert time sleep in app_test
almoelda Feb 2, 2025
6c69778
introduce lock sync on app in waitOnApplicationStatus
almoelda Feb 2, 2025
a44bde2
fix lock sync on app in waitOnApplicationStatus
almoelda Feb 2, 2025
49ad06f
change app variable inside waitOnApplicationStatus.AfterFunc
almoelda Feb 2, 2025
13e9e8d
remove unnecessary new lines
almoelda Feb 2, 2025
5106b19
lint fix
almoelda Feb 2, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions cmd/argocd/commands/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ func NewApplicationGetCommand(clientOpts *argocdclient.ClientOptions) *cobra.Com
refresh bool
hardRefresh bool
output string
timeout uint
showParams bool
showOperation bool
appNamespace string
Expand Down Expand Up @@ -382,17 +383,26 @@ 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)
}
acdClient := headless.NewClientOrDie(clientOpts, c)
conn, appIf := acdClient.NewApplicationClientOrDie()
defer argoio.Close(conn)
defer func() {
argoio.Close(conn)
cancel()
}()
almoelda marked this conversation as resolved.
Show resolved Hide resolved

appName, appNs := argo.ParseFromQualifiedName(args[0], appNamespace)

if timeout != 0 {
time.AfterFunc(time.Duration(timeout)*time.Second, func() {
cancel()
almoelda marked this conversation as resolved.
Show resolved Hide resolved
})
}
almoelda marked this conversation as resolved.
Show resolved Hide resolved

app, err := appIf.Get(ctx, &application.ApplicationQuery{
Name: &appName,
Refresh: getRefreshType(refresh, hardRefresh),
Expand Down Expand Up @@ -462,6 +472,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().UintVar(&timeout, "timeout", defaultCheckTimeoutSeconds, "Time out after this many seconds")
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")
Expand Down Expand Up @@ -2577,7 +2588,7 @@ func waitOnApplicationStatus(ctx context.Context, acdClient argocdclient.Client,
if timeout != 0 {
time.AfterFunc(time.Duration(timeout)*time.Second, func() {
_, appClient := acdClient.NewApplicationClientOrDie()
app, err := appClient.Get(ctx, &application.ApplicationQuery{
almoelda marked this conversation as resolved.
Show resolved Hide resolved
_, err := appClient.Get(ctx, &application.ApplicationQuery{
Name: &appRealName,
AppNamespace: &appNs,
})
Expand All @@ -2588,7 +2599,6 @@ func waitOnApplicationStatus(ctx context.Context, acdClient argocdclient.Client,
fmt.Println("This is the state of the app after `wait` timed out:")
}

printFinalStatus(app)
cancel()

if printSummary {
Expand Down
1 change: 1 addition & 0 deletions docs/user-guide/commands/argocd_app_get.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading