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

Fixing cloning regression on DS cluster #2037

Conversation

vasilsatanasov
Copy link
Contributor

@vasilsatanasov vasilsatanasov commented Oct 12, 2023

Description

Issue is that when vm is cloned on DS cluster the datastore_id field in the relocate spec holds invalid value which causes the vCenter to throw an error. The fix was to restore previously implemented behaviour to not send relocate specs for the VM hard disks when it is cloned on DS Cluster with exception when datastore_id is explicitly specified for the Hard Disk.

Added TestAccResourceVSphereVirtualMachine_cloneOnDsCuster to cover the case.

Fixes #2034

Acceptance tests

  • Have you added an acceptance test for the functionality being added?
  • Have you run the acceptance tests on this branch?

Output from acceptance testing:

vasila@vasila2VDJN terraform-provider-vsphere %  make testacc TESTARGS='-run="TestAccResourceVSphereVirtualMachine_cloneOnDsCuster|TestAccResourceVSphereVirtualMachine_cloneWithDiskTypeChange"'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test $(go list ./... |grep -v 'vendor') -v -run="TestAccResourceVSphereVirtualMachine_cloneOnDsCuster|TestAccResourceVSphereVirtualMachine_cloneWithDiskTypeChange" -timeout 360m
?       github.com/hashicorp/terraform-provider-vsphere [no test files]
?       github.com/hashicorp/terraform-provider-vsphere/vsphere/internal/administrationroles    [no test files]
?       github.com/hashicorp/terraform-provider-vsphere/vsphere/internal/helper/computeresource [no test files]
?       github.com/hashicorp/terraform-provider-vsphere/vsphere/internal/helper/clustercomputeresource  [no test files]
?       github.com/hashicorp/terraform-provider-vsphere/vsphere/internal/helper/contentlibrary  [no test files]
?       github.com/hashicorp/terraform-provider-vsphere/vsphere/internal/helper/customattribute [no test files]
?       github.com/hashicorp/terraform-provider-vsphere/vsphere/internal/helper/datastore       [no test files]
?       github.com/hashicorp/terraform-provider-vsphere/vsphere/internal/helper/dvportgroup     [no test files]
?       github.com/hashicorp/terraform-provider-vsphere/vsphere/internal/helper/envbrowse       [no test files]
?       github.com/hashicorp/terraform-provider-vsphere/vsphere/internal/helper/folder  [no test files]
?       github.com/hashicorp/terraform-provider-vsphere/vsphere/internal/helper/datacenter      [no test files]
?       github.com/hashicorp/terraform-provider-vsphere/vsphere/internal/helper/hostsystem      [no test files]
?       github.com/hashicorp/terraform-provider-vsphere/vsphere/internal/helper/network [no test files]
?       github.com/hashicorp/terraform-provider-vsphere/vsphere/internal/helper/nsx     [no test files]
?       github.com/hashicorp/terraform-provider-vsphere/vsphere/internal/helper/provider        [no test files]
?       github.com/hashicorp/terraform-provider-vsphere/vsphere/internal/helper/ovfdeploy       [no test files]
?       github.com/hashicorp/terraform-provider-vsphere/vsphere/internal/helper/resourcepool    [no test files]
?       github.com/hashicorp/terraform-provider-vsphere/vsphere/internal/helper/spbm    [no test files]
?       github.com/hashicorp/terraform-provider-vsphere/vsphere/internal/helper/storagepod      [no test files]
?       github.com/hashicorp/terraform-provider-vsphere/vsphere/internal/helper/structure       [no test files]
?       github.com/hashicorp/terraform-provider-vsphere/vsphere/internal/helper/testhelper      [no test files]
?       github.com/hashicorp/terraform-provider-vsphere/vsphere/internal/helper/utils   [no test files]
?       github.com/hashicorp/terraform-provider-vsphere/vsphere/internal/helper/vappcontainer   [no test files]
?       github.com/hashicorp/terraform-provider-vsphere/vsphere/internal/helper/virtualmachine  [no test files]
?       github.com/hashicorp/terraform-provider-vsphere/vsphere/internal/helper/vsanclient      [no test files]
?       github.com/hashicorp/terraform-provider-vsphere/vsphere/internal/helper/vsansystem      [no test files]
?       github.com/hashicorp/terraform-provider-vsphere/vsphere/internal/vmworkflow     [no test files]
=== RUN   TestAccResourceVSphereVirtualMachine_cloneWithDiskTypeChange
--- PASS: TestAccResourceVSphereVirtualMachine_cloneWithDiskTypeChange (164.92s)
=== RUN   TestAccResourceVSphereVirtualMachine_cloneOnDsCuster
--- PASS: TestAccResourceVSphereVirtualMachine_cloneOnDsCuster (240.41s)
PASS
ok      github.com/hashicorp/terraform-provider-vsphere/vsphere 406.327s
testing: warning: no tests to run
PASS
ok      github.com/hashicorp/terraform-provider-vsphere/vsphere/internal/helper/viapi   (cached) [no tests to run]
testing: warning: no tests to run
PASS
ok      github.com/hashicorp/terraform-provider-vsphere/vsphere/internal/helper/virtualdisk     (cached) [no tests to run]
testing: warning: no tests to run
PASS
ok      github.com/hashicorp/terraform-provider-vsphere/vsphere/internal/virtualdevice  (cached) [no tests to run]

...

Release Note

Release note for CHANGELOG:

Fixing cloning regression on DS cluster. Restored previously implemented behaviour to not send relocate specs for the VM hard disks when it is cloned on DS Cluster with exception when datastore_id is explicitly specified for the Hard Disk.

References

#2034

@vasilsatanasov vasilsatanasov requested a review from a team as a code owner October 12, 2023 15:16
@github-actions github-actions bot added provider Type: Provider size/m Relative Sizing: Medium labels Oct 12, 2023
Copy link
Collaborator

@tenthirtyam tenthirtyam left a comment

Choose a reason for hiding this comment

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

LGTM!

Issue is that when vm is cloned on DS cluster the datastore_id field in  the
relocate spec holds invalid value which causes the vCenter to throw an
error. The fix was to restore previously implemented behavior to not
send relocate specs for the VM hard disks when it is cloned on DS
Cluster with exception when datastore_id is explicitly specified for the
Hard Disk.

Added TestAccResourceVSphereVirtualMachine_cloneOnDsCuster to cover the
case.

Fixes hashicorp#2034

Signed-off-by: Vasil Atanasov <vasila@vmware.com>
@vasilsatanasov vasilsatanasov force-pushed the topic/vasilsatanasov/fix-issue-2034 branch from 4dc8f18 to e208779 Compare October 12, 2023 16:08
@vasilsatanasov
Copy link
Contributor Author

Removed disk with separate DS from the e2e , currently conflicting with datastore_cluster_id

"datastore_id": {
			Type:          schema.TypeString,
			Optional:      true,
			Computed:      true,
			ConflictsWith: []string{"datastore_cluster_id"},
			Description:   "The datastore ID for this virtual disk, if different than the virtual machine.",
		},

This is not exactly correct behaviour, since the UI supports cloning a VM with 1 disk on the DS cluster and another on a separate DS

@iBrandyJackson iBrandyJackson merged commit 326c8eb into hashicorp:main Oct 12, 2023
5 checks passed
@tenthirtyam tenthirtyam added this to the v2.5.1 milestone Oct 12, 2023
@github-actions
Copy link

This functionality has been released in v2.5.1 of the Terraform Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

Copy link

I'm going to lock this pull request 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 related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
provider Type: Provider size/m Relative Sizing: Medium
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error when using vsphere_datastore_cluster on 2.5.0
3 participants