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

proxmox_disk: prevent trying to shrink disks #7969

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

aBUDmdBQ
Copy link
Contributor

SUMMARY

Shrinking Disks is not supported by the PVE API and should be prevented by the module:
https://pve.proxmox.com/wiki/Resize_disks

Currently, when the configured size of the disk is smaller than the actual size, the module reports a change, but the change isn't actually happening. The module doesn't detect that this fails.

This PR checks if the user tries to shrink the disk and then fails instead of contacting the PVE API.

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME
  • proxmox_disk

Shrinking Disks is not supported by the PVE API (https://pve.proxmox.com/wiki/Resize_disks) and should be prevented by the module.
@ansibullbot
Copy link
Collaborator

The test ansible-test sanity --test pep8 [explain] failed with 1 error:

plugins/modules/proxmox_disk.py:820:161: E501: line too long (172 > 160 characters)

The test ansible-test sanity --test pep8 [explain] failed with 1 error:

plugins/modules/proxmox_disk.py:820:161: E501: line too long (172 > 160 characters)

The test ansible-test sanity --test pep8 [explain] failed with 1 error:

plugins/modules/proxmox_disk.py:820:161: E501: line too long (172 > 160 characters)

The test ansible-test sanity --test pep8 [explain] failed with 1 error:

plugins/modules/proxmox_disk.py:820:161: E501: line too long (172 > 160 characters)

click here for bot help

@ansibullbot
Copy link
Collaborator

@ansibullbot ansibullbot added bug This issue/PR relates to a bug ci_verified Push fixes to PR branch to re-run CI module module needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR new_contributor Help guide this first time contributor plugins plugin (any type) labels Feb 15, 2024
@felixfontein felixfontein added check-before-release PR will be looked at again shortly before release and merged if possible. backport-7 Automatically create a backport for the stable-7 branch backport-8 Automatically create a backport for the stable-8 branch labels Feb 16, 2024
Copy link
Collaborator

@felixfontein felixfontein 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 your contribution!

I don't know whether it's a good idea to prevent this, since both the old and the new behavior result in a failure. But it could happen that at some point the API suddenly supports shrinking, and then this extra check would be problematic.

…pts.yml

Co-authored-by: Felix Fontein <felix@fontein.de>
@castorsky
Copy link
Contributor

I'm agree with Felix. Current behavior is mentioned in module documentation and may be changed in future. I think there's no need to fix since this behavior is not a bug.

@aBUDmdBQ
Copy link
Contributor Author

You're saying that the module already should return a failed result when trying to shrink a disk?

When I try that, the module reports "changed", but the Proxmox Cluster Log shows an Error: TASK ERROR: shrinking disks is not supported

Versions we currently use:
Proxmox VE 8.1.4
community.general 8.3.0
python3-proxmoxer 1.2.0-2 (installed via apt. no other versions installed)

To make sure it's not the outdated version, i tried upgrading proxmoxer to 2.0.1 via pip, but this didn't change the behavior.

@felixfontein
Copy link
Collaborator

Hmm, maybe the API says "everything's fine" to the caller, queues the job, and only then the job fails while the caller (in this case the module) already returned "everything's ok"?

@castorsky
Copy link
Contributor

I have checked with different PVE versions and v8 reports success before task being queued (and failed).

  • v7.4.17
TASK [Modify disk] **********************************************************************************************************************************************
fatal: [localhost]: FAILED! => {"changed": false, "msg": "Failed to resize disk scsi0 in VM 100 with exception: 500 Internal Server Error: shrinking disks is not supported"}
  • v8.1.3
TASK [Modify disk] **********************************************************************************************************************************************
changed: [localhost]

@krauthosting
Copy link

@castorsky So this is a regression in PVE, right? Maybe it'd be a good idea to open a ticket with them about this.

FYI We are currently in the process of moving the proxmox_ modules to a separate collection. Hence we would like to resolve this PR asap so that we can move all issues over to community.proxmox

@aBUDmdBQ Would you be okay to close this PR and reopen it in community.proxmox if the upstream issue remains unresolved?

@castorsky
Copy link
Contributor

@castorsky So this is a regression in PVE, right? Maybe it'd be a good idea to open a ticket with them about this.

I'm not sure where is the root of the problem but it seems that this call should be async (via POST, not PUT). I have already implemented this for create_disk and move_disk functions because they can operate for a very long time. Maybe it's time to convert all sync calls to async.

This PR does not solve the root cause - it just patches some random consequence. So I think it's better to close PR in this repo.

@ansibullbot ansibullbot added has_issue stale_ci CI is older than 7 days, rerun before merging labels Feb 27, 2024
@aBUDmdBQ
Copy link
Contributor Author

aBUDmdBQ commented Mar 4, 2024

@krauthosting Yes, I'm fine with closing this and trying to get it fixed upstream. Otherwise I will open it again in community.proxmox

@ansibullbot ansibullbot removed the new_contributor Help guide this first time contributor label Mar 28, 2024
@felixfontein felixfontein added backport-9 Automatically create a backport for the stable-9 branch and removed backport-7 Automatically create a backport for the stable-7 branch labels May 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-8 Automatically create a backport for the stable-8 branch backport-9 Automatically create a backport for the stable-9 branch bug This issue/PR relates to a bug check-before-release PR will be looked at again shortly before release and merged if possible. ci_verified Push fixes to PR branch to re-run CI has_issue module module needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR plugins plugin (any type) stale_ci CI is older than 7 days, rerun before merging
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants