-
Notifications
You must be signed in to change notification settings - Fork 144
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
Refactor order of actions in guest reboot implementations #3469
Open
happz
wants to merge
3
commits into
main
Choose a base branch
from
cleanup-guest-reboot-implementations
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains 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
c314f9b
to
6087ca4
Compare
6087ca4
to
7b7ab65
Compare
a729b93
to
79497d7
Compare
Things worked, but the code was not easy to understand and follow: * it wasn't obvious custom reboot `command` and hard reboots are not compatible; * it wasn't obvious that custom reboot command can come only from reboot request data stored by `tmt-reboot`; * the ordering of hard, soft and soft-with-custom-command was unclear, * `command` of `reboot()` was not the same as `command` of `perform_reboot()`; * the relationship between `reboot()` and `perform_reboot()` was unclear; * often all known arguments were passed to `super().reboot()` or `perform_reboot()`, which was not incorrect, but harder for humans and linters to reason about; * docstrings of `reboot()` methods were incomplete or outdated, * plugins did not mention their special behavior in docstrings of `reboot()` method. To hopefully improve the situation, the patch makes the following changes: * uses `@overload` to clearly mark that `hard=True` means no custom reboot command; * it makes reboot handling in `TestInvocation` code more verbose to make the distinction between hard and soft reboots which should make the custom reboot command clearly attached to soft reboots only; * all `reboot()` methods now follow the same order of actions: handling hard reboot first, soft reboots second, with less dense code; * `perform_reboot()` now accepts "action" callback, not "command", and it is responsibility of `reboot()` to feed `perform_reboot()` wit the proper action (running remote command, local command, or calling testcloud API, and so on); * reduces "blind" passing of known values: `super().reboot(hard=hard)` is correct, but impossible for a type checker to map to the "hard or custom command" split; using `hard=True|False` helps linters narrow the situation; * cleans up docstrings, makes them as same as possible with plugin-specific additions and notes where necessary; * and mention reboot support levels in plugin docstrings.
79497d7
to
cf07da3
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
ci | full test
Pull request is ready for the full test execution
code | no functional change
"No Functional Change" intended. Patch should not change tmt's behavior in any way.
code | style
Code style changes not affecting functionality
command | reboot
Support for rebooting guests during `tmt run` and the `tmt-reboot` command
status | blocking other work
An important pull request, blocking other pull requests or issues
step | provision
Stuff related to the provision step
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.
Things worked, but the code was not easy to understand and follow:
command
and hard reboots are not compatible;tmt-reboot
;command
ofreboot()
was not the same ascommand
ofperform_reboot()
;reboot()
andperform_reboot()
was unclear;super().reboot()
orperform_reboot()
, which was not incorrect, but harder for humans and linters to reason about;reboot()
methods were incomplete or outdated,reboot()
method.To hopefully improve the situation, the patch makes the following changes:
@overload
to clearly mark thathard=True
means no custom reboot command;TestInvocation
code more verbose to make the distinction between hard and soft reboots which should make the custom reboot command clearly attached to soft reboots only;reboot()
methods now follow the same order of actions: handling hard reboot first, soft reboots second, with less dense code;perform_reboot()
now accepts "action" callback, not "command", and it is responsibility ofreboot()
to feedperform_reboot()
wit the proper action (running remote command, local command, or calling testcloud API, and so on);super().reboot(hard=hard)
is correct, but impossible for a type checker to map to the "hard or custom command" split; usinghard=True|False
helps linters narrow the situation;Pull Request Checklist