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

Module proxmox_kvm restarted state bug fix #6773

Merged
merged 7 commits into from
Jun 26, 2023

Conversation

juan210012
Copy link
Contributor

@juan210012 juan210012 commented Jun 23, 2023

SUMMARY

Previously, the restarted state used both stop and start vm functions to restart a vm. In some cases, the start_vm function starts before the vm on Proxmox finishes shutting down. This causes the start_vm function to return saying that the vm is already running. The vm ends up in the stopped state and the output will wrongly display that the restart was successful.
This change introduces the a new function that utilizes the Proxmox reboot endpoint instead for a more reliable method of restarting a vm.

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

proxmox_kvm

ADDITIONAL INFORMATION

To reproduce this bug, have a running vm on Proxmox with these parameters set for High Availability:
Proxmox-HA-UI
Then run an Ansible playbook with the state set to restarted.
There may be other vm configurations in which the restart fails but this is the one I have found to fail often.

This change does not produce a different output.

Previously, the `restarted` state used both stop and start vm functions to restart a vm.
This change introduces the a new function that utilizes the proxmox reboot endpoint instead for a more reliable method of restarting a vm.
@ansibullbot
Copy link
Collaborator

@ansibullbot ansibullbot added WIP Work in progress bug This issue/PR relates to a bug module module new_contributor Help guide this first time contributor plugins plugin (any type) labels Jun 23, 2023
@juan210012 juan210012 changed the title Change proxmox_kvm restart to use new method Module proxmox_kvm restarted state bug fix Jun 23, 2023
@juan210012 juan210012 changed the title Module proxmox_kvm restarted state bug fix Module proxmox_kvm restarted state bug fix Jun 23, 2023
@juan210012 juan210012 marked this pull request as ready for review June 23, 2023 20:28
@ansibullbot ansibullbot removed the WIP Work in progress label Jun 23, 2023
@felixfontein felixfontein added check-before-release PR will be looked at again shortly before release and merged if possible. backport-6 labels Jun 24, 2023
@ansibullbot

This comment was marked as outdated.

@ansibullbot ansibullbot added ci_verified Push fixes to PR branch to re-run CI needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR labels Jun 25, 2023
…yaml

Co-authored-by: Felix Fontein <felix@fontein.de>
@ansibullbot ansibullbot removed ci_verified Push fixes to PR branch to re-run CI needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR labels Jun 25, 2023
@felixfontein felixfontein removed the check-before-release PR will be looked at again shortly before release and merged if possible. label Jun 26, 2023
@felixfontein felixfontein merged commit 3571df8 into ansible-collections:main Jun 26, 2023
@patchback
Copy link

patchback bot commented Jun 26, 2023

Backport to stable-6: 💔 cherry-picking failed — conflicts found

❌ Failed to cleanly apply 3571df8 on top of patchback/backports/stable-6/3571df837d7c7f2c0aa5d6b02618635b0e4454cb/pr-6773

Backporting merged PR #6773 into main

  1. Ensure you have a local repo clone of your fork. Unless you cloned it
    from the upstream, this would be your origin remote.
  2. Make sure you have an upstream repo added as a remote too. In these
    instructions you'll refer to it by the name upstream. If you don't
    have it, here's how you can add it:
    $ git remote add upstream https://github.com/ansible-collections/community.general.git
  3. Ensure you have the latest copy of upstream and prepare a branch
    that will hold the backported code:
    $ git fetch upstream
    $ git checkout -b patchback/backports/stable-6/3571df837d7c7f2c0aa5d6b02618635b0e4454cb/pr-6773 upstream/stable-6
  4. Now, cherry-pick PR Module proxmox_kvm restarted state bug fix #6773 contents into that branch:
    $ git cherry-pick -x 3571df837d7c7f2c0aa5d6b02618635b0e4454cb
    If it'll yell at you with something like fatal: Commit 3571df837d7c7f2c0aa5d6b02618635b0e4454cb is a merge but no -m option was given., add -m 1 as follows instead:
    $ git cherry-pick -m1 -x 3571df837d7c7f2c0aa5d6b02618635b0e4454cb
  5. At this point, you'll probably encounter some merge conflicts. You must
    resolve them in to preserve the patch from PR Module proxmox_kvm restarted state bug fix #6773 as close to the
    original as possible.
  6. Push this branch to your fork on GitHub:
    $ git push origin patchback/backports/stable-6/3571df837d7c7f2c0aa5d6b02618635b0e4454cb/pr-6773
  7. Create a PR, ensure that the CI is green. If it's not — update it so that
    the tests and any other checks pass. This is it!
    Now relax and wait for the maintainers to process your pull request
    when they have some cycles to do reviews. Don't worry — they'll tell you if
    any improvements are necessary when the time comes!

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

@patchback
Copy link

patchback bot commented Jun 26, 2023

Backport to stable-7: 💚 backport PR created

✅ Backport PR branch: patchback/backports/stable-7/3571df837d7c7f2c0aa5d6b02618635b0e4454cb/pr-6773

Backported as #6797

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

patchback bot pushed a commit that referenced this pull request Jun 26, 2023
* Change proxmox_kvm restart to use new method

Previously, the `restarted` state used both stop and start vm functions to restart a vm.
This change introduces the a new function that utilizes the proxmox reboot endpoint instead for a more reliable method of restarting a vm.

* Create 6773-proxmox_kvm-restarted-state-bug-fix.yaml

* Fix typo

* Add link to PR

* Chanel log fragment formatting changes

* Move try/catch to `restart_vm` function

* Update changelogs/fragments/6773-proxmox_kvm-restarted-state-bug-fix.yaml

Co-authored-by: Felix Fontein <felix@fontein.de>

---------

Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit 3571df8)
@felixfontein
Copy link
Collaborator

@juan210012 thanks for your contribution!
@UnderGreen thanks for reviewing!

felixfontein pushed a commit that referenced this pull request Jun 27, 2023
…d` state bug fix (#6797)

Module `proxmox_kvm` `restarted` state bug fix (#6773)

* Change proxmox_kvm restart to use new method

Previously, the `restarted` state used both stop and start vm functions to restart a vm.
This change introduces the a new function that utilizes the proxmox reboot endpoint instead for a more reliable method of restarting a vm.

* Create 6773-proxmox_kvm-restarted-state-bug-fix.yaml

* Fix typo

* Add link to PR

* Chanel log fragment formatting changes

* Move try/catch to `restart_vm` function

* Update changelogs/fragments/6773-proxmox_kvm-restarted-state-bug-fix.yaml

Co-authored-by: Felix Fontein <felix@fontein.de>

---------

Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit 3571df8)

Co-authored-by: Juan Estupinan <65736594+juan210012@users.noreply.github.com>
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 module module new_contributor Help guide this first time contributor plugins plugin (any type)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants