crossplane-contrib / provider-alibaba

Crossplane provider for Alibaba Cloud
Apache License 2.0
50 stars 18 forks source link

fix: handle sdk ServerError InvalidDBInstanceId.NotFound when instance not present. #46

Closed yunlzheng closed 4 years ago

yunlzheng commented 4 years ago

fix: handle sdk ServerError InvalidDBInstanceId.NotFound when instance not present.

Description of your changes

When DB Instance is not present in RDS the DescribeDBInstances api will throw ServerError with errorMessage InvalidDBInstanceId.NotFound. This will broke the Observe() and Delete() Logic. The Change as follow will check the error type and content, make sure thow the right type of error.

func errorConvert(err error) error {
    if e, ok := err.(*sdkErrors.ServerError); ok && e.ErrorCode() == ErrCodeInstanceNotFound {
        return ErrDBInstanceNotFound
    }
    return err
}

Fixes #

I have:

How has this code been tested

TAB