Repository navigation
Conversation
--subsystem was only an option of `cloud-init devel hotplug-hook` itself, so it had to come before the hotplug action: `hotplug-hook query -s net` failed as if --subsystem was missing, and `hotplug-hook query --help` did not mention it. Also accept --subsystem after the query, handle and enable actions, so it shows in their help, while the form used by tools/hook-hotplug (`--subsystem=net handle ...`) keeps working. As argparse can no longer require it on either parser, handle_args() reports it when missing. Fixes canonicalGH-4826 Fixes canonicalGH-4827
1 of 2 tasks
Member
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.
Proposed Commit Message
Additional Context
Fixes #4826
Fixes #4827
--subsystemis now accepted both before and after the hotplug action. The leading form keeps working unchanged. That includes the--subsystem=net handle --devpath=... --udevaction=...arguments thattools/hook-hotplugpasses tocloud-init-hotplugd.The
query,handleandenableparsers get their own-s/--subsystemwithdefault=argparse.SUPPRESS, so an action given without it can't overwrite a value parsed before the action. argparse can't require an option that may appear on either parser, sohandle_args()now makes that check. It uses argparse's usual message and exit code 2, and it runs beforeInitis created, so a missing option still has no side effects.hotplug-hook -s net queryhotplug-hook query -s nethotplug-hook handle -d PATH -u add -s nethotplug-hook query --help-h-s, --subsystem {net}hotplug-hook query-s/--subsystemrequired-s/--subsystemrequiredThe new
TestGetParsertests cover these cases. Verified with the pinned black, isort, ruff, pylint and mypy, and the full unit suite passes (5,787 tests).Test Steps
Merge type