You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
vsphere_tag_category.project: could not locate category with id "urn:vmomi:InventoryServiceCategory:5c1b281a-0850-4a14-a417-38620f8878ad:GLOBAL": Status code: 404, error: call failed: Error response from vCloud Suite API: {"type":"com.vmware.vapi.std.errors.not_found","value":{"messages":[]}}
Expected Behavior
Provider should mark resource as missing and plan to create it
Actual Behavior
Reading resource from provider fails
Steps to Reproduce
Create tag or tag_category using terraform apply
Delete tag or tag_category in vCenter
Run terraform plan
Suggested patch
diff --git a/vsphere/resource_vsphere_tag.go b/vsphere/resource_vsphere_tag.go
index 6765234..0d5a35a 100644
--- a/vsphere/resource_vsphere_tag.go
+++ b/vsphere/resource_vsphere_tag.go
@@ -5,6 +5,8 @@ import (
"encoding/json"
"errors"
"fmt"
+ "log"
+ "strings"
"github.com/hashicorp/terraform/helper/schema"
"github.com/vmware/vic/pkg/vsphere/tags"
@@ -79,6 +81,11 @@ func resourceVSphereTagRead(d *schema.ResourceData, meta interface{}) error {
defer cancel()
tag, err := client.GetTag(ctx, id)
if err != nil {
+ if strings.Contains(err.Error(), "com.vmware.vapi.std.errors.not_found") {
+ log.Printf("[WARN] Tag with id %q is missing. Need to recreate it", id)
+ d.SetId("")
+ return nil
+ }
return fmt.Errorf("could not locate tag with id %q: %s", id, err)
}
d.Set("name", tag.Name)
diff --git a/vsphere/resource_vsphere_tag_category.go b/vsphere/resource_vsphere_tag_category.go
index 69703cb..8d0a664 100644
--- a/vsphere/resource_vsphere_tag_category.go
+++ b/vsphere/resource_vsphere_tag_category.go
@@ -4,6 +4,8 @@ import (
"context"
"errors"
"fmt"
+ "log"
+ "strings"
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/helper/validation"
@@ -104,6 +106,11 @@ func resourceVSphereTagCategoryRead(d *schema.ResourceData, meta interface{}) er
defer cancel()
category, err := client.GetCategory(ctx, id)
if err != nil {
+ if strings.Contains(err.Error(), "com.vmware.vapi.std.errors.not_found") {
+ log.Printf("[WARN] Tag category with id %q is missing. Need to recreate it", id)
+ d.SetId("")
+ return nil
+ }
return fmt.Errorf("could not locate category with id %q: %s", id, err)
}
d.Set("name", category.Name)
The text was updated successfully, but these errors were encountered:
When previously created tags and tag categories are missing in vCenter, provider doesn't remove them from state.
Terraform Version
Terraform v0.11.7
vSphere Provider Version
1.8.1
Affected Resource(s)
Please list the resources as a list, for example:
vsphere_tag
vsphere_tag_category
Terraform Configuration Files
Debug Output
Expected Behavior
Provider should mark resource as missing and plan to create it
Actual Behavior
Reading resource from provider fails
Steps to Reproduce
terraform apply
terraform plan
Suggested patch
The text was updated successfully, but these errors were encountered: