Skip to content

Commit 884384b

Browse files
tongyimingmikatong
andauthored
fix: pg read npe (#1201)
Co-authored-by: mikatong <mikatong@tencent.com>
1 parent 9465e76 commit 884384b

File tree

2 files changed

+4
-12
lines changed

2 files changed

+4
-12
lines changed

tencentcloud/resource_tc_postgresql_instance.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,12 +1015,12 @@ func resourceTencentCloudPostgresqlInstanceRead(d *schema.ResourceData, meta int
10151015
instance, has, inErr = postgresqlService.DescribePostgresqlInstanceById(ctx, d.Id())
10161016
if inErr != nil {
10171017
ee, ok := inErr.(*sdkErrors.TencentCloudSDKError)
1018-
if ok && ee.GetCode() == "ResourceNotFound.InstanceNotFoundError" {
1018+
if ok && (ee.GetCode() == "ResourceNotFound.InstanceNotFoundError" || ee.GetCode() == "InvalidParameter") {
10191019
return nil
10201020
}
10211021
return retryError(inErr)
10221022
}
1023-
if IsContains(POSTGRESQL_RETRYABLE_STATUS, *instance.DBInstanceStatus) {
1023+
if instance != nil && IsContains(POSTGRESQL_RETRYABLE_STATUS, *instance.DBInstanceStatus) {
10241024
return resource.RetryableError(fmt.Errorf("instance %s is %s, retrying", *instance.DBInstanceId, *instance.DBInstanceStatus))
10251025
}
10261026
return nil

tencentcloud/service_tencentcloud_postgresql.go

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -360,18 +360,10 @@ func (me *PostgresqlService) DescribePostgresqlInstanceById(ctx context.Context,
360360
ratelimit.Check(request.GetAction())
361361
response, err := me.client.UsePostgresqlClient().DescribeDBInstanceAttribute(request)
362362
if err != nil {
363-
ee, ok := err.(*sdkErrors.TencentCloudSDKError)
364-
if !ok {
365-
errRet = err
366-
return
367-
}
368-
if ee.Code == "InvalidParameter" || ee.Code == "ResourceNotFound.InstanceNotFoundError" {
369-
errRet = nil
370-
} else {
371-
errRet = err
372-
}
363+
errRet = err
373364
return
374365
}
366+
375367
if response == nil || response.Response == nil {
376368
errRet = fmt.Errorf("TencentCloud SDK return nil response, %s", request.GetAction())
377369
return

0 commit comments

Comments
 (0)