Skip to content

Commit 5af5eb6

Browse files
fix sfam-1413
1 parent 2eb7bbe commit 5af5eb6

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

simplyblock_core/controllers/tasks_controller.py

+18
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ def _add_task(function_name, cluster_id, node_id, device_id,
5252
if task_id:
5353
logger.info(f"Task found, skip adding new task: {task_id}")
5454
return False
55+
elif function_name == JobSchedule.FN_DEV_MIG:
56+
task_id = get_device_mig_task(cluster_id, node_id, function_params['distr_name'])
57+
if task_id:
58+
logger.info(f"Task found, skip adding new task: {task_id}")
59+
return False
5560

5661
task_obj = JobSchedule()
5762
task_obj.uuid = str(uuid.uuid4())
@@ -72,6 +77,8 @@ def _add_task(function_name, cluster_id, node_id, device_id,
7277
def add_device_mig_task(device_id):
7378
device = db_controller.get_storage_devices(device_id)
7479
for node in db_controller.get_storage_nodes_by_cluster_id(device.cluster_id):
80+
if not node.lvols:
81+
continue
7582
for bdev in node.lvstore_stack:
7683
if bdev['type'] == "bdev_distr":
7784
_add_task(JobSchedule.FN_DEV_MIG, device.cluster_id, node.get_id(), device.get_id(),
@@ -190,6 +197,7 @@ def get_active_node_task(cluster_id, node_id):
190197
return task.uuid
191198
return False
192199

200+
193201
def get_new_device_mig_task(cluster_id, node_id, distr_name):
194202
tasks = db_controller.get_job_tasks(cluster_id)
195203
for task in tasks:
@@ -198,3 +206,13 @@ def get_new_device_mig_task(cluster_id, node_id, distr_name):
198206
and "distr_name" in task.function_params and task.function_params["distr_name"] == distr_name:
199207
return task.uuid
200208
return False
209+
210+
211+
def get_device_mig_task(cluster_id, node_id, distr_name):
212+
tasks = db_controller.get_job_tasks(cluster_id)
213+
for task in tasks:
214+
if task.function_name == JobSchedule.FN_DEV_MIG and task.node_id == node_id:
215+
if task.status != JobSchedule.STATUS_DONE and task.canceled is False \
216+
and "distr_name" in task.function_params and task.function_params["distr_name"] == distr_name:
217+
return task.uuid
218+
return False

0 commit comments

Comments
 (0)