Add volume resize if changed
This commit is contained in:
parent
9aa32134a9
commit
235299942a
|
@ -3352,11 +3352,7 @@ def vm_worker_send_snapshot(
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# Begin send, set stages
|
# Begin send, set stages
|
||||||
total_stages = (
|
total_stages = 2 + (3 * len(snapshot_rbdsnaps))
|
||||||
2
|
|
||||||
+ (2 * len(snapshot_rbdsnaps))
|
|
||||||
+ (len(snapshot_rbdsnaps) if current_destination_vm_state is None else 0)
|
|
||||||
)
|
|
||||||
|
|
||||||
current_stage += 1
|
current_stage += 1
|
||||||
update(
|
update(
|
||||||
|
@ -3417,18 +3413,17 @@ def vm_worker_send_snapshot(
|
||||||
return False
|
return False
|
||||||
|
|
||||||
try:
|
try:
|
||||||
_ = ceph.format_bytes_fromhuman(retdata[0]["stats"]["size"])
|
local_volume_size = ceph.format_bytes_fromhuman(retdata[0]["stats"]["size"])
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
error_message = f"Failed to get volume size for {rbd_name}: {e}"
|
error_message = f"Failed to get volume size for {rbd_name}: {e}"
|
||||||
|
|
||||||
if destination_storage_pool is not None:
|
if destination_storage_pool is not None:
|
||||||
pool = destination_storage_pool
|
pool = destination_storage_pool
|
||||||
|
|
||||||
if current_destination_vm_state is None:
|
|
||||||
current_stage += 1
|
current_stage += 1
|
||||||
update(
|
update(
|
||||||
celery,
|
celery,
|
||||||
f"Checking for remote volume {rbd_name}",
|
f"Checking remote volume {rbd_name} for compliance",
|
||||||
current=current_stage,
|
current=current_stage,
|
||||||
total=total_stages,
|
total=total_stages,
|
||||||
)
|
)
|
||||||
|
@ -3439,13 +3434,35 @@ def vm_worker_send_snapshot(
|
||||||
params=None,
|
params=None,
|
||||||
data=None,
|
data=None,
|
||||||
)
|
)
|
||||||
if response.status_code != 404:
|
if response.status_code != 404 and current_destination_vm_state is None:
|
||||||
fail(
|
fail(
|
||||||
celery,
|
celery,
|
||||||
f"Remote storage pool {pool} already contains volume {volume}",
|
f"Remote storage pool {pool} already contains volume {volume}",
|
||||||
)
|
)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
if current_destination_vm_state is not None:
|
||||||
|
try:
|
||||||
|
remote_volume_size = ceph.format_bytes_fromhuman(
|
||||||
|
response.json()[0]["stats"]["size"]
|
||||||
|
)
|
||||||
|
except Exception as e:
|
||||||
|
error_message = f"Failed to get volume size for remote {rbd_name}: {e}"
|
||||||
|
fail(celery, error_message)
|
||||||
|
return False
|
||||||
|
|
||||||
|
if local_volume_size != remote_volume_size:
|
||||||
|
response = session.put(
|
||||||
|
f"{destination_api_uri}/storage/ceph/volume/{pool}/{volume}",
|
||||||
|
params={"new_size": local_volume_size, "force": True},
|
||||||
|
)
|
||||||
|
if response.status_code != 200:
|
||||||
|
fail(
|
||||||
|
celery,
|
||||||
|
"Failed to resize remote volume to match local volume",
|
||||||
|
)
|
||||||
|
return False
|
||||||
|
|
||||||
# Send the volume to the remote
|
# Send the volume to the remote
|
||||||
cluster = rados.Rados(conffile="/etc/ceph/ceph.conf")
|
cluster = rados.Rados(conffile="/etc/ceph/ceph.conf")
|
||||||
cluster.connect()
|
cluster.connect()
|
||||||
|
|
Loading…
Reference in New Issue