Commit 05c2e624 authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

Merge branch 'devel-2.4' into devel-2.5



* devel-2.4:
  Ensure unused ports return to the free port pool
  Re-wrap a paragraph to eliminate a sphinx warning
Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarGuido Trotter <ultrotter@google.com>
parents ac2c8bc0 f396ad8c
......@@ -8002,6 +8002,11 @@ def _RemoveDisks(lu, instance, target_node=None):
" continuing anyway: %s", device.iv_name, node, msg)
all_result = False
# if this is a DRBD disk, return its port to the pool
if device.dev_type in constants.LDS_DRBD:
tcp_port = device.logical_id[2]
lu.cfg.AddTcpUdpPort(tcp_port)
if instance.disk_template == constants.DT_FILE:
file_storage_dir = os.path.dirname(instance.disks[0].logical_id[1])
if target_node:
......@@ -11161,6 +11166,11 @@ class LUInstanceSetParams(LogicalUnit):
self.LogWarning("Could not remove metadata for disk %d on node %s,"
" continuing anyway: %s", idx, pnode, msg)
# this is a DRBD disk, return its port to the pool
for disk in old_disks:
tcp_port = disk.logical_id[2]
self.cfg.AddTcpUdpPort(tcp_port)
def Exec(self, feedback_fn):
"""Modifies an instance.
......@@ -11187,6 +11197,11 @@ class LUInstanceSetParams(LogicalUnit):
self.LogWarning("Could not remove disk/%d on node %s: %s,"
" continuing anyway", device_idx, node, msg)
result.append(("disk/%d" % device_idx, "remove"))
# if this is a DRBD disk, return its port to the pool
if device.dev_type in constants.LDS_DRBD:
tcp_port = device.logical_id[2]
self.cfg.AddTcpUdpPort(tcp_port)
elif disk_op == constants.DDM_ADD:
# add a new disk
if instance.disk_template in (constants.DT_FILE,
......
......@@ -1158,6 +1158,14 @@ class ConfigWriter:
"""
if instance_name not in self._config_data.instances:
raise errors.ConfigurationError("Unknown instance '%s'" % instance_name)
# If a network port has been allocated to the instance,
# return it to the pool of free ports.
inst = self._config_data.instances[instance_name]
network_port = getattr(inst, "network_port", None)
if network_port is not None:
self._config_data.cluster.tcpudp_port_pool.add(network_port)
del self._config_data.instances[instance_name]
self._config_data.cluster.serial_no += 1
self._WriteConfig()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment