Refactor order of actions in guest reboot implementations #3469
+353
−103
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