Skip to content

Commit 8b2ed3b

Browse files
dulekmandre
authored andcommitted
Use instanceIDFromProviderID() function (kubernetes#2302)
This commit makes sure that in all instances of reading Nova instance ID from the `.Spec.ProviderID` field, we're using `instanceIDFromProviderID()` function which is designed for that purpose.
1 parent 27823d9 commit 8b2ed3b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

pkg/openstack/loadbalancer.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -695,9 +695,9 @@ func getSubnetIDForLB(network *gophercloud.ServiceClient, node corev1.Node, pref
695695
return "", err
696696
}
697697

698-
instanceID := node.Spec.ProviderID
699-
if ind := strings.LastIndex(instanceID, "/"); ind >= 0 {
700-
instanceID = instanceID[(ind + 1):]
698+
_, instanceID, err := instanceIDFromProviderID(node.Spec.ProviderID)
699+
if err != nil {
700+
return "", fmt.Errorf("can't determine instance ID from ProviderID when autodetecting LB subnet: %w", err)
701701
}
702702

703703
ports, err := getAttachedPorts(network, instanceID)

0 commit comments

Comments
 (0)