Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: missing required providerID on external nodes #172

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions scaleway/servers.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,8 @@ func (s *servers) InstanceShutdown(ctx context.Context, node *v1.Node) (bool, er
// translated into specific fields in the Node object on registration.
// Use the node.name or node.spec.providerID field to find the node in the cloud provider.
func (s *servers) InstanceMetadata(ctx context.Context, node *v1.Node) (*cloudprovider.InstanceMetadata, error) {
providerID := node.Spec.ProviderID

if address, ok := node.Labels[nodeLabelNodePublicIP]; ok {
addresses := []v1.NodeAddress{
{Type: v1.NodeExternalIP, Address: address},
Expand All @@ -222,17 +224,22 @@ func (s *servers) InstanceMetadata(ctx context.Context, node *v1.Node) (*cloudpr
}
}

if providerID == "" {
providerID = fmt.Sprintf("scaleway://external/%s", node.GetUID())
}

return &cloudprovider.InstanceMetadata{
ProviderID: providerID,
NodeAddresses: addresses,
}, nil
}

if node.Spec.ProviderID == "" {
if providerID == "" {
metadata, err := s.instances.InstanceMetadata(ctx, node)
if err == cloudprovider.InstanceNotFound {
return s.baremetal.InstanceMetadata(ctx, node)
}
return metadata, err
}
return s.getImplementationByProviderID(node.Spec.ProviderID).InstanceMetadata(ctx, node)
return s.getImplementationByProviderID(providerID).InstanceMetadata(ctx, node)
}
Loading