-
Notifications
You must be signed in to change notification settings - Fork 9.5k
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
provider/vsphere: added update function with support for vcpu and memory #6356
Conversation
This LGTM but I would rather one of the VMWare specific people took a look as well |
@thetuxkeeper looks good, but can we have a unit test ;) Let me know if you are not familiar with the unit testing framework. @stack72 / @phinze / @jen20 does this project have a write up on how to write unit / integrations tests? Also please update the provider docs that update capabilities are in the earily stages ... Here is how you do it. If you have any questions holler! And again thanks for the work!!!!! |
@chrislovecnm i'm not familiar with unit/integration tests. Additionally my PRs are the only thing I did with go, so I'd need some support here (I know only the basic language features). |
There is a section of the CONTRIBUTING doc that has this - https://github.com/hashicorp/terraform/blob/master/.github/CONTRIBUTING.md#writing-acceptance-tests P. |
@thetuxkeeper look at the integration tests that have been written https://github.com/hashicorp/terraform/blob/master/builtin/providers/vsphere/resource_vsphere_virtual_machine_test.go Please ask questions if yah got them!! |
Hi @thetuxkeeper , looks like were forcing a reboot here. Not all updates would require that, so my comment is regarding future-proofing the resourceVSphereVirtualMachineUpdate function. Whether that work is done in this initial update patch or subsequent patches that need conditional reboot is debatable. |
for !toolsRunning { | ||
time.Sleep(1000 * time.Millisecond) | ||
toolsRunning, err = vm.IsToolsRunning(context.TODO()) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we wait for vm tools? Is this redundant with the WaitForIP() call?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dkalleg good catch. @thetuxkeeper what exactly are we doing here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's a left over and I forgot to review it in detail. It should be redundant with WaitForIP(), since the vsphere clients won't show IPs without running tools either.
I'll remove it.
@chrislovecnm and @stack72 thanks for the links. I'll try to get as far as I can and come back if I need help with the tests |
Now with tests for changing memory and vcpu. Is this the right way? |
var locationOpt string | ||
var datastoreOpt string | ||
|
||
if v := os.Getenv("VSPHERE_DATACENTER"); v != "" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If these are the standard env vars that are required to run the resources outside of the tests, then they are not needed here - they are taken care of in provider_test.go
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
provider_test.go only checks for VSPHERE_USER, VSPHERE_PASSWORD and VSPHERE_SERVER, but not VSPHERE_DATACENTER.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how would datacenter usually be sent to the VM? Would it be created and then passed as a resource?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how would datacenter usually be sent to the VM? Would it be created and then passed as a resource?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With a vSphere server you can maintain multiple vSphere data centers. Below the data centers you usually have clusters containing physical hosts and resource pools. So you have to specify the data center at creation time of the VM since it's part of the location of the VM. Using (offline?) Vmotion you can move the VM from one data center to another.
the tests look ok - did you manage to run them? can you paste the output of the tests? something like:
would be able to run them Paul |
Output of TestAccVSphereVirtualMachine_updateMemory:
Output of TestAccVSphereVirtualMachine_updateVcpu:
|
I added the the reboot flag to be able to skip the reboot, but I haven't found a parameter that's easy implement. I'll rebase it to current master (memory reservation commit is blocking the clean merge) when the open questions/issues are resolved. |
|
||
if d.HasChange("memory") { | ||
configSpec.MemoryMB = int64(d.Get("memory").(int)) | ||
hasChanges = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to set rebootRequired = true
here and for vcpu.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! It's fixed.
Missed that when Iwas splitting the patch (relocation branch an this one).
@thetuxkeeper can you resolve the conflicts? Once that is done, ping me at @markpeek and we will do a final code review |
@chrislovecnm, @markpeek: I rebased it to the master and the conflicts are gone (perhaps a cached status since the rebase had none). Should I squash it to a single commit? |
@thetuxkeeper a squash would be great, then we should get this merged!! First part of update support 😄 |
Thanks for all the work here :) I will squash as part of the merge |
@stack72 thanks Paul ... |
…ory (hashicorp#6356) * added update function with support for vcpu and memory * waiting for vmware tools redundant with WaitForIP * proper error handling of PowerOn task * added test cases for update memory and vcpu * reboot flag
…ory (hashicorp#6356) * added update function with support for vcpu and memory * waiting for vmware tools redundant with WaitForIP * proper error handling of PowerOn task * added test cases for update memory and vcpu * reboot flag
…ory (hashicorp#6356) * added update function with support for vcpu and memory * waiting for vmware tools redundant with WaitForIP * proper error handling of PowerOn task * added test cases for update memory and vcpu * reboot flag
…ory (hashicorp#6356) * added update function with support for vcpu and memory * waiting for vmware tools redundant with WaitForIP * proper error handling of PowerOn task * added test cases for update memory and vcpu * reboot flag
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
Since not all VMs should be rebuild from scratch if we want to change memory or vcpus (cluster masters, ...), I added an update function supporting these two settings to change with a reboot.