Skip to content

Commit bc5d407

Browse files
fixed the floating ip logic
1 parent 7c0354d commit bc5d407

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

dask_cloudprovider/openstack/instances.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,20 @@ async def create_and_assign_floating_ip(self, conn):
116116
floating_network_id=self.config["external_network_id"],
117117
)
118118

119-
# Assign the floating IP to the server
119+
# Find the first port of the instance
120+
ports = await self.cluster.call_async(
121+
conn.network.ports,
122+
device_id=self.instance.id
123+
)
124+
ports = list(ports)
125+
if not ports:
126+
raise RuntimeError(f"No network ports found for instance {self.instance.id}")
127+
128+
# Assign the floating IP to the instance's port
120129
await self.cluster.call_async(
121-
conn.compute.add_floating_ip_to_server,
122-
server=self.instance.id,
123-
address=floating_ip.floating_ip_address,
130+
conn.network.update_ip,
131+
floating_ip,
132+
port_id=ports[0].id
124133
)
125134

126135
return floating_ip.floating_ip_address

0 commit comments

Comments
 (0)