Skip to content

Commit 0514aba

Browse files
authored
Use instanceIDFromProviderID() function (#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 95dc81c commit 0514aba

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
@@ -699,9 +699,9 @@ func getSubnetIDForLB(network *gophercloud.ServiceClient, node corev1.Node, pref
699699
return "", err
700700
}
701701

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

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

0 commit comments

Comments
 (0)