-
Notifications
You must be signed in to change notification settings - Fork 53
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
Allow to recreate VMs if in DONE state #563
Conversation
Will update changelog and docs if this gets approved |
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.
It's not a final review but a bunch of considerations to open a discussion and dig a bit more
|
||
// waitForVMState waits until the VM with vmId has the desiredState. | ||
// returns an error if timeout is reached. | ||
func waitForVMState(vmId int, desiredState vm.State, timeout time.Duration) error { |
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.
VM already has some VM state checking methods, should we share/reuse some code or should we consider that it's ok to have separated test code ?
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.
Ah, I probably missed that, if there is something to be reuse, to wait for the state then we definitely should use it, can you point me towards it?
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.
Maybe a bit complex, but there's some existing code here:
https://github.com/OpenNebula/terraform-provider-opennebula/blob/master/opennebula/helpers_vm_state.go#L138
d.Set("gname", vmInfo.GName) | ||
d.Set("state", vmInfo.StateRaw) | ||
d.Set("lcmstate", vmInfo.LCMStateRaw) | ||
if vm.State(vmInfo.StateRaw) == vm.Done { |
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.
Is it the proper way to do ?
There's a -replace
option to terraform
And if we consider it's ok, do we want this behavior everytime, for everyone or should it be conditioned by an other attribute with a name ?
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.
As far as I know, unsetting the "ID" parameter is the way to tell terraform that the previously existing resource no longer exists (see an example on AWS's provider here.
A VM in done
state can be considered as non-existing anymore. As it is expected that terraform recreates the resource when they do not exist anymore, this behaviour should be default.
An example for that expectation is drift checks, if you create a VM, someone deletes it from the UI, the expectation is that terraform will tell you there is a drift.
The thing to consider is the non-backward compatible behaviour this brings to the vm resource, this might be worth of a major version release.
Maybe this could be behind a recreate_on_delete
boolean on the resource on an initial minor update, with a deprecation notice for the next major update.
This also affects the vrouter
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.
@frousselet what do you think on this ?
Should we consider this behavior to be protected by a recreate_on_delete
attribute ?
This pull request is stale because it has been open for 30 days with no activity and it is not in a milestone. Remove 'status: stale' label or comment, or this will be closed in 5 days. |
nope, not stale... |
@Thiryn your work on this is much appreciated. Since it's a bug fix, we don't anticipate it breaking backwards compatibility. We'll go ahead and proceed with the merge |
Community Note
Description
Detect
done
state for VMs and reconcile them via recreation.Also renames
vm
variable intovmInfo
to prevent collision with thegithub.com/OpenNebula/one/src/oca/go/src/goca/schemas/vm
package import.References
Fixes #562
New or Affected Resource(s)
opennebula_virtual_router_instance
opennebula_virtual_machine
Checklist
References
go fmt
)