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

nutanix_virtual_machine resource won't allow setting power_state #98

Closed
mgrubb opened this issue Mar 10, 2020 · 8 comments
Closed

nutanix_virtual_machine resource won't allow setting power_state #98

mgrubb opened this issue Mar 10, 2020 · 8 comments
Assignees

Comments

@mgrubb
Copy link

mgrubb commented Mar 10, 2020

Describe the bug
When adding the power_state = "OFF" setting to a nutanix_virtual_machine resource, the error "Error: "power_state": this field cannot be set" is given when trying to apply.

Expected behavior
The expected behavior would be one of:
If power_state is present, force that power_state on the VM
If power_state is not present, when creating the VM set power_state to OFF, when not creating, leave the power_state at it's current value.

Logs
Here is the snippet from the trace log:
2020/03/10 14:38:15 [WARN] : eval: *terraform.EvalValidateResource, non-fatal err: "power_state": this field cannot be set
2020/03/10 14:38:15 [ERROR] : eval: *terraform.EvalSequence, err: "power_state": this field cannot be set

Versions (please complete the following information):

  • macOS 10.14.6
  • Terraform v0.12.21
  • Nutanix Cluster (Prism Element / AOS) 5.11.2.1 - Pro License
  • Nutanix Prism Central 5.11.2.1
  • Terraform provider version (using posted RC1? Compiling yourself? v1.0.2 (version downloaded from terraform init)

Additional context
Add any other context about the problem here.

@Sn0d3n
Copy link

Sn0d3n commented Mar 11, 2020

HI @mgrubb - This is an issue with Nutanix Terraform Provider and we have found a solution from our end. I'm in a discussion with the internal engineering team who deals with the provider. I shall update you as soon as we plan on how to release the fix.

@marinsalinas
Copy link
Contributor

marinsalinas commented Mar 17, 2020

Hello @mgrubb and @Sn0d3n, we used to support this value but when we get the Hashi review we had to remove it because of the immutable philosophy behind Terraform, once you create a resource you shouldn't be able to modify the running state, you can take a look to other providers, for example, AWS and there isn't an option to change the instance state even when you can stop/pause/run via API.

See: https://www.hashicorp.com/resources/what-is-mutable-vs-immutable-infrastructure

@marinsalinas
Copy link
Contributor

Here is a comment over vsphere provider from Hashicorp Engineer, please take a look: hashicorp/terraform-provider-vsphere#327 (comment)

@mgrubb
Copy link
Author

mgrubb commented Mar 23, 2020

Well, I'd still like to be able to set the state at time of creation, and then have it ignored later. I don't like that I am forced to have those resources be turned on by default.

@coderGo93
Copy link
Contributor

Hello @mgrubb , I was reading about that, could you tell me how is the user case for that to make it happen? I mean, when you want to have turned it off if you can't turn it on or something like that? to understand better

@mgrubb
Copy link
Author

mgrubb commented Apr 27, 2020

I'm not sure how much more detail you want.
Basically, at time of VM creation I would like to be able to set the power state explicitly.
So at creation time if I want the VM to remain powered off after it is created, I would like to be able to set that via the power_state attribute.
Conversely, if I want to have the VM power itself on once it is created then honor the power_state attribute accordingly.

I don't agree with the assertion that the terraform infrastructure should be immutable, things change all the time, like we need more memory or CPU, etc. Why should I have to destroy and recreate the VM for that change? But I guess I can live with that restriction, but it would still be nice to at least create the resources in a known given state, regardless if changing that attribute after creation has no effect.

@marinsalinas
Copy link
Contributor

We'll work regarding all the attributes (such as CPU, Memory, etc..) that need to hotplug and add it to the resource logic with this we won't need to manually turn off or turn on the VM.

Going to close this ticket until we get any update from Hashicorp to support manually start/stop.

@mritzmann
Copy link
Contributor

Not sure if I understood the discussion here correctly. Do I understand it correctly that power_state was removed? If so, this should also be removed from the documentation. Question because I have a similar problem in #172.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants