Skip to content

Commit

Permalink
fix: missing required providerID on external nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
Nox-404 committed Sep 9, 2024
1 parent 43e1f57 commit 0aad4ec
Showing 1 changed file with 9 additions and 2 deletions.
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)
}

0 comments on commit 0aad4ec

Please sign in to comment.