add a new `--degraded` flag to `argocd app wait` command
Summary
We would like to add a new flag to the argocd app wait CLI to stop waiting when the health status is degraded.
Motivation
argocd app wait already have the following flags:
--operation: waits for pending operations.--sync: waits for the app to be synced--suspended: wait for the health status to besuspended, can be combined with--health--health: wait for the health status to behealthy, or to transitioned todegraded(from another known status).
For reference:
- https://github.com/argoproj/argo-cd/blob/master/cmd/argocd/commands/app.go#L1722
- https://github.com/argoproj/argo-cd/blob/5676ab5c9bc37cf4d8e60968745f30a3eeb98038/cmd/argocd/commands/app.go#L1606-L1620
We perform our deployments in our CI pipelines by running the following commands:
argocd app syncto trigger a syncargo app wait --health --timeout <some timeout>to wait for the deployment to complete
This works for most cases, but there is one scenario where this does not work well. If the sync instantly fails, or fails very quickly (for example, canaries misconfiguration), argocd app wait will directly see the app in a degraded state and will wait until the timeout is reached, giving delayed feedback to our developers and generating a bit of confusion.
We tried to play with the currently available flags, but none is really fitting our need. The only workaround we found so far is to call argocd app get after the sync and before the wait: we can then grep the health status and decide whether or not to run argocd app wait. But overall, that'd be cleaner if we just have a combination of flags to exit argocd app wait if the app is either healthy or degraded.
Proposal
There is already a --suspended flag for argocd app wait to wait on the suspended health state. This flag can also be combined with --health to wait on both healthy or suspended state.
The proposal is to add a new flag --degraded to argocd app wait that works like --suspended:
- If using
--degradedonly,argocd app waitwill wait until the state isdegraded - If using
--health --degraded,argocd app waitwill wait until the state is eitherdegradedorhealthy
FYI, I opened a PR with the change I have in mind: https://github.com/argoproj/argo-cd/pull/8497
we faced exactly the same scenario in our CI/CD and we watch this issue with great interest. Is there a chance the PR will get a go in the following months? I see it is pending review, though if any help is required down the line with implementation I would be happy to assist.
I ran argocd app wait --help on v2.8.10 and the flag seems to be present. Shouldn't this issue be closed?
See output:
Flags:
--degraded Wait for degraded
--health Wait for health
-h, --help help for wait
--operation Wait for pending operations
--resource stringArray Sync only specific resources as GROUP:KIND:NAME or !GROUP:KIND:NAME. Fields may be blank and '*' can be used. This option may be specified repeatedly
-l, --selector string Wait for apps by label. Supports '=', '==', '!=', in, notin, exists & not exists. Matching apps must satisfy all of the specified label constraints.
--suspended Wait for suspended
--sync Wait for sync
--timeout uint Time out after this many seconds