From d41cef9d361cdad2659cfa34668c6c1147a6a925 Mon Sep 17 00:00:00 2001 From: ShiChangkuo Date: Fri, 29 May 2020 15:42:14 +0800 Subject: [PATCH] ignore error when fetching tags failed in ReadFunc --- .../resource_huaweicloud_vpc_subnet_v1.go | 16 ++++++++++------ huaweicloud/resource_huaweicloud_vpc_v1.go | 16 ++++++++++------ 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/huaweicloud/resource_huaweicloud_vpc_subnet_v1.go b/huaweicloud/resource_huaweicloud_vpc_subnet_v1.go index 9db21d62cb..37f772820b 100644 --- a/huaweicloud/resource_huaweicloud_vpc_subnet_v1.go +++ b/huaweicloud/resource_huaweicloud_vpc_subnet_v1.go @@ -208,12 +208,16 @@ func resourceVpcSubnetV1Read(d *schema.ResourceData, meta interface{}) error { } resourceTags, err := tags.Get(vpcSubnetV2Client, "subnets", d.Id()).Extract() if err != nil { - return fmt.Errorf("Error fetching HuaweiCloud VpcSubnet tags: %s", err) - } - - tagmap := tagsToMap(resourceTags.Tags) - if err := d.Set("tags", tagmap); err != nil { - return fmt.Errorf("Error saving tags for HuaweiCloud VpcSubnet (%s): %s", d.Id(), err) + if err404, ok := err.(golangsdk.ErrDefault404); ok { + log.Printf("[INFO] fetching Subnet tags failed: %s", err404) + } else { + return fmt.Errorf("Error fetching HuaweiCloud Subnet %s tags: %s", d.Id(), err) + } + } else { + tagmap := tagsToMap(resourceTags.Tags) + if err := d.Set("tags", tagmap); err != nil { + return fmt.Errorf("Error saving HuaweiCloud Subnet %s tags: %s", d.Id(), err) + } } return nil diff --git a/huaweicloud/resource_huaweicloud_vpc_v1.go b/huaweicloud/resource_huaweicloud_vpc_v1.go index 445241452e..04c5a1eb84 100644 --- a/huaweicloud/resource_huaweicloud_vpc_v1.go +++ b/huaweicloud/resource_huaweicloud_vpc_v1.go @@ -144,12 +144,16 @@ func resourceVirtualPrivateCloudV1Read(d *schema.ResourceData, meta interface{}) } resourceTags, err := tags.Get(vpcV2Client, "vpcs", d.Id()).Extract() if err != nil { - return fmt.Errorf("Error fetching HuaweiCloud VirtualPrivateCloud tags: %s", err) - } - - tagmap := tagsToMap(resourceTags.Tags) - if err := d.Set("tags", tagmap); err != nil { - return fmt.Errorf("Error saving tags for HuaweiCloud VirtualPrivateCloud (%s): %s", d.Id(), err) + if err404, ok := err.(golangsdk.ErrDefault404); ok { + log.Printf("[INFO] fetching VPC tags failed: %s", err404) + } else { + return fmt.Errorf("Error fetching HuaweiCloud VPC %s tags: %s", d.Id(), err) + } + } else { + tagmap := tagsToMap(resourceTags.Tags) + if err := d.Set("tags", tagmap); err != nil { + return fmt.Errorf("Error saving HuaweiCloud VPC %s tags: %s", d.Id(), err) + } } return nil