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

govc: Handle powered-on VMs in vm.destroy #2532

Merged
merged 1 commit into from
Aug 26, 2021
Merged

Conversation

embano1
Copy link
Contributor

@embano1 embano1 commented Aug 2, 2021

Description

govc vm.destroy might throw error in vCenter UI/task log if the vm to be destroyed is already powered off. This non-breaking change checks the power state of a VM, and if it is powered on a power off attempt will be performed.

Closes: #2529
Signed-off-by: Michael Gasch mgasch@vmware.com

Type of change

Please mark options that are relevant:

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to
    not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide
instructions so we can reproduce. If applicable, please also list any relevant
details for your test configuration.

  • Added govc bats test

Test Configuration:

  • Toolchain:
  • SDK:
  • (add more if needed)

Checklist:

  • My code follows the CONTRIBUTION guidelines of
    this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged

Copy link
Member

@dougm dougm left a comment

Choose a reason for hiding this comment

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

Thanks @embano1 . We could check the power state of the VM(s) and only power off those that are poweredOn.
If we want the flag option, can we name it -off (same as vm.power's flag) and default to true?

@embano1
Copy link
Contributor Author

embano1 commented Aug 6, 2021

Thx Doug, sounds like a reasonable change to me.

@Petrapana
Copy link

Hello,
Will it be possible to merge this change?

@embano1
Copy link
Contributor Author

embano1 commented Aug 26, 2021

@Petrapana just back from PTO and hope to finish this by EOW

Closes: vmware#2529
Signed-off-by: Michael Gasch <mgasch@vmware.com>
@embano1 embano1 changed the title govc: Add option to skip power off in vm.destroy govc: Handle powered-on VMs in vm.destroy Aug 26, 2021
@embano1
Copy link
Contributor Author

embano1 commented Aug 26, 2021

@dougm made changes as per your comment, no additional flag needed.

@embano1 embano1 requested a review from dougm August 26, 2021 14:47
Copy link
Member

@dougm dougm 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 @embano1

@embano1 embano1 merged commit 5a06d85 into vmware:master Aug 26, 2021
@embano1 embano1 deleted the issue-2529 branch August 27, 2021 09:36
dougm added a commit to dougm/govmomi that referenced this pull request Dec 7, 2021
With PR vmware#2532 , vm.destroy was returning after the 1st VM was destroyed.
yuyin002 pushed a commit to yuyin002/govmomi that referenced this pull request Jan 12, 2022
With PR vmware#2532 , vm.destroy was returning after the 1st VM was destroyed.
pradeep288 pushed a commit to pradeep288/govmomi that referenced this pull request Jan 17, 2022
With PR vmware#2532 , vm.destroy was returning after the 1st VM was destroyed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Govc generates error for vm.destroy if vm already Powered off
4 participants