-
-
Notifications
You must be signed in to change notification settings - Fork 139
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
feat(vm): add support for migration when the node name is modified #501
Conversation
* Added a `migrate` VM flag which changes the provider's behaviour when the VM's `node_name` is updated. If `true`, the VM will be migrated to the specified node instead of being re-created. * Added a `timeout_migrate` setting to control the timeout for VM migration. * Fixed a bug in the API's migration data structure that prevented the online migration flag to be set.
That lint failure (which also occurred on my workstation, but I wanted to be sure) doesn't have anything to do with the code I added, yet it doesn't happen in the main branch. Weirder yet, it doesn't look like the section of code it happens on has been touched recently. Not sure if I should fix it in this PR, since doing so kind of mixes concerns. On the other hand, well, the linter fails. Edit: applying the patch below would solve the problem: diff --git a/proxmoxtf/resource/vm.go b/proxmoxtf/resource/vm.go
index 6a2a71a..893f666 100644
--- a/proxmoxtf/resource/vm.go
+++ b/proxmoxtf/resource/vm.go
@@ -3908,7 +3908,6 @@ func vmReadCustom(
currentPCIList := d.Get(mkResourceVirtualEnvironmentVMHostPCI).([]interface{})
pciMap := map[string]interface{}{}
- var orderedPCIList []interface{}
pciDevices := getPCIInfo(vmConfig, d)
for pi, pp := range pciDevices {
@@ -3960,8 +3959,9 @@ func vmReadCustom(
}
sort.Strings(keyList)
- for _, k := range keyList {
- orderedPCIList = append(orderedPCIList, pciMap[k])
+ orderedPCIList := make([]interface{}, len(keyList))
+ for i, k := range keyList {
+ orderedPCIList[i] = pciMap[k]
}
if len(clone) > 0 { |
* This commit fixes a linter error that somehow doesn't manifest unless some other, unrelated changes trigger it (see bpg#501 and bpg#505). * In addition it fixes a similar issue that had so far gone undetected by the linter. * Refactored the code in question into a function, since it was mostly duplicated. * Simplified a pair of conditionals that had the same code in both branches.
fix: linter error in ambush * This commit fixes a linter error that somehow doesn't manifest unless some other, unrelated changes trigger it (see #501 and #505). * In addition it fixes a similar issue that had so far gone undetected by the linter. * Refactored the code in question into a function, since it was mostly duplicated. * Simplified a pair of conditionals that had the same code in both branches.
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.
This is a really useful feature, thanks for contributing @tseeker!
LGTM! 🚀
proxmoxtf/resource/vm.go
Outdated
@@ -1367,6 +1376,12 @@ func VM() *schema.Resource { | |||
Optional: true, | |||
Default: dvResourceVirtualEnvironmentVMTimeoutMoveDisk, | |||
}, | |||
mkResourceVirtualEnvironmentVMTimeoutMigrate: { | |||
Type: schema.TypeInt, | |||
Description: "MoveDisk timeout", |
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.
Looks like the descrition was not updated :)
Added a
migrate
VM flag which changes the provider's behaviour when the VM'snode_name
is updated. Iftrue
, the VM will be migrated to the specified node instead of being re-created.Added a
timeout_migrate
setting to control the timeout for VM migration.Fixed a bug in the API's migration data structure that prevented the online migration flag to be set.
Contributor's Note
Please mark the following items with an [x] if they apply to your PR.
Leave the [ ] if they are not applicable, or if you have not completed the item.
/docs
for any user-facing features or additions./examples
for any new or updated resources / data sources.make examples
to verify that the change works as expected.Community Note
Closes #499