edge3: Exit non-zero when worker admin CLI commands fail#70112
Open
dkranchii wants to merge 1 commit into
Open
edge3: Exit non-zero when worker admin CLI commands fail#70112dkranchii wants to merge 1 commit into
dkranchii wants to merge 1 commit into
Conversation
The add-worker-queues, remove-worker-queues, and set-worker-concurrency
subcommands raised bare `SystemExit` after catching a TypeError from the
model layer, which yields exit status 0. Shell scripts wrapping these
commands treated failures as success and continued as if the queue or
concurrency change had been applied.
Pass the exception message to SystemExit so the process exits with
status 1 and writes the failure to stderr, matching the file's own
convention for validation-error paths (see the explicit
`raise SystemExit("Error: ...")` calls in the same subcommands) and the
`raise SystemExit(str(e))` pattern already used elsewhere in the edge3
CLI. The model layer already logs the error before raising, so the
redundant logger.error call is removed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
add-worker-queues,remove-worker-queues, andset-worker-concurrencyraised bareSystemExitafter catching aTypeErrorfrom the model layer (raised when the target worker is inOFFLINE,OFFLINE_MAINTENANCE, orUNKNOWNstate).SystemExit()with no argument yields exit code0, so shell scripts wrapping these commands saw success and continued as if the queue or concurrency change had been applied, when in fact it had been silently rejected.Pass the exception message to
SystemExit(str(e))so the process exits with status1and writes the failure to stderr. Matches this file's own convention for validation-error paths (e.g.raise SystemExit("Error: No queues specified to add.")a few lines above each fix site) and theraise SystemExit(str(e))pattern already used inproviders/edge3/src/airflow/providers/edge3/cli/worker.py.The model layer at
providers/edge3/src/airflow/providers/edge3/models/edge_worker.pyalready callslogger.error(error_message)before raising, so the CLI-sidelogger.error(str(e))was strictly duplicative and is removed.Adds parametrized tests over all three subcommands asserting that
SystemExit.codecarries the error message (i.e. exit status is1, not0).Was generative AI tooling used to co-author this PR?