Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automation for CEPH-83584085: Live migration of raw data format #4487

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 103 additions & 0 deletions ceph/rbd/workflows/migration.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import json
import tempfile

from ceph.rbd.utils import random_string
from ceph.rbd.workflows.rbd import create_single_pool_and_images
from cli.rbd.rbd import Rbd
from utility.log import Log

Expand Down Expand Up @@ -73,3 +75,104 @@ def prepare_migration_source_spec(
spec_file.flush()

return temp_file.name


def run_prepare_execute_commit(rbd, pool, image, **kw):
"""
Function to carry out the following:
- Create Target/destination pool for migration
- Migration prepare
- Migration Execute
- Migration commit
Args:
kw: rbd object, pool, image, test data
Returns:
int: The return value. 0 for success, 1 otherwise

"""
# Create Target Pool/ Destination Pool for migration
is_ec_pool = True if "ec" in kw[pool]["pool_type"] else False
config = kw.get("config", {})
target_pool = "target_pool_" + random_string(len=3)
target_pool_config = {}
if is_ec_pool:
data_pool_target = "data_pool_new_" + random_string(len=3)
target_pool_config["data_pool"] = data_pool_target
rc = create_single_pool_and_images(
config=config,
pool=target_pool,
pool_config=target_pool_config,
client=kw["client"],
cluster="ceph",
rbd=rbd,
ceph_version=int(config.get("rhbuild")[0]),
is_ec_pool=is_ec_pool,
is_secondary=False,
do_not_create_image=True,
)
if rc:
log.error(f"Creation of target pool {target_pool} failed")
return rc

# Adding the new pool details to config so that they are handled in cleanup
if kw[pool]["pool_type"] == "rep_pool_config":
kw["config"]["rep_pool_config"][target_pool] = {}
elif kw[pool]["pool_type"] == "ec_pool_config":
kw["config"]["ec_pool_config"][target_pool] = {"data_pool": data_pool_target}

# Prepare Migration
target_image = "target_image_" + random_string(len=3)
rbd.migration.prepare(
source_spec=kw[pool]["spec"],
dest_spec=f"{target_pool}/{target_image}",
client_node=kw["client"],
)
kw[pool].update({"target_pool": target_pool})
kw[pool].update({"target_image": target_image})

# Verify prepare migration status
if verify_migration_state(
action="prepare",
image_spec=f"{target_pool}/{target_image}",
**kw,
):
log.error("Failed to prepare migration")
return 1
else:
log.info("Migration prepare status verfied successfully")

# execute migration
rbd.migration.action(
action="execute",
dest_spec=f"{target_pool}/{target_image}",
client_node=kw["client"],
)

# verify execute migration status
if verify_migration_state(
action="execute",
image_spec=f"{target_pool}/{target_image}",
**kw,
):
log.error("Failed to execute migration")
return 1
else:
log.info("Migration executed successfully")

# commit migration
rbd.migration.action(
action="commit",
dest_spec=f"{target_pool}/{target_image}",
client_node=kw["client"],
)

# verify commit migration status
if verify_migration_state(
action="commit",
image_spec=f"{target_pool}/{target_image}",
**kw,
):
log.error("Failed to commit migration")
return 1
else:
log.info("Migration committed successfully")
13 changes: 13 additions & 0 deletions cli/rbd/rbd.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,3 +390,16 @@ def image_usage(self, **kw):
cmd = f"{self.base_cmd} du {image_spec} {build_cmd_from_args(**kw_copy)}"

return self.execute_as_sudo(cmd=cmd)

def get_raw_file_size(self, raw_file_path):
"""
This method is used get size of raw file format
Args:
kw(dict): Key/value pairs that needs to be provided to the installer
Example:
Supported keys:
raw_file_path(str) : absolute path of the file
"""
cmd = f"ls -lh {raw_file_path}"

return self.execute(cmd=cmd)
17 changes: 17 additions & 0 deletions suites/squid/rbd/tier-3_rbd_migration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -178,3 +178,20 @@ tests:
Rollback after Failed Migration using migration
abort in single ceph cluster
polarion-id: CEPH-83584090

- test:
desc: Live migration of image with external data source as RAW data format in single ceph cluster
config:
rep_pool_config:
num_pools: 1
do_not_create_image: true
ec_pool_config:
num_pools: 1
do_not_create_image: true
fio:
size: 1G
fs: ext4
io: true
module: test_live_migration_with_raw_data_format.py
name: Live migration of raw data format
polarion-id: CEPH-83584085
Loading