Skip to content
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

Merged
merged 6 commits into from Apr 22, 2020
Merged

Add virt.*defined states #55814

merged 6 commits into from Apr 22, 2020

Conversation

cbosdo
Copy link
Contributor

@cbosdo cbosdo commented Jan 8, 2020

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 into virt.*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

@cbosdo cbosdo requested a review from a team as a code owner January 8, 2020 14:24
@ghost ghost requested a review from Ch3LL January 8, 2020 19:16
@cbosdo cbosdo force-pushed the virt-defined-states branch 3 times, most recently from 73f3df8 to b21a93b Compare January 9, 2020 08:20
@cbosdo
Copy link
Contributor Author

cbosdo commented Jan 9, 2020

@Ch3LL I suspect the failing test to be unrelated to the PR

@cbosdo
Copy link
Contributor Author

cbosdo commented Jan 9, 2020

BTW, this PR is ready for review

@cbosdo
Copy link
Contributor Author

cbosdo commented Jan 9, 2020

oops... just found out a regression here. Will submit an update soon

@cbosdo
Copy link
Contributor Author

cbosdo commented Jan 9, 2020

Fixed now :)

tests/unit/states/test_virt.py Outdated Show resolved Hide resolved
salt/states/virt.py Outdated Show resolved Hide resolved
@cbosdo
Copy link
Contributor Author

cbosdo commented Jan 27, 2020

@Ch3LL comments addressed

@cbosdo cbosdo force-pushed the virt-defined-states branch 2 times, most recently from 41b8b42 to 3be80eb Compare February 1, 2020 16:59
@cbosdo
Copy link
Contributor Author

cbosdo commented Feb 1, 2020

rebased on master

@cbosdo
Copy link
Contributor Author

cbosdo commented Feb 3, 2020

@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 virt.running state at all. I couldn't even reproduce the error after the demo... definitely need to do some sacrifice to the demo kami next time

}

try:
if update:
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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.

salt/states/virt.py Outdated Show resolved Hide resolved
salt/modules/virt.py Outdated Show resolved Hide resolved
salt/states/virt.py Outdated Show resolved Hide resolved
salt/states/virt.py Outdated Show resolved Hide resolved
salt/states/virt.py Outdated Show resolved Hide resolved
salt/states/virt.py Outdated Show resolved Hide resolved
salt/states/virt.py Outdated Show resolved Hide resolved
}

try:
if update:
Copy link
Contributor

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.

@cbosdo
Copy link
Contributor Author

cbosdo commented Mar 9, 2020

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.
And setting update=True doesn't necessarily mean there will be an update: if there was no change there will be no update.
And that forces to add a deprecated parameter to the new virt.defined state.

@cbosdo
Copy link
Contributor Author

cbosdo commented Apr 14, 2020

@cbosdo Black needs to be run on this PR

@dwoz done

@cbosdo
Copy link
Contributor Author

cbosdo commented Apr 14, 2020

argh! I broke a test while rebasing... will fix tomorrow

@cbosdo
Copy link
Contributor Author

cbosdo commented Apr 15, 2020

Fixed! I also cherry picked a commit from PR #56414 to fix the test on py3.8 which is what I am running locally

@Ch3LL Ch3LL removed Merge Ready Feature new functionality including changes to functionality and code refactors, etc. Salt-Cloud labels Apr 17, 2020
Ch3LL
Ch3LL previously approved these changes Apr 17, 2020
@cbosdo cbosdo force-pushed the virt-defined-states branch 2 times, most recently from fdd8937 to 660147d Compare April 20, 2020 08:47
@cbosdo
Copy link
Contributor Author

cbosdo commented Apr 20, 2020

rebased on master and resolved the conflicts after the deprecated removal in virt states

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.
@dwoz dwoz merged commit 1317142 into saltstack:master Apr 22, 2020
Core Open PRs automation moved this from In progress to Done Apr 22, 2020
@cbosdo cbosdo deleted the virt-defined-states branch April 23, 2020 08:23
@sagetherage sagetherage added the ZRelease-Sodium retired label label May 18, 2020
@sagetherage sagetherage added this to Done in Sodium May 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ZRelease-Sodium retired label
Projects
No open projects
Sodium
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

5 participants