Skip to content

Commit

Permalink
Merge branch 'hashicorp:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
zxinyu08 authored Mar 29, 2023
2 parents 407ed09 + 2afea98 commit 63547db
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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))
Expand Down
3 changes: 2 additions & 1 deletion vsphere/nas_datastore_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
9 changes: 7 additions & 2 deletions vsphere/resource_vsphere_vm_storage_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand Down

0 comments on commit 63547db

Please sign in to comment.