Skip to content

Commit ab97c66

Browse files
committed
Automation for CEPH-83584085: Live migration of raw data format
Signed-off-by: Aarti Sharma <[email protected]>
1 parent f6deaae commit ab97c66

File tree

4 files changed

+462
-0
lines changed

4 files changed

+462
-0
lines changed

ceph/rbd/workflows/migration.py

+103
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import json
22
import tempfile
33

4+
from ceph.rbd.utils import random_string
5+
from ceph.rbd.workflows.rbd import create_single_pool_and_images
46
from cli.rbd.rbd import Rbd
57
from utility.log import Log
68

@@ -73,3 +75,104 @@ def prepare_migration_source_spec(
7375
spec_file.flush()
7476

7577
return temp_file.name
78+
79+
80+
def run_prepare_execute_commit(rbd, pool, image, **kw):
81+
"""
82+
Function to carry out the following:
83+
- Create Target/destination pool for migration
84+
- Migration prepare
85+
- Migration Execute
86+
- Migration commit
87+
Args:
88+
kw: rbd object, pool, image, test data
89+
Returns:
90+
int: The return value. 0 for success, 1 otherwise
91+
92+
"""
93+
# Create Target Pool/ Destination Pool for migration
94+
is_ec_pool = True if "ec" in kw[pool]["pool_type"] else False
95+
config = kw.get("config", {})
96+
target_pool = "target_pool_" + random_string(len=3)
97+
target_pool_config = {}
98+
if is_ec_pool:
99+
data_pool_target = "data_pool_new_" + random_string(len=3)
100+
target_pool_config["data_pool"] = data_pool_target
101+
rc = create_single_pool_and_images(
102+
config=config,
103+
pool=target_pool,
104+
pool_config=target_pool_config,
105+
client=kw["client"],
106+
cluster="ceph",
107+
rbd=rbd,
108+
ceph_version=int(config.get("rhbuild")[0]),
109+
is_ec_pool=is_ec_pool,
110+
is_secondary=False,
111+
do_not_create_image=True,
112+
)
113+
if rc:
114+
log.error(f"Creation of target pool {target_pool} failed")
115+
return rc
116+
117+
# Adding the new pool details to config so that they are handled in cleanup
118+
if kw[pool]["pool_type"] == "rep_pool_config":
119+
kw["config"]["rep_pool_config"][target_pool] = {}
120+
elif kw[pool]["pool_type"] == "ec_pool_config":
121+
kw["config"]["ec_pool_config"][target_pool] = {"data_pool": data_pool_target}
122+
123+
# Prepare Migration
124+
target_image = "target_image_" + random_string(len=3)
125+
rbd.migration.prepare(
126+
source_spec=kw[pool]["spec"],
127+
dest_spec=f"{target_pool}/{target_image}",
128+
client_node=kw["client"],
129+
)
130+
kw[pool].update({"target_pool": target_pool})
131+
kw[pool].update({"target_image": target_image})
132+
133+
# Verify prepare migration status
134+
if verify_migration_state(
135+
action="prepare",
136+
image_spec=f"{target_pool}/{target_image}",
137+
**kw,
138+
):
139+
log.error("Failed to prepare migration")
140+
return 1
141+
else:
142+
log.info("Migration prepare status verfied successfully")
143+
144+
# execute migration
145+
rbd.migration.action(
146+
action="execute",
147+
dest_spec=f"{target_pool}/{target_image}",
148+
client_node=kw["client"],
149+
)
150+
151+
# verify execute migration status
152+
if verify_migration_state(
153+
action="execute",
154+
image_spec=f"{target_pool}/{target_image}",
155+
**kw,
156+
):
157+
log.error("Failed to execute migration")
158+
return 1
159+
else:
160+
log.info("Migration executed successfully")
161+
162+
# commit migration
163+
rbd.migration.action(
164+
action="commit",
165+
dest_spec=f"{target_pool}/{target_image}",
166+
client_node=kw["client"],
167+
)
168+
169+
# verify commit migration status
170+
if verify_migration_state(
171+
action="commit",
172+
image_spec=f"{target_pool}/{target_image}",
173+
**kw,
174+
):
175+
log.error("Failed to commit migration")
176+
return 1
177+
else:
178+
log.info("Migration committed successfully")

cli/rbd/rbd.py

+66
Original file line numberDiff line numberDiff line change
@@ -390,3 +390,69 @@ def image_usage(self, **kw):
390390
cmd = f"{self.base_cmd} du {image_spec} {build_cmd_from_args(**kw_copy)}"
391391

392392
return self.execute_as_sudo(cmd=cmd)
393+
394+
def lock_ls(self, **kw):
395+
"""
396+
This method is used to get list of locked rbd images
397+
Args:
398+
kw(dict): Key/value pairs that needs to be provided to the installer
399+
Example:
400+
Supported keys:
401+
image-spec(str) : [<pool-name>/[<namespace>/]]<image-name>
402+
"""
403+
kw_copy = deepcopy(kw)
404+
image_spec = kw_copy.pop("image-spec", "")
405+
cmd = f"{self.base_cmd} lock ls {image_spec} {build_cmd_from_args(**kw_copy)}"
406+
407+
return self.execute_as_sudo(cmd=cmd)
408+
409+
def lock_rm(self, **kw):
410+
"""
411+
This method is used to remove lock from rbd image
412+
Args:
413+
kw(dict): Key/value pairs that needs to be provided to the installer
414+
Example:
415+
Supported keys:
416+
lock-spec(str) : locker_id locker_name
417+
"""
418+
kw_copy = deepcopy(kw)
419+
lock_spec = kw_copy.pop("lock-spec", "")
420+
cmd = f"{self.base_cmd} lock rm {build_cmd_from_args(**kw_copy)} {lock_spec}"
421+
422+
return self.execute_as_sudo(cmd=cmd)
423+
424+
def blocklist_ls(self):
425+
"""
426+
This method is used to list blocklisted clients
427+
"""
428+
cmd = "ceph osd blocklist ls"
429+
430+
return self.execute_as_sudo(cmd=cmd)
431+
432+
def blocklist_rm(self, **kw):
433+
"""
434+
This method is used to remove specific ip from blocklisted entries
435+
Args:
436+
kw(dict): Key/value pairs that needs to be provided to the installer
437+
Example:
438+
Supported keys:
439+
ip_spec(str) : blocklist ip in form "10.0.67.42:0/3439165164"
440+
"""
441+
kw_copy = deepcopy(kw)
442+
blocklist_ip_spec = kw_copy.pop("ip-spec", "")
443+
cmd = f"ceph osd blocklist rm {blocklist_ip_spec}"
444+
445+
return self.execute_as_sudo(cmd=cmd)
446+
447+
def get_raw_file_size(self, raw_file_path):
448+
"""
449+
This method is used get size of raw file format
450+
Args:
451+
kw(dict): Key/value pairs that needs to be provided to the installer
452+
Example:
453+
Supported keys:
454+
raw_file_path(str) : absolute path of the file
455+
"""
456+
cmd = f"ls -lh {raw_file_path}"
457+
458+
return self.execute(cmd=cmd)

suites/squid/rbd/tier-3_rbd_migration.yaml

+17
Original file line numberDiff line numberDiff line change
@@ -178,3 +178,20 @@ tests:
178178
Rollback after Failed Migration using migration
179179
abort in single ceph cluster
180180
polarion-id: CEPH-83584090
181+
182+
- test:
183+
desc: Live migration of image with external data source as RAW data format in single ceph cluster
184+
config:
185+
rep_pool_config:
186+
num_pools: 1
187+
do_not_create_image: true
188+
ec_pool_config:
189+
num_pools: 1
190+
do_not_create_image: true
191+
fio:
192+
size: 1G
193+
fs: ext4
194+
io: true
195+
module: test_live_migration_with_raw_data_format.py
196+
name: Live migration of raw data format
197+
polarion-id: CEPH-83584085

0 commit comments

Comments
 (0)