diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index c03cae416..9edbcfac2 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -10,7 +10,7 @@ jobs: issues: write pull-requests: write steps: - - uses: actions/stale@v7 + - uses: actions/stale@v8 with: repo-token: '${{ secrets.GITHUB_TOKEN }}' days-before-stale: 180 diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f76ccdb3..4c030e770 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ ## 2.4.0 (Unreleased) +BUG FIXES: +* `r/vsphere_nas_datastore`: Fix issue mounting and/or unmounting NFS datastores when updating `host_system_ids` as a day-two operation. ([#1860](https://github.com/terraform-providers/terraform-provider-vsphere/pull/1860)) +* `r/vsphere_vm_storage_policy`: Updates the `resourceVMStoragePolicyDelete` method to check the response of `pbmClient.DeleteProfile()` API for errors. If a storage policy is in use and cannot be deleted, the destroy operation will fail and the storage policy will remain in the state. ([#1863](https://github.com/terraform-providers/terraform-provider-vsphere/pull/1863)) + CHORES: * Refactor acctests setup ([#1847](https://github.com/terraform-providers/terraform-provider-vsphere/pull/1847)) * Update to terraform-plugin-sdk v2.25.0 ([#1847](https://github.com/terraform-providers/terraform-provider-vsphere/pull/1847)) diff --git a/vsphere/nas_datastore_helper.go b/vsphere/nas_datastore_helper.go index 6bde59c8b..0b6d6a38d 100644 --- a/vsphere/nas_datastore_helper.go +++ b/vsphere/nas_datastore_helper.go @@ -50,12 +50,13 @@ func (p *nasDatastoreMountProcessor) diffNewOld() []string { // diff is what diffOldNew and diffNewOld hand off to. func (p *nasDatastoreMountProcessor) diff(a, b []string) []string { - var found bool c := make([]string, 0) for _, v1 := range a { + found := false for _, v2 := range b { if v1 == v2 { found = true + break } } if !found { diff --git a/vsphere/resource_vsphere_vm_storage_policy.go b/vsphere/resource_vsphere_vm_storage_policy.go index d6a25263a..25d8f9625 100644 --- a/vsphere/resource_vsphere_vm_storage_policy.go +++ b/vsphere/resource_vsphere_vm_storage_policy.go @@ -275,7 +275,7 @@ func resourceVMStoragePolicyUpdate(d *schema.ResourceData, meta interface{}) err } func resourceVMStoragePolicyDelete(d *schema.ResourceData, meta interface{}) error { - log.Printf("[DEBUG] Performing create of VM storage policy with ID %s", d.Id()) + log.Printf("[DEBUG] Performing delete of VM storage policy with ID %s", d.Id()) client := meta.(*Client).vimClient pbmClient, err := pbm.NewClient(context.Background(), client.Client) if err != nil { @@ -286,10 +286,15 @@ func resourceVMStoragePolicyDelete(d *schema.ResourceData, meta interface{}) err UniqueId: d.Id(), }) - _, err = pbmClient.DeleteProfile(context.Background(), policyIdsToDelete) + var deleteProfileOutcome []types2.PbmProfileOperationOutcome + deleteProfileOutcome, err = pbmClient.DeleteProfile(context.Background(), policyIdsToDelete) if err != nil { return fmt.Errorf("error while deleting policy with ID %s %s", d.Id(), err) } + if len(deleteProfileOutcome) > 0 && deleteProfileOutcome[0].Fault != nil { + return fmt.Errorf("error while deleting policy with ID %s %s", + d.Id(), deleteProfileOutcome[0].Fault.LocalizedMessage) + } d.SetId("") log.Printf("[DEBUG] %s: Delete complete", d.Id()) return nil