Skip to content

Commit

Permalink
WiP - Refactor conductor layer
Browse files Browse the repository at this point in the history
Refactors include mostly renames of Replica into Transfer, and Migration into
Deployment. They also include some constants refactoring (renaming and
removing deprecated ones).
  • Loading branch information
Dany9966 committed Nov 1, 2024
1 parent 34573ab commit f652776
Show file tree
Hide file tree
Showing 28 changed files with 754 additions and 820 deletions.
2 changes: 1 addition & 1 deletion coriolis/api/v1/replica_schedules.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from coriolis.api import wsgi as api_wsgi
from coriolis import exception
from coriolis.policies import replica_schedules as schedules_policies
from coriolis.replica_cron import api
from coriolis.transfer_cron import api
from coriolis import schemas

import jsonschema
Expand Down
6 changes: 3 additions & 3 deletions coriolis/api/v1/replicas.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
LOG = logging.getLogger(__name__)

SUPPORTED_REPLICA_SCENARIOS = [
constants.REPLICA_SCENARIO_REPLICA,
constants.REPLICA_SCENARIO_LIVE_MIGRATION]
constants.TRANSFER_SCENARIO_REPLICA,
constants.TRANSFER_SCENARIO_LIVE_MIGRATION]


class ReplicaController(api_wsgi.Controller):
Expand Down Expand Up @@ -79,7 +79,7 @@ def _validate_create_body(self, context, body):
f"'{scenario}', must be one of: "
f"{SUPPORTED_REPLICA_SCENARIOS}")
else:
scenario = constants.REPLICA_SCENARIO_REPLICA
scenario = constants.TRANSFER_SCENARIO_REPLICA
LOG.warn(
"No Replica 'scenario' field set in Replica body, "
f"defaulting to: '{scenario}'")
Expand Down
4 changes: 2 additions & 2 deletions coriolis/cmd/replica_cron.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from oslo_config import cfg

from coriolis import constants
from coriolis.replica_cron.rpc import server as rpc_server
from coriolis.transfer_cron.rpc import server as rpc_server
from coriolis import service
from coriolis import utils

Expand All @@ -19,7 +19,7 @@ def main():
utils.setup_logging()

server = service.MessagingService(
constants.REPLICA_CRON_MAIN_MESSAGING_TOPIC,
constants.TRANSFER_CRON_MAIN_MESSAGING_TOPIC,
[rpc_server.ReplicaCronServerEndpoint()],
rpc_server.VERSION, worker_count=1)
launcher = service.service.launch(
Expand Down
1,129 changes: 557 additions & 572 deletions coriolis/conductor/rpc/server.py

Large diffs are not rendered by default.

103 changes: 36 additions & 67 deletions coriolis/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

DEFAULT_CORIOLIS_REGION_NAME = "Default Region"

REPLICA_SCENARIO_REPLICA = "replica"
REPLICA_SCENARIO_LIVE_MIGRATION = "live_migration"
TRANSFER_SCENARIO_REPLICA = "replica"
TRANSFER_SCENARIO_LIVE_MIGRATION = "live_migration"

EXECUTION_STATUS_UNEXECUTED = "UNEXECUTED"
EXECUTION_STATUS_RUNNING = "RUNNING"
Expand Down Expand Up @@ -82,62 +82,36 @@
TASK_STATUS_FAILED_TO_CANCEL
]

TASK_TYPE_DEPLOY_MIGRATION_SOURCE_RESOURCES = (
"DEPLOY_MIGRATION_SOURCE_RESOURCES")
TASK_TYPE_DEPLOY_MIGRATION_TARGET_RESOURCES = (
"DEPLOY_MIGRATION_TARGET_RESOURCES")
TASK_TYPE_DELETE_MIGRATION_SOURCE_RESOURCES = (
"DELETE_MIGRATION_SOURCE_RESOURCES")
TASK_TYPE_DELETE_MIGRATION_TARGET_RESOURCES = (
"DELETE_MIGRATION_TARGET_RESOURCES")
TASK_TYPE_DEPLOY_INSTANCE_RESOURCES = "DEPLOY_INSTANCE_RESOURCES"
TASK_TYPE_FINALIZE_INSTANCE_DEPLOYMENT = "FINALIZE_INSTANCE_DEPLOYMENT"
TASK_TYPE_CLEANUP_FAILED_INSTANCE_DEPLOYMENT = (
"CLEANUP_FAILED_INSTANCE_DEPLOYMENT")
TASK_TYPE_CLEANUP_INSTANCE_SOURCE_STORAGE = (
"CLEANUP_INSTANCE_SOURCE_STORAGE")
TASK_TYPE_CLEANUP_INSTANCE_TARGET_STORAGE = (
"CLEANUP_INSTANCE_TARGET_STORAGE")

TASK_TYPE_CREATE_INSTANCE_DISKS = "CREATE_INSTANCE_DISKS"

TASK_TYPE_DEPLOY_OS_MORPHING_RESOURCES = "DEPLOY_OS_MORPHING_RESOURCES"
TASK_TYPE_OS_MORPHING = "OS_MORPHING"
TASK_TYPE_DELETE_OS_MORPHING_RESOURCES = "DELETE_OS_MORPHING_RESOURCES"

TASK_TYPE_GET_INSTANCE_INFO = "GET_INSTANCE_INFO"
TASK_TYPE_DEPLOY_REPLICA_DISKS = "DEPLOY_REPLICA_DISKS"
TASK_TYPE_DELETE_REPLICA_SOURCE_DISK_SNAPSHOTS = (
"DELETE_REPLICA_SOURCE_DISK_SNAPSHOTS")
TASK_TYPE_DELETE_REPLICA_DISKS = "DELETE_REPLICA_DISKS"
TASK_TYPE_DEPLOY_TRANSFER_DISKS = "DEPLOY_TRANSFER_DISKS"
TASK_TYPE_DELETE_TRANSFER_SOURCE_DISK_SNAPSHOTS = (
"DELETE_TRANSFER_SOURCE_DISK_SNAPSHOTS")
TASK_TYPE_DELETE_TRANSFER_DISKS = "DELETE_TRANSFER_DISKS"
TASK_TYPE_REPLICATE_DISKS = "REPLICATE_DISKS"
TASK_TYPE_DEPLOY_REPLICA_SOURCE_RESOURCES = "DEPLOY_REPLICA_SOURCE_RESOURCES"
TASK_TYPE_DELETE_REPLICA_SOURCE_RESOURCES = "DELETE_REPLICA_SOURCE_RESOURCES"
TASK_TYPE_DEPLOY_REPLICA_TARGET_RESOURCES = "DEPLOY_REPLICA_TARGET_RESOURCES"
TASK_TYPE_DELETE_REPLICA_TARGET_RESOURCES = "DELETE_REPLICA_TARGET_RESOURCES"
TASK_TYPE_DEPLOY_TRANSFER_SOURCE_RESOURCES = "DEPLOY_TRANSFER_SOURCE_RESOURCES"
TASK_TYPE_DELETE_TRANSFER_SOURCE_RESOURCES = "DELETE_TRANSFER_SOURCE_RESOURCES"
TASK_TYPE_DEPLOY_TRANSFER_TARGET_RESOURCES = "DEPLOY_TRANSFER_TARGET_RESOURCES"
TASK_TYPE_DELETE_TRANSFER_TARGET_RESOURCES = "DELETE_TRANSFER_TARGET_RESOURCES"
TASK_TYPE_SHUTDOWN_INSTANCE = "SHUTDOWN_INSTANCE"
TASK_TYPE_DEPLOY_REPLICA_INSTANCE_RESOURCES = (
"DEPLOY_REPLICA_INSTANCE_RESOURCES")
TASK_TYPE_FINALIZE_REPLICA_INSTANCE_DEPLOYMENT = (
"FINALIZE_REPLICA_INSTANCE_DEPLOYMENT")
TASK_TYPE_CLEANUP_FAILED_REPLICA_INSTANCE_DEPLOYMENT = (
"CLEANUP_FAILED_REPLICA_INSTANCE_DEPLOYMENT")
TASK_TYPE_CREATE_REPLICA_DISK_SNAPSHOTS = "CREATE_REPLICA_DISK_SNAPSHOTS"
TASK_TYPE_DELETE_REPLICA_TARGET_DISK_SNAPSHOTS = (
"DELETE_REPLICA_TARGET_DISK_SNAPSHOTS")
TASK_TYPE_RESTORE_REPLICA_DISK_SNAPSHOTS = "RESTORE_REPLICA_DISK_SNAPSHOTS"
TASK_TYPE_DEPLOY_INSTANCE_RESOURCES = "DEPLOY_INSTANCE_RESOURCES"
TASK_TYPE_CLEANUP_FAILED_INSTANCE_DEPLOYMENT = (
"CLEANUP_FAILED_INSTANCE_DEPLOYMENT")
TASK_TYPE_CREATE_TRANSFER_DISK_SNAPSHOTS = "CREATE_TRANSFER_DISK_SNAPSHOTS"
TASK_TYPE_DELETE_TRANSFER_TARGET_DISK_SNAPSHOTS = (
"DELETE_TRANSFER_TARGET_DISK_SNAPSHOTS")
TASK_TYPE_RESTORE_TRANSFER_DISK_SNAPSHOTS = "RESTORE_TRANSFER_DISK_SNAPSHOTS"
TASK_TYPE_GET_OPTIMAL_FLAVOR = "GET_OPTIMAL_FLAVOR"
TASK_TYPE_VALIDATE_MIGRATION_SOURCE_INPUTS = (
"VALIDATE_MIGRATION_SOURCE_INPUTS")
TASK_TYPE_VALIDATE_MIGRATION_DESTINATION_INPUTS = (
"VALIDATE_MIGRATION_DESTINATION_INPUTS")
TASK_TYPE_VALIDATE_REPLICA_SOURCE_INPUTS = "VALIDATE_REPLICA_SOURCE_INPUTS"
TASK_TYPE_VALIDATE_REPLICA_DESTINATION_INPUTS = (
"VALIDATE_REPLICA_DESTINATION_INPUTS")
TASK_TYPE_VALIDATE_REPLICA_DEPLOYMENT_INPUTS = (
"VALIDATE_REPLICA_DEPLOYMENT_INPUTS")
TASK_TYPE_UPDATE_SOURCE_REPLICA = "UPDATE_SOURCE_REPLICA"
TASK_TYPE_UPDATE_DESTINATION_REPLICA = "UPDATE_DESTINATION_REPLICA"
TASK_TYPE_VALIDATE_TRANSFER_SOURCE_INPUTS = "VALIDATE_TRANSFER_SOURCE_INPUTS"
TASK_TYPE_VALIDATE_TRANSFER_DESTINATION_INPUTS = (
"VALIDATE_TRANSFER_DESTINATION_INPUTS")
TASK_TYPE_VALIDATE_DEPLOYMENT_INPUTS = "VALIDATE_DEPLOYMENT_INPUTS"
TASK_TYPE_UPDATE_SOURCE_TRANSFER = "UPDATE_SOURCE_TRANSFER"
TASK_TYPE_UPDATE_DESTINATION_TRANSFER = "UPDATE_DESTINATION_TRANSFER"

TASK_TYPE_VALIDATE_SOURCE_MINION_POOL_OPTIONS = (
"VALIDATE_SOURCE_MINION_POOL_ENVIRONMENT_OPTIONS")
Expand Down Expand Up @@ -185,7 +159,6 @@
TASK_TYPE_POWER_ON_DESTINATION_MINION = "POWER_ON_DESTINATION_MINION"
TASK_TYPE_POWER_OFF_DESTINATION_MINION = "POWER_OFF_DESTINATION_MINION"


MINION_POOL_OPERATIONS_TASKS = [
TASK_TYPE_VALIDATE_SOURCE_MINION_POOL_OPTIONS,
TASK_TYPE_VALIDATE_DESTINATION_MINION_POOL_OPTIONS,
Expand Down Expand Up @@ -284,14 +257,13 @@
COMPRESSION_FORMAT_ZLIB
]

TRANSFER_ACTION_TYPE_MIGRATION = "migration"
TRANSFER_ACTION_TYPE_REPLICA = "replica"
TRANSFER_ACTION_TYPE_DEPLOYMENT = "deployment"
TRANSFER_ACTION_TYPE_TRANSFER = "transfer"

EXECUTION_TYPE_REPLICA_EXECUTION = "replica_execution"
EXECUTION_TYPE_REPLICA_DISKS_DELETE = "replica_disks_delete"
EXECUTION_TYPE_REPLICA_DEPLOY = "replica_deploy"
EXECUTION_TYPE_MIGRATION = "migration"
EXECUTION_TYPE_REPLICA_UPDATE = "replica_update"
EXECUTION_TYPE_TRANSFER_EXECUTION = "transfer_execution"
EXECUTION_TYPE_TRANSFER_DISKS_DELETE = "transfer_disks_delete"
EXECUTION_TYPE_DEPLOYMENT = "deployment"
EXECUTION_TYPE_TRANSFER_UPDATE = "transfer_update"
EXECUTION_TYPE_MINION_POOL_MAINTENANCE = "minion_pool_maintenance"
EXECUTION_TYPE_MINION_POOL_UPDATE = "minion_pool_update"
EXECUTION_TYPE_MINION_POOL_SET_UP_SHARED_RESOURCES = (
Expand All @@ -306,22 +278,19 @@
TASKFLOW_LOCK_NAME_FORMAT = "taskflow-%s"
EXECUTION_LOCK_NAME_FORMAT = "execution-%s"
ENDPOINT_LOCK_NAME_FORMAT = "endpoint-%s"
MIGRATION_LOCK_NAME_FORMAT = "migration-%s"
# NOTE(aznashwan): intentionately left identical to Migration locks.
DEPLOYMENT_LOCK_NAME_FORMAT = "migration-%s"
REPLICA_LOCK_NAME_FORMAT = "replica-%s"
DEPLOYMENT_LOCK_NAME_FORMAT = "deployment-%s"
TRANSFER_LOCK_NAME_FORMAT = "transfer-%s"
SCHEDULE_LOCK_NAME_FORMAT = "schedule-%s"
REGION_LOCK_NAME_FORMAT = "region-%s"
SERVICE_LOCK_NAME_FORMAT = "service-%s"
MINION_POOL_LOCK_NAME_FORMAT = "minion-pool-%s"
MINION_MACHINE_LOCK_NAME_FORMAT = "minion-pool-%s-machine-%s"

EXECUTION_TYPE_TO_ACTION_LOCK_NAME_FORMAT_MAP = {
EXECUTION_TYPE_MIGRATION: MIGRATION_LOCK_NAME_FORMAT,
EXECUTION_TYPE_REPLICA_EXECUTION: REPLICA_LOCK_NAME_FORMAT,
EXECUTION_TYPE_REPLICA_DEPLOY: REPLICA_LOCK_NAME_FORMAT,
EXECUTION_TYPE_REPLICA_UPDATE: REPLICA_LOCK_NAME_FORMAT,
EXECUTION_TYPE_REPLICA_DISKS_DELETE: REPLICA_LOCK_NAME_FORMAT,
EXECUTION_TYPE_TRANSFER_EXECUTION: TRANSFER_LOCK_NAME_FORMAT,
EXECUTION_TYPE_TRANSFER_UPDATE: TRANSFER_LOCK_NAME_FORMAT,
EXECUTION_TYPE_TRANSFER_DISKS_DELETE: TRANSFER_LOCK_NAME_FORMAT,
EXECUTION_TYPE_DEPLOYMENT: DEPLOYMENT_LOCK_NAME_FORMAT,
EXECUTION_TYPE_MINION_POOL_MAINTENANCE: MINION_POOL_LOCK_NAME_FORMAT,
EXECUTION_TYPE_MINION_POOL_UPDATE: MINION_POOL_LOCK_NAME_FORMAT,
EXECUTION_TYPE_MINION_POOL_SET_UP_SHARED_RESOURCES: (
Expand All @@ -340,7 +309,7 @@
CONDUCTOR_MAIN_MESSAGING_TOPIC = "coriolis_conductor"
WORKER_MAIN_MESSAGING_TOPIC = "coriolis_worker"
SCHEDULER_MAIN_MESSAGING_TOPIC = "coriolis_scheduler"
REPLICA_CRON_MAIN_MESSAGING_TOPIC = "coriolis_replica_cron_worker"
TRANSFER_CRON_MAIN_MESSAGING_TOPIC = "coriolis_transfer_cron_worker"
MINION_MANAGER_MAIN_MESSAGING_TOPIC = "coriolis_minion_manager"

MINION_POOL_MACHINE_RETENTION_STRATEGY_DELETE = "delete"
Expand Down
2 changes: 1 addition & 1 deletion coriolis/db/sqlalchemy/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ class Transfer(BaseTransferAction):
'base_transfer_action.base_id'), primary_key=True)
scenario = sqlalchemy.Column(
sqlalchemy.String(255), nullable=False,
default=constants.REPLICA_SCENARIO_REPLICA)
default=constants.TRANSFER_SCENARIO_REPLICA)

__mapper_args__ = {
'polymorphic_identity': 'transfer',
Expand Down
4 changes: 2 additions & 2 deletions coriolis/diagnostics/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
# All Rights Reserved.

from coriolis.conductor.rpc import client as conductor_rpc
from coriolis.replica_cron.rpc import client as cron_rpc
from coriolis.transfer_cron.rpc import client as cron_rpc
from coriolis import utils
from coriolis.worker.rpc import client as worker_rpc


class API(object):
def __init__(self):
self._conductor_cli = conductor_rpc.ConductorClient()
self._cron_cli = cron_rpc.ReplicaCronClient()
self._cron_cli = cron_rpc.TransferCronClient()
self._worker_cli = worker_rpc.WorkerClient()

def get(self, ctxt):
Expand Down
12 changes: 8 additions & 4 deletions coriolis/exception.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,12 +235,16 @@ class InvalidActionTasksExecutionState(Invalid):
message = _("Invalid tasks execution state: %(reason)s")


class InvalidMigrationState(Invalid):
message = _("Invalid migration state: %(reason)s")
class InvalidDeploymentState(Invalid):
message = _("Invalid deployment state: %(reason)s")


class InvalidReplicaState(Invalid):
message = _("Invalid replica state: %(reason)s")
class InvalidTasksExecutionState(Invalid):
message = _("Invalid tasks execution state: %(reason)s")


class InvalidTransferState(Invalid):
message = _("Invalid transfer state: %(reason)s")


class InvalidInstanceState(Invalid):
Expand Down
4 changes: 2 additions & 2 deletions coriolis/minion_manager/rpc/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ def validate_minion_pool_selections_for_action(self, ctxt, action):
ctxt, 'validate_minion_pool_selections_for_action',
action=action)

def allocate_minion_machines_for_replica(
def allocate_minion_machines_for_transfer(
self, ctxt, replica):
return self._cast(
ctxt, 'allocate_minion_machines_for_replica', replica=replica)

def allocate_minion_machines_for_migration(
def allocate_minion_machines_for_deployment(
self, ctxt, migration, include_transfer_minions=True,
include_osmorphing_minions=True):
return self._cast(
Expand Down
8 changes: 4 additions & 4 deletions coriolis/minion_manager/rpc/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ def allocate_minion_machines_for_replica(
try:
self._run_machine_allocation_subflow_for_action(
ctxt, replica,
constants.TRANSFER_ACTION_TYPE_REPLICA,
constants.TRANSFER_ACTION_TYPE_TRANSFER,
include_transfer_minions=True,
include_osmorphing_minions=False)
except Exception as ex:
Expand All @@ -539,7 +539,7 @@ def allocate_minion_machines_for_migration(
try:
self._run_machine_allocation_subflow_for_action(
ctxt, migration,
constants.TRANSFER_ACTION_TYPE_MIGRATION,
constants.TRANSFER_ACTION_TYPE_DEPLOYMENT,
include_transfer_minions=include_transfer_minions,
include_osmorphing_minions=include_osmorphing_minions)
except Exception as ex:
Expand Down Expand Up @@ -779,7 +779,7 @@ def _run_machine_allocation_subflow_for_action(
machine_action_allocation_subflow_name_format = None
allocation_failure_reporting_task_class = None
allocation_confirmation_reporting_task_class = None
if action_type == constants.TRANSFER_ACTION_TYPE_MIGRATION:
if action_type == constants.TRANSFER_ACTION_TYPE_DEPLOYMENT:
allocation_flow_name_format = (
(minion_mgr_tasks.
MINION_POOL_MIGRATION_ALLOCATION_FLOW_NAME_FORMAT))
Expand All @@ -793,7 +793,7 @@ def _run_machine_allocation_subflow_for_action(
machine_action_allocation_subflow_name_format = (
(minion_mgr_tasks.
MINION_POOL_ALLOCATE_MACHINES_FOR_MIGRATION_SUBFLOW_NAME_FORMAT)) # noqa: E501
elif action_type == constants.TRANSFER_ACTION_TYPE_REPLICA:
elif action_type == constants.TRANSFER_ACTION_TYPE_TRANSFER:
allocation_flow_name_format = (
(minion_mgr_tasks.
MINION_POOL_REPLICA_ALLOCATION_FLOW_NAME_FORMAT))
Expand Down
4 changes: 2 additions & 2 deletions coriolis/minion_manager/rpc/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,8 +379,8 @@ def _check_minion_properties(
raise exception.MinionMachineAllocationFailure(
msg) from ex
except (
exception.InvalidMigrationState,
exception.InvalidReplicaState) as ex:
exception.InvalidDeploymentState,
exception.InvalidTransferState) as ex:
msg = (
"The Conductor has refused minion machine allocations for "
"%s with ID '%s' as it is purportedly in an invalid state "
Expand Down
6 changes: 3 additions & 3 deletions coriolis/scheduler/scheduler_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from coriolis import constants
from coriolis.db import api as db_api
from coriolis import exception
from coriolis.replica_cron.rpc import client as rpc_cron_client
from coriolis.transfer_cron.rpc import client as rpc_cron_client
from coriolis.scheduler.rpc import client as rpc_scheduler_client
from coriolis.worker.rpc import client as rpc_worker_client

Expand All @@ -21,8 +21,8 @@
constants.WORKER_MAIN_MESSAGING_TOPIC: rpc_worker_client.WorkerClient,
constants.SCHEDULER_MAIN_MESSAGING_TOPIC: (
rpc_scheduler_client.SchedulerClient),
constants.REPLICA_CRON_MAIN_MESSAGING_TOPIC: (
rpc_cron_client.ReplicaCronClient)
constants.TRANSFER_CRON_MAIN_MESSAGING_TOPIC: (
rpc_cron_client.TransferCronClient)
}


Expand Down
Loading

0 comments on commit f652776

Please sign in to comment.