Merge pull request #87839 from leakingtapan/cloud-provider

Fix aws provider to return no error when instance is not found for InstanceExistsByProviderID
This commit is contained in:
Kubernetes Prow Robot 2020-02-21 12:12:11 -08:00 committed by GitHub
commit cd3494193a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1588,6 +1588,10 @@ func (c *Cloud) InstanceExistsByProviderID(ctx context.Context, providerID strin
instances, err := c.ec2.DescribeInstances(request)
if err != nil {
// if err is InstanceNotFound, return false with no error
if isAWSErrorInstanceNotFound(err) {
return false, nil
}
return false, err
}
if len(instances) == 0 {
@ -1803,6 +1807,20 @@ func (c *Cloud) GetZoneByNodeName(ctx context.Context, nodeName types.NodeName)
}
func isAWSErrorInstanceNotFound(err error) bool {
if err == nil {
return false
}
if awsError, ok := err.(awserr.Error); ok {
if awsError.Code() == ec2.UnsuccessfulInstanceCreditSpecificationErrorCodeInvalidInstanceIdNotFound {
return true
}
}
return false
}
// Used to represent a mount device for attaching an EBS volume
// This should be stored as a single letter (i.e. c, not sdc or /dev/sdc)
type mountDevice string