Commit 3988331c authored by Justin Santa Barbara's avatar Justin Santa Barbara

Restore InstanceNotFound comment & logic

Otherwise node registration is broken on AWS.
parent d057795f
...@@ -131,6 +131,7 @@ type Instances interface { ...@@ -131,6 +131,7 @@ type Instances interface {
// services cannot be used in this method to obtain nodeaddresses // services cannot be used in this method to obtain nodeaddresses
NodeAddressesByProviderID(ctx context.Context, providerID string) ([]v1.NodeAddress, error) NodeAddressesByProviderID(ctx context.Context, providerID string) ([]v1.NodeAddress, error)
// InstanceID returns the cloud provider ID of the node with the specified NodeName. // InstanceID returns the cloud provider ID of the node with the specified NodeName.
// Note that if the instance does not exist or is no longer running, we must return ("", cloudprovider.InstanceNotFound)
InstanceID(ctx context.Context, nodeName types.NodeName) (string, error) InstanceID(ctx context.Context, nodeName types.NodeName) (string, error)
// InstanceType returns the type of the specified instance. // InstanceType returns the type of the specified instance.
InstanceType(ctx context.Context, name types.NodeName) (string, error) InstanceType(ctx context.Context, name types.NodeName) (string, error)
......
...@@ -1363,6 +1363,10 @@ func (c *Cloud) InstanceID(ctx context.Context, nodeName types.NodeName) (string ...@@ -1363,6 +1363,10 @@ func (c *Cloud) InstanceID(ctx context.Context, nodeName types.NodeName) (string
} }
inst, err := c.getInstanceByNodeName(nodeName) inst, err := c.getInstanceByNodeName(nodeName)
if err != nil { if err != nil {
if err == cloudprovider.InstanceNotFound {
// The Instances interface requires that we return InstanceNotFound (without wrapping)
return "", err
}
return "", fmt.Errorf("getInstanceByNodeName failed for %q with %q", nodeName, err) return "", fmt.Errorf("getInstanceByNodeName failed for %q with %q", nodeName, err)
} }
return "/" + aws.StringValue(inst.Placement.AvailabilityZone) + "/" + aws.StringValue(inst.InstanceId), nil return "/" + aws.StringValue(inst.Placement.AvailabilityZone) + "/" + aws.StringValue(inst.InstanceId), nil
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment