-
Notifications
You must be signed in to change notification settings - Fork 161
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
Zdevs autoinstall #2167
base: main
Are you sure you want to change the base?
Zdevs autoinstall #2167
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This LGTM. Thanks for the extra tests too.
I typically like the multi-commit merge but I think this one could be squashed into a single commit. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this. I have a few suggestions to discuss.
subiquity/server/controllers/zdev.py
Outdated
@@ -593,10 +596,43 @@ | |||
id="0.0.c0fe" type="generic-ccw" on="no" exists="yes" pers="no" auto="no" failed="yes" names=""''' # noqa: E501 | |||
|
|||
|
|||
ZdevAiItem = TypedDict( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For most things like this we been doing attrs, what is the motivation here for TypedDict instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The main point of the typedict is to use it as a type hint for make_autoinstall
and load_autoinstall_data
. But I can convert this data to an attr to store in self.ai_data and self.actions_done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
got it. I still lean towards the attrs implementation to stay consistent with other places in Subiquity. Can we try it in a new commit and see if it reads differently?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Chris and I updated the code to use attrs as well (in the last commit)
on = False | ||
state = "disabled" | ||
else: | ||
raise ValueError("action must be 'enable' or 'disable'") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
raise ValueError("action must be 'enable' or 'disable'") | |
raise AutoinstallError("action must be 'enable' or 'disable'") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
chzdev
is also called by non-autoinstall code. Maybe we catch the ValueError and wrap it in an AutoinstallError in autoinstall code.
subiquity/server/controllers/zdev.py
Outdated
"ZdevAiItem", | ||
{ | ||
"id": str, | ||
"state": Literal["enabled", "disabled"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggest using enable/disable here to match the apidef and to indicate that we are taking this action, not asserting initial state matches expectations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we had the following in our previous draft:
"id": str
"action": Literal["enable", "disable"]
Let's discuss if we think it's better
subiquity/server/controllers/zdev.py
Outdated
else: | ||
chzdev_cmd = ["chzdev", "--%s" % action, zdev.id] | ||
await arun_command(chzdev_cmd) | ||
await asyncio.sleep(random.random() * 0.4) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
await asyncio.sleep(random.random() * 0.4) | |
await asyncio.sleep(random.random() * 0.4 / self.app.scale_factor) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea, I guess that would make sense. I can even configure the delay directly in DryRunCommandRunner._get_delay_for_cmd
and skip the call to asyncio.sleep here.
Yeah, I'll rework the history a bit. I want to make the move |
Previously, in the Zdev controller, we had code to make sure that we didn't call `chzdev` when running in dry-run mode. Instead we would call asyncio.sleep. We can make the code simpler though by using CommandRunner. It has a dry-run implementation that does not actually execute commands - and allows configuring a sleep duration. Signed-off-by: Olivier Gayot <[email protected]>
2295d7f
to
534c7e6
Compare
Controls whether the device should be enabled or disabled. Supported values are: | ||
|
||
* ``enabled`` | ||
* ``disabled`` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's discuss if we want to support ignore
, and if not, should we be treating this more as a yaml boolean?
This introduces a new "zdevs" autoinstall, which makes it possible to enable or disable supported devices on IBM Z. One can supply a "zdevs" autoinstall section in the following format: zdevs: - id: 0.0.1506 state: enabled - id: 0.0.1507 state: enabled - id: 0.0.1508 state: disabled This is a list since the ordering of operations is important. Signed-off-by: Olivier Gayot <[email protected]>
534c7e6
to
6892bc7
Compare
Signed-off-by: Olivier Gayot <[email protected]>
This is to support doing basic actions (i.e., enable/disable) on zdevs with autoinstall. The work is a joint effort with @Chris-Peterson444.
In the first implementation we did, we used separate sections for
disable
andenable
, but the order is important for DASDs.