Repository navigation
Conversation
The return in the finally clause discarded the exception, so raise_on_error=True never raised. Return after the try instead, and only re-raise launch errors when raise_on_error is set so callers passing False still get the -1 return code. Fixes apache#9289
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.
What is the purpose of the change
Fixes #9289.
shell_commandinbin/docker-to-squash.pyreturned from itsfinallyclause. Areturninfinallydiscards any exception in flight, soraise_on_error=Truenever raised:shell_command(["false"], False, False, True)just returned(b'', b'', 1). Because of thatcheck_dependenciesreported success when hadoop or/usr/sbin/mksquashfswas missing, and failed hadoop commands (e.g. inatomic_upload_mv_to_hdfs) went unnoticed.Changes:
returnout offinally, so the timer is still cancelled but exceptions propagate.exceptblock, only re-raise whenraise_on_erroris set (withfrom ex). Withraise_on_error=False, a command that can't be started (e.g.hadoopnot installed) still returns rc-1like today, sodoes_hdfs_entry_exist(..., raise_on_error=False)and the otherFalsecallers keep their current behavior.test_shell_command, which asserted the old behavior: withraise_on_error=Falsebothbadcmdandfalsereturn a non-zero rc, withraise_on_error=Trueboth raise.How was the change tested
python -m unittest -v test_docker_to_squashinbin/with Python 3.9: passes. The updated test fails on master (Exception not raised).from collections import Iterable), that's one of the other follow-ups from docs: Add comments to docker-to-squash.py #9284, so I left it alone here.Upgrade notes
raise_on_error=True(the default for mosthdfs_*helpers, andcheck_dependencies) will now actually see the exception. That's the documented intent, but it's a behavior change for anyone who relied on the silent return code.An AI assistant helped draft this change; I reviewed it and take responsibility for it.
Happy to adjust anything, lmk.