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

vmware_guest_disk: Avoid using in maintenance DS #1321

Conversation

Tireg
Copy link
Contributor

@Tireg Tireg commented May 17, 2022

The get_recommended_datastore from the vmware_guest_disk filters out
datastores using the one with the greater amount of free space.
However, it doesn't check the datastore status (eg. inMaintenance).

When running the task on an SDRS cluster, which have a datastore in
maintenance, and that datastore is the one with the greater amount of
free space, the module fails with a pyvmomi error like:
"This operation is not allowed in the current state of the datastore".

This commit ensure to skip the selection of in-maintenance datastores by
not even checking their size, and exclude them immediately.

SUMMARY

Avoid recommending in-maintenance datastores when trying to create
a disk with vmware_guest_disk.

(Not able to find issues reported for this error, but IIRC I've seen at least one
in the previous days...)

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

vmware_guest_disk

ADDITIONAL INFORMATION

The get_recommended_datastore from the vmware_guest_disk filters out
datastores using the one with the greater amount of free space.
However, it doesn't check the datastore status (eg. inMaintenance).

When running the task on an SDRS cluster, which have a datastore in
maintenance, and that datastore is the one with the greater amount of
free space, the module fails with a pyvmomi error like:
"This operation is not allowed in the current state of the datastore".

This is because the recommended datastore is in-maintenance, and VMware
refuses to operate on a datastore with this state.

This commit ensure to skip the selection of in-maintenance datastores by
not even checking their size, and exclude them immediately.

Note that it may be required in other contexts such as :

@Tireg Tireg force-pushed the avoid-recommended-datastore-in-maintenance branch from 8cdee3c to 4c3d6b0 Compare May 17, 2022 13:22
Copy link
Collaborator

@mariolenz mariolenz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this PR @Tireg!

Could you please add a changelog fragment like this? Something like:

bugfixes:
  - vmware_guest_disk - Ignore datastores in maintenance mode (https://github.com/ansible-collections/community.vmware/pull/1321).

or similar.

The get_recommended_datastore from the vmware_guest_disk filters out
datastores using the one with the greater amount of free space.
However, it doesn't check the datastore status (eg. inMaintenance).

When running the task on an SDRS cluster, which have a datastore in
maintenance, and that datastore is the one with the greater amount of
free space, the module fails with a pyvmomi error like:
"This operation is not allowed in the current state of the datastore".

This commit ensure to skip the selection of in-maintenance datastores by
not even checking their size, and exclude them immediately.
@Tireg Tireg force-pushed the avoid-recommended-datastore-in-maintenance branch from 4c3d6b0 to eea80df Compare May 17, 2022 17:17
@softwarefactory-project-zuul
Copy link

@Tireg
Copy link
Contributor Author

Tireg commented May 17, 2022

This should be ok now.

I don't now what to do with this however : https://github.com/ansible-collections/community.vmware/blob/main/plugins/module_utils/vmware.py#L1669

I didn't read the code in depth but shouldn't the SDRS recommended datastore follow the same code path ?
Or should I duplicate the fix to this function ?

@mariolenz
Copy link
Collaborator

recheck

@mariolenz
Copy link
Collaborator

recheck

@softwarefactory-project-zuul
Copy link

Copy link
Collaborator

@mariolenz mariolenz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Thanks @Tireg!

@softwarefactory-project-zuul
Copy link

Build succeeded (gate pipeline).

✔️ ansible-tox-linters SUCCESS in 3m 55s
✔️ build-ansible-collection SUCCESS in 3m 15s
✔️ ansible-test-sanity-docker-stable-2.13 SUCCESS in 11m 14s
✔️ ansible-test-units-community-vmware-python38 SUCCESS in 5m 54s
✔️ ansible-galaxy-importer SUCCESS in 4m 19s

@softwarefactory-project-zuul softwarefactory-project-zuul bot merged commit c673d75 into ansible-collections:main Jun 17, 2022
softwarefactory-project-zuul bot pushed a commit that referenced this pull request Jun 18, 2022
Backport vmware_guest_disk: Avoid using in maintenance DS

Backport #1321
SUMMARY
Avoid recommending in-maintenance datastores when trying to create a disk with vmware_guest_disk.
ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME
vmware_guest_disk
ADDITIONAL INFORMATION
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants