Skip to content

Commit 85e4ca1

Browse files
fix nil pointer exception during OpenStack FloatingIP assignment (#361)
1 parent 752124d commit 85e4ca1

File tree

1 file changed

+3
-2
lines changed
  • pkg/cloudprovider/provider/openstack

1 file changed

+3
-2
lines changed

pkg/cloudprovider/provider/openstack/helper.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,11 +365,12 @@ func assignFloatingIPToInstance(client *gophercloud.ProviderClient, instanceID,
365365
return osErrorToTerminalError(err, "failed to allocate a floating ip")
366366
}
367367
} else {
368-
ip, err = osfloatingips.Update(netClient, freeFloatingIps[0].ID, osfloatingips.UpdateOpts{
368+
freeIP := freeFloatingIps[0]
369+
ip, err := osfloatingips.Update(netClient, freeIP.ID, osfloatingips.UpdateOpts{
369370
PortID: &port.ID,
370371
}).Extract()
371372
if err != nil {
372-
return fmt.Errorf("failed to update FloatingIP %s: %v", ip.ID, err)
373+
return fmt.Errorf("failed to update FloatingIP %s(%s): %v", freeIP.ID, freeIP.FloatingIP, err)
373374
}
374375

375376
// We're now going to wait 3 seconds and check if the IP is still ours. If not, we're going to fail

0 commit comments

Comments
 (0)