File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed
staging/src/k8s.io/legacy-cloud-providers/aws Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -1588,6 +1588,10 @@ func (c *Cloud) InstanceExistsByProviderID(ctx context.Context, providerID strin
1588
1588
1589
1589
instances , err := c .ec2 .DescribeInstances (request )
1590
1590
if err != nil {
1591
+ // if err is InstanceNotFound, return false with no error
1592
+ if isAWSErrorInstanceNotFound (err ) {
1593
+ return false , nil
1594
+ }
1591
1595
return false , err
1592
1596
}
1593
1597
if len (instances ) == 0 {
@@ -1803,6 +1807,20 @@ func (c *Cloud) GetZoneByNodeName(ctx context.Context, nodeName types.NodeName)
1803
1807
1804
1808
}
1805
1809
1810
+ func isAWSErrorInstanceNotFound (err error ) bool {
1811
+ if err == nil {
1812
+ return false
1813
+ }
1814
+
1815
+ if awsError , ok := err .(awserr.Error ); ok {
1816
+ if awsError .Code () == ec2 .UnsuccessfulInstanceCreditSpecificationErrorCodeInvalidInstanceIdNotFound {
1817
+ return true
1818
+ }
1819
+ }
1820
+
1821
+ return false
1822
+ }
1823
+
1806
1824
// Used to represent a mount device for attaching an EBS volume
1807
1825
// This should be stored as a single letter (i.e. c, not sdc or /dev/sdc)
1808
1826
type mountDevice string
You can’t perform that action at this time.
0 commit comments