mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
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:
commit
cd3494193a
@ -1588,6 +1588,10 @@ func (c *Cloud) InstanceExistsByProviderID(ctx context.Context, providerID strin
|
|||||||
|
|
||||||
instances, err := c.ec2.DescribeInstances(request)
|
instances, err := c.ec2.DescribeInstances(request)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
// if err is InstanceNotFound, return false with no error
|
||||||
|
if isAWSErrorInstanceNotFound(err) {
|
||||||
|
return false, nil
|
||||||
|
}
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
if len(instances) == 0 {
|
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
|
// 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)
|
// This should be stored as a single letter (i.e. c, not sdc or /dev/sdc)
|
||||||
type mountDevice string
|
type mountDevice string
|
||||||
|
Loading…
Reference in New Issue
Block a user