@@ -1004,7 +1004,7 @@ func (c *Cloud) GetZoneByProviderID(ctx context.Context, providerID string) (clo
10041004 }
10051005
10061006 instance , err := c .getInstanceByID (ctx , string (instanceID ))
1007- if err != nil {
1007+ if err != nil || instance == nil {
10081008 return cloudprovider.Zone {}, err
10091009 }
10101010 return c .getInstanceZone (instance ), nil
@@ -1078,7 +1078,7 @@ func (c *Cloud) buildSelfAWSInstance(ctx context.Context) (*awsInstance, error)
10781078 defer instanceIDMetadata .Content .Close ()
10791079
10801080 instance , err := c .getInstanceByID (ctx , string (instanceIDBytes ))
1081- if err != nil {
1081+ if err != nil || instance == nil {
10821082 return nil , fmt .Errorf ("error finding instance %s: %q" , string (instanceIDBytes ), err )
10831083 }
10841084 return newAWSInstance (c .ec2 , instance ), nil
@@ -3146,7 +3146,7 @@ func (c *Cloud) UpdateLoadBalancer(ctx context.Context, clusterName string, serv
31463146// Returns the instance with the specified ID
31473147func (c * Cloud ) getInstanceByID (ctx context.Context , instanceID string ) (* ec2types.Instance , error ) {
31483148 instances , err := c .getInstancesByIDs (ctx , []string {instanceID })
3149- if err != nil {
3149+ if err != nil || instances == nil {
31503150 return nil , err
31513151 }
31523152
@@ -3347,13 +3347,6 @@ func (c *Cloud) getFullInstance(ctx context.Context, nodeName types.NodeName) (*
33473347 return awsInstance , instance , err
33483348}
33493349
3350- // extract private ip address from node name
3351- func nodeNameToIPAddress (nodeName string ) string {
3352- nodeName = strings .TrimPrefix (nodeName , privateDNSNamePrefix )
3353- nodeName = strings .Split (nodeName , "." )[0 ]
3354- return strings .ReplaceAll (nodeName , "-" , "." )
3355- }
3356-
33573350func (c * Cloud ) nodeNameToInstanceID (nodeName types.NodeName ) (InstanceID , error ) {
33583351 if strings .HasPrefix (string (nodeName ), rbnNamePrefix ) {
33593352 // depending on if you use a RHEL (e.g. AL2) or Debian (e.g. standard Ubuntu) based distribution, the
0 commit comments