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
Add virt.*defined states #55814
Add virt.*defined states #55814
Conversation
fe16e44
to
fc8080e
Compare
73f3df8
to
b21a93b
Compare
@Ch3LL I suspect the failing test to be unrelated to the PR |
BTW, this PR is ready for review |
oops... just found out a regression here. Will submit an update soon |
a50af64
to
9c5b016
Compare
Fixed now :) |
9c5b016
to
cb8c210
Compare
@Ch3LL comments addressed |
41b8b42
to
3be80eb
Compare
rebased on master |
@Akm0d unlike what I suspected, the bug I saw in the demo is not related to this PR at all since the resume action doesn't involve the |
salt/states/virt.py
Outdated
} | ||
|
||
try: | ||
if update: |
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.
It seems that someone still cannot use the update
kwarg to change behavior if i'm reading it correctly. What if they want to ensure an update does not occur? This would be changing behavior without proper deprecation still. Can you elaborate why you are changing this behavior?
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.
If using the update
parameter to ensure an update doesn't occur, this means that users have to set the deprecated parameter to True
in order to be able to use the new behavior... which doesn't make sense at all. And changing the default value for update
is disruptive as well.
The option that brings the least issues is to leave the update
parameter but warn that it is not used: the VM will only be updated if there is a difference in the configuration. This fits more the Salt states spirit and in all cases the update doesn't stop the VM to update it: it tries as much as possible to apply live changes.
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.
users have to set the deprecated parameter to True in order to be able to use the new behavior... which doesn't make sense at all.
Why does this not make sense? This would allow this to be an opt in feature while not changing behavior for users for another couple releases so they are prepared.
9552ea7
to
dbd1d49
Compare
dbd1d49
to
49ab152
Compare
salt/states/virt.py
Outdated
} | ||
|
||
try: | ||
if update: |
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.
users have to set the deprecated parameter to True in order to be able to use the new behavior... which doesn't make sense at all.
Why does this not make sense? This would allow this to be an opt in feature while not changing behavior for users for another couple releases so they are prepared.
Well having to set a deprecated parameter in order to use a new feature sounds awkward to me. |
49ab152
to
9d172b4
Compare
8c4abae
to
f35fb97
Compare
argh! I broke a test while rebasing... will fix tomorrow |
f35fb97
to
bc113be
Compare
Fixed! I also cherry picked a commit from PR #56414 to fix the test on py3.8 which is what I am running locally |
fdd8937
to
660147d
Compare
rebased on master and resolved the conflicts after the deprecated removal in virt states |
660147d
to
9bb5167
Compare
Users may want to use states to ensure a virtual storage pool is defined and not enforce it to be running. Extract the code that performs the pool definition / update from virt.pool_running state into a virt.pool_defined. Obviously the virt.pool_running state calls the virt.pool_defined one. In such a case no additionnal test is needed for virt.pool_defined since this is already tested with virt.pool_running.
In order to allow running dry-runs of virt.update module add a test parameter. This will later be used by the virt states.
In order to ensure a virtual guest is defined independently of its status, extract the corresponding code from the virt.running state. This commit also handles the __opts__['test'] for the running state. Since the update call only performs changes if needed, deprecate the update parameter.
Just like domains and storage pools, users may want to ensure a network is defined without influencing it's status. Extract the code from network_running state defining the network into a network_defined state. While at it, support __opt__['test'] == True in these states. Updating the network definition in the pool_defined state will come in a future PR.
virt.running state now may call virt.update with None mem and cpu parameters. This was not handled in _gen_xml(). Also add some more tests cases matching this for virt.update.
9bb5167
to
4e6ea37
Compare
What does this PR do?
This PR extracts the code defining and/or updating the VM, storage pool or network from the corresponding
virt.*running
state intovirt.*defined
states.This allows ensuring a VM, storage pool or network is defined without needing to care about it's status.
While at it, implement the
__opts__['test']
support for those states. The returned values from the running states have been keep intact as much as possible.Since the running states are using the new defined ones, the existing running tests are enough to ensure the defined states are working fine.
What issues does this PR fix or reference?
Tests written?
Yes
Commits signed with GPG?
Yes