Skip to content

Commit

Permalink
Fix dns record not found when applying resource st-alicloud_alidns_re…
Browse files Browse the repository at this point in the history
…cord_weight. (#9)

* Remove resource if not found in Read().

* Code cleanup.
  • Loading branch information
styumyum authored May 10, 2023
1 parent 6fe327c commit dd43ab0
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions alicloud/resource_alidns_record_weight.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@ func (r *aliDnsRecordWeightResource) Read(ctx context.Context, req resource.Read
if isAbleToRetry(*_t.Code) {
return err
} else {
if *_t.Code == "InvalidRR.NoExist" {
return backoff.Permanent(fmt.Errorf("domain record not found"))
}
return backoff.Permanent(err)
}
} else {
Expand Down Expand Up @@ -208,10 +211,14 @@ func (r *aliDnsRecordWeightResource) Read(ctx context.Context, req resource.Read

err := backoff.Retry(readRecordWeight, reconnectBackoff)
if err != nil {
resp.Diagnostics.AddError(
"[API ERROR] Failed to Read DNS Record Weight",
err.Error(),
)
if err.Error() == "domain record not found" {
resp.State.RemoveResource(ctx)
} else {
resp.Diagnostics.AddError(
"[API ERROR] Failed to Read DNS Record Weight",
err.Error(),
)
}
return
}

Expand Down

0 comments on commit dd43ab0

Please sign in to comment.