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

Fix disk creation resulting in 'invalid configuration for device' error #2009

Conversation

Yannik
Copy link
Contributor

@Yannik Yannik commented Feb 27, 2024

SUMMARY

Under some circumstances, disk creation fails with an invalid configuration for device error.
Once this error shows up for a VM, it persistently happens whenever trying to add disks, however, I do not know how to make it show up for a VM, sometimes it is just there.

In comparing the API calls done by VCenter (which works) and ansible (which fails with the error above), I noticed that VCenter sets fileOperation to create. Setting this in ansible, as done in this patch, fixes the disk creation in ansible.

The docs describe the fileOperation parameter like this:

Type of operation being performed on the backing of the specified virtual device. If no file operation is specified in the VirtualDeviceSpec, then any backing filenames in the VirtualDevice must refer to files that already exist. The "replace" and "delete" values for this property are only applicable to virtual disk backing files.

So it really must be set when the backing file does not exist, (which it ofc doesn't when creating a disk).

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

vm_device_helper

@Yannik
Copy link
Contributor Author

Yannik commented Feb 27, 2024

@mariolenz

The CI stage is failing with this error:

ERROR: Found 5 pylint issue(s) which need to be resolved:
ERROR: plugins/module_utils/vmware.py:1091:13: unidiomatic-typecheck: Use isinstance() rather than type() for a typecheck.
ERROR: plugins/module_utils/vmware.py:1093:13: unidiomatic-typecheck: Use isinstance() rather than type() for a typecheck.
ERROR: plugins/module_utils/vmware.py:1095:13: unidiomatic-typecheck: Use isinstance() rather than type() for a typecheck.
ERROR: scripts/inventory/vmware_inventory.py:286:11: unidiomatic-typecheck: Use isinstance() rather than type() for a typecheck.
ERROR: tests/unit/mock/loader.py:33:15: unidiomatic-typecheck: Use isinstance() rather than type() for a typecheck.

However, none of these LOC are touched by my PR.

@Yannik Yannik force-pushed the fix-disk-add-failing-with-invalid-configuration-for-device branch from 7df2a3b to c784d76 Compare September 12, 2024 06:47
@Yannik
Copy link
Contributor Author

Yannik commented Sep 12, 2024

@mariolenz Please consider merging this :)

@mariolenz
Copy link
Collaborator

I've assigned this PR to myself. Hopefully, this helps me to remember having a look at this.

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.

Under some circumstances, disk creation fails with an invalid configuration for device error. Once this error shows up for a VM, it persistently happens whenever trying to add disks, however, I do not know how to make it show up for a VM, sometimes it is just there.

In that case, it's hard to test this. But the code LGTM so let's give it a try :-)

@mariolenz mariolenz added bug This issue/PR relates to a bug mergeit labels Nov 11, 2024
Copy link

Build succeeded (gate pipeline).
https://ansible.softwarefactory-project.io/zuul/buildset/f0eae4bf7e7642f3abba3c99d405c715

✔️ ansible-tox-linters SUCCESS in 4m 57s
✔️ build-ansible-collection SUCCESS in 6m 07s
✔️ ansible-galaxy-importer SUCCESS in 4m 42s

Copy link

Pull request merge failed: Resource not accessible by integration, You may need to manually rebase your PR and retry.

@mariolenz
Copy link
Collaborator

Pull request merge failed: Resource not accessible by integration, You may need to manually rebase your PR and retry.

Sooner or later, I'd like to understand this...

@mariolenz mariolenz merged commit ccf14a9 into ansible-collections:main Nov 11, 2024
11 checks passed
@Yannik
Copy link
Contributor Author

Yannik commented Nov 11, 2024

Thank you @mariolenz

Would it be possible to backport this, atleast to 4.x?

softwarefactory-project-zuul bot pushed a commit that referenced this pull request Nov 12, 2024
… device' error (#2245)

Backport #2009
SUMMARY
Under some circumstances, disk creation fails with an invalid configuration for device error.
Once this error shows up for a VM, it persistently happens whenever trying to add disks, however, I do not know how to make it show up for a VM, sometimes it is just there.
In comparing the API calls done by VCenter (which works) and ansible (which fails with the error above), I noticed that VCenter sets fileOperation to create. Setting this in ansible, as done in this patch, fixes the disk creation in ansible.
The docs describe the fileOperation parameter like this:

Type of operation being performed on the backing of the specified virtual device. If no file operation is specified in the VirtualDeviceSpec, then any backing filenames in the VirtualDevice must refer to files that already exist. The "replace" and "delete" values for this property are only applicable to virtual disk backing files.

So it really must  be set when the backing file does not exist, (which it ofc doesn't when creating a disk).
ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME
vm_device_helper
@mariolenz
Copy link
Collaborator

Would it be possible to backport this, atleast to 4.x?

#2245

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue/PR relates to a bug mergeit
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants