From 863f8baf86e64e825dba6b217bfdce5fe53e8f84 Mon Sep 17 00:00:00 2001 From: Mikayla Thompson Date: Wed, 19 Jun 2024 11:47:32 -0600 Subject: [PATCH 1/5] Clean up handling of CommandResults Signed-off-by: Mikayla Thompson --- .../console_link/logic/backfill.py | 18 +++++++++--------- .../console_link/models/command_result.py | 5 +++++ 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/logic/backfill.py b/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/logic/backfill.py index 1aa5622b6..504b3b228 100644 --- a/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/logic/backfill.py +++ b/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/logic/backfill.py @@ -75,8 +75,8 @@ def create(backfill: Backfill, *args, **kwargs) -> Tuple[ExitCode, str]: return ExitCode.FAILURE, f"Failure when creating backfill: {type(e).__name__} {e}" if result.success: - return ExitCode.SUCCESS, "Backfill created successfully." + "\n" + result.value - return ExitCode.FAILURE, "Backfill creation failed." + "\n" + result.value + return ExitCode.SUCCESS, "Backfill created successfully." + "\n" + result.display() + return ExitCode.FAILURE, "Backfill creation failed." + "\n" + result.display() def start(backfill: Backfill, *args, **kwargs) -> Tuple[ExitCode, str]: @@ -90,8 +90,8 @@ def start(backfill: Backfill, *args, **kwargs) -> Tuple[ExitCode, str]: return ExitCode.FAILURE, f"Failure when starting backfill: {type(e).__name__} {e}" if result.success: - return ExitCode.SUCCESS, "Backfill started successfully." + "\n" + result.value - return ExitCode.FAILURE, "Backfill start failed." + "\n" + result.value + return ExitCode.SUCCESS, "Backfill started successfully." + "\n" + result.display() + return ExitCode.FAILURE, "Backfill start failed." + "\n" + result.display() def stop(backfill: Backfill, *args, **kwargs) -> Tuple[ExitCode, str]: @@ -105,8 +105,8 @@ def stop(backfill: Backfill, *args, **kwargs) -> Tuple[ExitCode, str]: logger.error(f"Failed to stop backfill: {e}") return ExitCode.FAILURE, f"Failure when stopping backfill: {type(e).__name__} {e}" if result.success: - return ExitCode.SUCCESS, "Backfill stopped successfully." + "\n" + result.value - return ExitCode.FAILURE, "Backfill stop failed." + "\n" + result.value + return ExitCode.SUCCESS, "Backfill stopped successfully." + "\n" + result.display() + return ExitCode.FAILURE, "Backfill stop failed." + "\n" + result.display() def scale(backfill: Backfill, units: int, *args, **kwargs) -> Tuple[ExitCode, str]: @@ -120,8 +120,8 @@ def scale(backfill: Backfill, units: int, *args, **kwargs) -> Tuple[ExitCode, st logger.error(f"Failed to scale backfill: {e}") return ExitCode.FAILURE, f"Failure when scaling backfill: {type(e).__name__} {e}" if result.success: - return ExitCode.SUCCESS, "Backfill scaled successfully." + "\n" + result.value - return ExitCode.FAILURE, "Backfill scale failed." + "\n" + result.value + return ExitCode.SUCCESS, "Backfill scaled successfully." + "\n" + result.display() + return ExitCode.FAILURE, "Backfill scale failed." + "\n" + result.display() def status(backfill: Backfill, *args, **kwargs) -> Tuple[ExitCode, str]: @@ -136,4 +136,4 @@ def status(backfill: Backfill, *args, **kwargs) -> Tuple[ExitCode, str]: return ExitCode.FAILURE, f"Failure when getting status of backfill: {type(e).__name__} {e}" if result.success: return ExitCode.SUCCESS, result.value - return ExitCode.FAILURE, "Backfill status retrieval failed." + "\n" + result.value + return ExitCode.FAILURE, "Backfill status retrieval failed." + "\n" + result diff --git a/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/models/command_result.py b/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/models/command_result.py index 6cd67eb30..622534a83 100644 --- a/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/models/command_result.py +++ b/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/models/command_result.py @@ -4,3 +4,8 @@ class CommandResult(NamedTuple): success: bool value: Any + + def display(self) -> str: + if self.value: + return str(self.value) + return "" From f1a691482c502bf6ee4bd588c15cefbc02599e2a Mon Sep 17 00:00:00 2001 From: Mikayla Thompson Date: Wed, 19 Jun 2024 11:47:59 -0600 Subject: [PATCH 2/5] Move the aws utils Signed-off-by: Mikayla Thompson --- .../lib/console_link/console_link/models/metrics_source.py | 2 +- .../lib/console_link/console_link/{logic => models}/utils.py | 0 .../lib/console_link/tests/test_metrics_source.py | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) rename TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/{logic => models}/utils.py (100%) diff --git a/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/models/metrics_source.py b/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/models/metrics_source.py index 0c65feb9e..7a5dc698d 100644 --- a/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/models/metrics_source.py +++ b/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/models/metrics_source.py @@ -5,7 +5,7 @@ import boto3 import botocore from cerberus import Validator -from console_link.logic.utils import raise_for_aws_api_error +from console_link.models.utils import raise_for_aws_api_error import requests import logging diff --git a/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/logic/utils.py b/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/models/utils.py similarity index 100% rename from TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/logic/utils.py rename to TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/models/utils.py diff --git a/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/tests/test_metrics_source.py b/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/tests/test_metrics_source.py index 325bc8276..f7f78b4bd 100644 --- a/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/tests/test_metrics_source.py +++ b/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/tests/test_metrics_source.py @@ -11,7 +11,7 @@ import botocore.session from botocore.stub import Stubber -from console_link.logic.utils import AWSAPIError +from console_link.models.utils import AWSAPIError TEST_DATA_DIRECTORY = pathlib.Path(__file__).parent / "data" AWS_REGION = "us-east-1" From f106568407a599e2356be150e3610a1973dd3676 Mon Sep 17 00:00:00 2001 From: Mikayla Thompson Date: Wed, 19 Jun 2024 11:48:46 -0600 Subject: [PATCH 3/5] Add ECS service and implement rfs start/stop Signed-off-by: Mikayla Thompson --- .../console_link/logic/backfill.py | 8 ++-- .../console_link/models/backfill_rfs.py | 18 ++++++++- .../console_link/models/ecs_service.py | 40 +++++++++++++++++++ 3 files changed, 60 insertions(+), 6 deletions(-) create mode 100644 TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/models/ecs_service.py diff --git a/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/logic/backfill.py b/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/logic/backfill.py index 504b3b228..b7e34e012 100644 --- a/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/logic/backfill.py +++ b/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/logic/backfill.py @@ -127,13 +127,13 @@ def scale(backfill: Backfill, units: int, *args, **kwargs) -> Tuple[ExitCode, st def status(backfill: Backfill, *args, **kwargs) -> Tuple[ExitCode, str]: logger.info("Getting backfill status") try: - result = backfill.get_status(*args, **kwargs) + status = backfill.get_status(*args, **kwargs) except NotImplementedError: logger.error(f"Status is not implemented for backfill {type(backfill).__name__}") return ExitCode.FAILURE, f"Status is not implemented for backfill: {type(backfill).__name__}" except Exception as e: logger.error(f"Failed to get status of backfill: {e}") return ExitCode.FAILURE, f"Failure when getting status of backfill: {type(e).__name__} {e}" - if result.success: - return ExitCode.SUCCESS, result.value - return ExitCode.FAILURE, "Backfill status retrieval failed." + "\n" + result + if status: + return ExitCode.SUCCESS, status.value + return ExitCode.FAILURE, "Backfill status retrieval failed." + "\n" + status diff --git a/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/models/backfill_rfs.py b/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/models/backfill_rfs.py index fd5dd5bb5..bacaef1b1 100644 --- a/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/models/backfill_rfs.py +++ b/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/models/backfill_rfs.py @@ -3,10 +3,13 @@ from console_link.models.cluster import Cluster from console_link.models.schema_tools import contains_one_of from console_link.models.command_result import CommandResult +from console_link.models.ecs_service import ECSService from cerberus import Validator -import boto3 +import logging + +logger = logging.getLogger(__name__) DOCKER_RFS_SCHEMA = { "type": "dict", @@ -76,5 +79,16 @@ class ECSRFSBackfill(RFSBackfill): def __init__(self, config: Dict, target_cluster: Cluster) -> None: super().__init__(config) self.target_cluster = target_cluster + self.default_scale = self.config["reindex_from_snapshot"].get("scale", 1) + self.ecs_config = self.config["reindex_from_snapshot"]["ecs"] - self.client = boto3.client("ecs", region_name=self.ecs_config.get("aws_region", None)) + self.ecs_client = ECSService(self.ecs_config["cluster_name"], self.ecs_config["service_name"], + self.ecs_config.get("aws_region", None)) + + def start(self, *args, **kwargs) -> CommandResult: + logger.info(f"Starting RFS backfill by setting desired count to {self.default_scale} instances") + return self.ecs_client.set_desired_count(self.default_scale) + + def stop(self, *args, **kwargs) -> CommandResult: + logger.info("Stopping RFS backfill by setting desired count to 0 instances") + return self.ecs_client.set_desired_count(0) diff --git a/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/models/ecs_service.py b/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/models/ecs_service.py new file mode 100644 index 000000000..f1bda4198 --- /dev/null +++ b/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/models/ecs_service.py @@ -0,0 +1,40 @@ +import logging + +import boto3 + +from console_link.models.command_result import CommandResult +from console_link.models.utils import AWSAPIError, raise_for_aws_api_error + + +logger = logging.getLogger(__name__) + + +class ECSService: + def __init__(self, cluster_name, service_name, aws_region=None): + self.cluster_name = cluster_name + self.service_name = service_name + self.aws_region = aws_region + + logger.info(f"Creating ECS client for region {aws_region}, if specified") + self.client = boto3.client("ecs", region_name=self.aws_region) + + def set_desired_count(self, desired_count: int) -> CommandResult: + logger.info(f"Setting desired count for service {self.service_name} to {desired_count}") + response = self.client.update_service( + cluster=self.cluster_name, + service=self.service_name, + desiredCount=desired_count + ) + logger.debug(f"Response from update_service: {response}") + + try: + raise_for_aws_api_error(response) + except AWSAPIError as e: + return CommandResult(False, e) + + logger.info(f"Service status: {response['service']['status']}") + running_count = response["service"]["runningCount"] + pending_count = response["service"]["pendingCount"] + desired_count = response["service"]["desiredCount"] + return CommandResult(True, f"Service {self.service_name} set to {desired_count} desired count." + f" Currently {running_count} running and {pending_count} pending.") From 638acb44a909e23c95bed26827b96118f6d6d34c Mon Sep 17 00:00:00 2001 From: Mikayla Thompson Date: Wed, 19 Jun 2024 11:49:12 -0600 Subject: [PATCH 4/5] Add tests Signed-off-by: Mikayla Thompson --- .../data/ecs_update_service_response.json | 567 ++++++++++++++++++ .../ecs_update_service_response_failed.json | 14 + .../lib/console_link/tests/test_backfill.py | 32 + .../lib/console_link/tests/test_ecs.py | 59 ++ 4 files changed, 672 insertions(+) create mode 100644 TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/tests/data/ecs_update_service_response.json create mode 100644 TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/tests/data/ecs_update_service_response_failed.json create mode 100644 TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/tests/test_ecs.py diff --git a/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/tests/data/ecs_update_service_response.json b/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/tests/data/ecs_update_service_response.json new file mode 100644 index 000000000..c49243cf5 --- /dev/null +++ b/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/tests/data/ecs_update_service_response.json @@ -0,0 +1,567 @@ +{ + "ResponseMetadata": { + "HTTPHeaders": { + "content-length": "18483", + "content-type": "application/x-amz-json-1.1", + "date": "Wed, 19 Jun 2024 16:19:27 GMT", + "x-amzn-requestid": "2840c6e1-4016-40b1-92c4-81537cc8fa44" + }, + "HTTPStatusCode": 200, + "RequestId": "2840c6e1-4016-40b1-92c4-81537cc8fa44", + "RetryAttempts": 0 + }, + "service": { + "clusterArn": "arn:aws:ecs:us-east-1:471142325910:cluster/migration-aws-integ-ecs-cluster", + "createdAt": "2024-05-29 17:31:13.749000+00:00", + "createdBy": "arn:aws:iam::471142325910:role/cdk-hnb659fds-cfn-exec-role-471142325910-us-east-1", + "deploymentConfiguration": { + "alarms": { + "alarmNames": [], + "enable": false, + "rollback": false + }, + "deploymentCircuitBreaker": { + "enable": false, + "rollback": false + }, + "maximumPercent": 200, + "minimumHealthyPercent": 50 + }, + "deploymentController": { + "type": "ECS" + }, + "deployments": [ + { + "createdAt": "2024-06-19 15:54:49.868000+00:00", + "desiredCount": 1, + "failedTasks": 0, + "id": "ecs-svc/4332894108537737212", + "launchType": "FARGATE", + "networkConfiguration": { + "awsvpcConfiguration": { + "assignPublicIp": "ENABLED", + "securityGroups": ["sg-0fddc78082979cda6", "sg-00593244fe8d01b08"], + "subnets": ["subnet-097061ef9615fbd90", "subnet-0aec1d00c07cdb30e"] + } + }, + "pendingCount": 0, + "platformFamily": "Linux", + "platformVersion": "1.4.0", + "rolloutState": "COMPLETED", + "rolloutStateReason": "ECS deployment ecs-svc/4332894108537737212 completed.", + "runningCount": 1, + "status": "PRIMARY", + "taskDefinition": "arn:aws:ecs:us-east-1:471142325910:task-definition/migration-aws-integ-reindex-from-snapshot:4", + "updatedAt": "2024-06-19 16:19:25.479000+00:00" + } + ], + "desiredCount": 1, + "enableECSManagedTags": false, + "enableExecuteCommand": true, + "events": [ + { + "createdAt": "2024-06-19 16:19:25.483000+00:00", + "id": "913b3431-6ece-483a-a49e-1c4b9820dec0", + "message": "(service migration-aws-integ-reindex-from-snapshot) has reached a steady state." + }, + { + "createdAt": "2024-06-19 16:18:47.606000+00:00", + "id": "ecf03c80-d019-4fb2-8b57-43e67e504dc9", + "message": "(service migration-aws-integ-reindex-from-snapshot) has started 1 tasks: (task c5d2b01595d0402bae5b640eca0c25e4)." + }, + { + "createdAt": "2024-06-19 16:10:10.205000+00:00", + "id": "7945d656-1068-4573-88f0-221cc5d1f170", + "message": "(service migration-aws-integ-reindex-from-snapshot) has reached a steady state." + }, + { + "createdAt": "2024-06-19 16:09:59.468000+00:00", + "id": "f426536a-af88-4207-a6c3-4bded882de07", + "message": "(service migration-aws-integ-reindex-from-snapshot) has stopped 1 running tasks: (task 1295f3854c8445e6a3d90da6f6f35950)." + }, + { + "createdAt": "2024-06-19 16:09:19.702000+00:00", + "id": "58a42acf-c36b-4899-8adf-cd37d9d8a33c", + "message": "(service migration-aws-integ-reindex-from-snapshot) has reached a steady state." + }, + { + "createdAt": "2024-06-19 16:08:42.512000+00:00", + "id": "b6915951-6d56-4071-a87b-17ef2e97a895", + "message": "(service migration-aws-integ-reindex-from-snapshot) has started 1 tasks: (task 1295f3854c8445e6a3d90da6f6f35950)." + }, + { + "createdAt": "2024-06-19 15:56:19.630000+00:00", + "id": "6bfe704a-70fb-4e3c-9d6b-5160176653f9", + "message": "(service migration-aws-integ-reindex-from-snapshot) has reached a steady state." + }, + { + "createdAt": "2024-06-19 15:56:19.629000+00:00", + "id": "9b046f6d-a219-4826-bac6-8939587758f8", + "message": "(service migration-aws-integ-reindex-from-snapshot) (deployment ecs-svc/4332894108537737212) deployment completed." + }, + { + "createdAt": "2024-06-19 13:47:02.613000+00:00", + "id": "260bb476-ea30-4be7-8816-ae781fd349bf", + "message": "(service migration-aws-integ-reindex-from-snapshot) has reached a steady state." + }, + { + "createdAt": "2024-06-19 07:46:35.705000+00:00", + "id": "a15e46b2-abfe-485c-8bdb-ea427e371137", + "message": "(service migration-aws-integ-reindex-from-snapshot) has reached a steady state." + }, + { + "createdAt": "2024-06-19 01:46:23.408000+00:00", + "id": "03f4d1af-de1e-4498-8efa-7a63a5da94f6", + "message": "(service migration-aws-integ-reindex-from-snapshot) has reached a steady state." + }, + { + "createdAt": "2024-06-18 19:46:04.533000+00:00", + "id": "2aeafb66-a93f-4d2a-8e21-25e6ed00f61a", + "message": "(service migration-aws-integ-reindex-from-snapshot) has reached a steady state." + }, + { + "createdAt": "2024-06-18 19:46:04.532000+00:00", + "id": "5ce256b3-8934-4252-b4c1-4be766c354df", + "message": "(service migration-aws-integ-reindex-from-snapshot) (deployment ecs-svc/1823067421084717411) deployment completed." + }, + { + "createdAt": "2024-06-18 16:12:19.912000+00:00", + "id": "f6e4dc27-0b78-43c5-a577-fde56a852368", + "message": "(service migration-aws-integ-reindex-from-snapshot) has reached a steady state." + }, + { + "createdAt": "2024-06-18 10:12:17.431000+00:00", + "id": "af8f0371-5999-4f9a-894a-6111ed8030fd", + "message": "(service migration-aws-integ-reindex-from-snapshot) has reached a steady state." + }, + { + "createdAt": "2024-06-18 04:12:15.234000+00:00", + "id": "cf98bcbf-b890-4c09-b925-df472393afa7", + "message": "(service migration-aws-integ-reindex-from-snapshot) has reached a steady state." + }, + { + "createdAt": "2024-06-17 22:11:56.393000+00:00", + "id": "470ea55c-a748-4494-adda-6906afb6d2aa", + "message": "(service migration-aws-integ-reindex-from-snapshot) has reached a steady state." + }, + { + "createdAt": "2024-06-17 16:11:37.783000+00:00", + "id": "6c21b174-24e2-4ce1-baa1-92f4309b547f", + "message": "(service migration-aws-integ-reindex-from-snapshot) has reached a steady state." + }, + { + "createdAt": "2024-06-17 10:11:32.280000+00:00", + "id": "033c4d7b-0cfd-484b-8850-135de660cae9", + "message": "(service migration-aws-integ-reindex-from-snapshot) has reached a steady state." + }, + { + "createdAt": "2024-06-17 04:11:18.007000+00:00", + "id": "1469fa55-448c-4740-ad31-ab5e88957e07", + "message": "(service migration-aws-integ-reindex-from-snapshot) has reached a steady state." + }, + { + "createdAt": "2024-06-16 22:11:04.236000+00:00", + "id": "17f7ed01-f0eb-4cd3-bb59-d16a6f8fd892", + "message": "(service migration-aws-integ-reindex-from-snapshot) has reached a steady state." + }, + { + "createdAt": "2024-06-16 16:10:59.345000+00:00", + "id": "d3685aa0-eb34-4efc-a7b9-d09502b95a2b", + "message": "(service migration-aws-integ-reindex-from-snapshot) has reached a steady state." + }, + { + "createdAt": "2024-06-16 10:10:38.988000+00:00", + "id": "01f040fc-fb3d-484a-b9b9-5d88da4822d3", + "message": "(service migration-aws-integ-reindex-from-snapshot) has reached a steady state." + }, + { + "createdAt": "2024-06-16 04:10:36.552000+00:00", + "id": "f7be3a5a-75cd-4dcf-915a-c5715d2df3de", + "message": "(service migration-aws-integ-reindex-from-snapshot) has reached a steady state." + }, + { + "createdAt": "2024-06-15 22:10:09.498000+00:00", + "id": "bf7395de-a163-4ff8-b269-84f873690b73", + "message": "(service migration-aws-integ-reindex-from-snapshot) has reached a steady state." + }, + { + "createdAt": "2024-06-15 16:09:56.312000+00:00", + "id": "2271d158-a50c-410f-bd74-054888af8256", + "message": "(service migration-aws-integ-reindex-from-snapshot) has reached a steady state." + }, + { + "createdAt": "2024-06-15 10:09:53.001000+00:00", + "id": "824c364f-5595-4124-b3d8-a6b7881df830", + "message": "(service migration-aws-integ-reindex-from-snapshot) has reached a steady state." + }, + { + "createdAt": "2024-06-15 04:09:48.108000+00:00", + "id": "74ceda60-cfa9-493e-acf0-84e094d9b7ee", + "message": "(service migration-aws-integ-reindex-from-snapshot) has reached a steady state." + }, + { + "createdAt": "2024-06-14 22:09:18.775000+00:00", + "id": "c8a0cc44-40d2-427d-87cd-c97aad6e90a1", + "message": "(service migration-aws-integ-reindex-from-snapshot) has reached a steady state." + }, + { + "createdAt": "2024-06-14 16:09:11.996000+00:00", + "id": "4ed8b158-0a44-4327-84ad-6ed6f9fd75b1", + "message": "(service migration-aws-integ-reindex-from-snapshot) has reached a steady state." + }, + { + "createdAt": "2024-06-14 10:09:01.292000+00:00", + "id": "001fb8bc-f21a-4321-a29a-3b58e930eb93", + "message": "(service migration-aws-integ-reindex-from-snapshot) has reached a steady state." + }, + { + "createdAt": "2024-06-14 04:08:45.412000+00:00", + "id": "c09d7462-c36a-4d7d-bd88-ed2ac462534d", + "message": "(service migration-aws-integ-reindex-from-snapshot) has reached a steady state." + }, + { + "createdAt": "2024-06-13 22:08:37.979000+00:00", + "id": "fba5d510-0fb1-4b51-8485-32268e357f7f", + "message": "(service migration-aws-integ-reindex-from-snapshot) has reached a steady state." + }, + { + "createdAt": "2024-06-13 16:08:23.583000+00:00", + "id": "b3cbff54-80e1-4c87-b307-987697d5d678", + "message": "(service migration-aws-integ-reindex-from-snapshot) has reached a steady state." + }, + { + "createdAt": "2024-06-13 10:08:22.975000+00:00", + "id": "57f2ceb0-0052-4dfa-809b-d86b380d3654", + "message": "(service migration-aws-integ-reindex-from-snapshot) has reached a steady state." + }, + { + "createdAt": "2024-06-13 04:08:12.714000+00:00", + "id": "f8ab6943-c988-43c0-aa63-43f739b3af6e", + "message": "(service migration-aws-integ-reindex-from-snapshot) has reached a steady state." + }, + { + "createdAt": "2024-06-12 22:07:43.073000+00:00", + "id": "717fedd8-936d-4b99-998e-2844c2290aa9", + "message": "(service migration-aws-integ-reindex-from-snapshot) has reached a steady state." + }, + { + "createdAt": "2024-06-12 16:07:32.376000+00:00", + "id": "c45b26e4-4f05-41e9-9559-7265d6e8e13f", + "message": "(service migration-aws-integ-reindex-from-snapshot) has reached a steady state." + }, + { + "createdAt": "2024-06-12 10:07:28.547000+00:00", + "id": "d248ff82-46b0-41f7-9c0a-e37448feb3b7", + "message": "(service migration-aws-integ-reindex-from-snapshot) has reached a steady state." + }, + { + "createdAt": "2024-06-12 04:07:25.705000+00:00", + "id": "d5982e76-3ef6-47ca-a113-7b5e6c3bd35a", + "message": "(service migration-aws-integ-reindex-from-snapshot) has reached a steady state." + }, + { + "createdAt": "2024-06-11 22:07:05.368000+00:00", + "id": "d8701c62-af19-49c7-88f3-85be35078cdd", + "message": "(service migration-aws-integ-reindex-from-snapshot) has reached a steady state." + }, + { + "createdAt": "2024-06-11 16:06:51.674000+00:00", + "id": "f9dc0be4-350e-46d1-8a89-497beab563bd", + "message": "(service migration-aws-integ-reindex-from-snapshot) has reached a steady state." + }, + { + "createdAt": "2024-06-11 10:06:45.604000+00:00", + "id": "ba2f74ce-b48f-426a-8c50-3820934b2bf7", + "message": "(service migration-aws-integ-reindex-from-snapshot) has reached a steady state." + }, + { + "createdAt": "2024-06-11 04:06:28.163000+00:00", + "id": "9eeab85f-0ebd-4221-8a03-4ec43b2341f8", + "message": "(service migration-aws-integ-reindex-from-snapshot) has reached a steady state." + }, + { + "createdAt": "2024-06-10 22:06:14.340000+00:00", + "id": "572cdb84-b5d9-4c74-8e16-2cfa76f63a14", + "message": "(service migration-aws-integ-reindex-from-snapshot) has reached a steady state." + }, + { + "createdAt": "2024-06-10 16:05:51.805000+00:00", + "id": "7008ce2b-4711-4002-9a81-fb42234add60", + "message": "(service migration-aws-integ-reindex-from-snapshot) has reached a steady state." + }, + { + "createdAt": "2024-06-10 10:05:42.154000+00:00", + "id": "7c934a87-e5a8-463c-b3f8-8136699f56f7", + "message": "(service migration-aws-integ-reindex-from-snapshot) has reached a steady state." + }, + { + "createdAt": "2024-06-10 04:05:39.584000+00:00", + "id": "9d8e1645-9b60-43ff-af4d-5466068831b0", + "message": "(service migration-aws-integ-reindex-from-snapshot) has reached a steady state." + }, + { + "createdAt": "2024-06-09 22:05:35.270000+00:00", + "id": "41ce2844-d4d9-45c5-ac4e-e960134eb971", + "message": "(service migration-aws-integ-reindex-from-snapshot) has reached a steady state." + }, + { + "createdAt": "2024-06-09 16:05:17.168000+00:00", + "id": "d08c7c91-ef8d-4359-8586-6f15719a4e7e", + "message": "(service migration-aws-integ-reindex-from-snapshot) has reached a steady state." + }, + { + "createdAt": "2024-06-09 10:04:55.374000+00:00", + "id": "f6681e33-8aa9-4bc3-93d8-10f427251695", + "message": "(service migration-aws-integ-reindex-from-snapshot) has reached a steady state." + }, + { + "createdAt": "2024-06-09 04:04:35.473000+00:00", + "id": "1298e4ef-6b8e-45cc-96ec-89d3330a6f76", + "message": "(service migration-aws-integ-reindex-from-snapshot) has reached a steady state." + }, + { + "createdAt": "2024-06-08 22:04:08.777000+00:00", + "id": "61f2ffc7-e6ec-4dc6-b0d5-d54fdf1302d1", + "message": "(service migration-aws-integ-reindex-from-snapshot) has reached a steady state." + }, + { + "createdAt": "2024-06-08 16:03:43.628000+00:00", + "id": "4c73f304-c7c0-4522-9bfa-9b14adb109d0", + "message": "(service migration-aws-integ-reindex-from-snapshot) has reached a steady state." + }, + { + "createdAt": "2024-06-08 10:03:32.576000+00:00", + "id": "2c387832-1981-4bbe-b00f-a64f8de22bfc", + "message": "(service migration-aws-integ-reindex-from-snapshot) has reached a steady state." + }, + { + "createdAt": "2024-06-08 04:03:17.288000+00:00", + "id": "f63e7d48-dfe4-4bd1-9c97-28eb75e1471b", + "message": "(service migration-aws-integ-reindex-from-snapshot) has reached a steady state." + }, + { + "createdAt": "2024-06-07 22:03:04.708000+00:00", + "id": "5b00aa6b-83a5-464f-877a-6ae740666a62", + "message": "(service migration-aws-integ-reindex-from-snapshot) has reached a steady state." + }, + { + "createdAt": "2024-06-07 16:02:38.750000+00:00", + "id": "29093286-5c28-4a56-b7a5-45fc4c92fd6f", + "message": "(service migration-aws-integ-reindex-from-snapshot) has reached a steady state." + }, + { + "createdAt": "2024-06-07 16:02:38.749000+00:00", + "id": "1e8f237d-a809-4065-97a3-3e64110db681", + "message": "(service migration-aws-integ-reindex-from-snapshot) (deployment ecs-svc/7249105888842962627) deployment completed." + }, + { + "createdAt": "2024-06-07 11:40:58.739000+00:00", + "id": "b802de6c-9493-45e4-b2cc-d89e2d453470", + "message": "(service migration-aws-integ-reindex-from-snapshot) has reached a steady state." + }, + { + "createdAt": "2024-06-07 05:40:35.339000+00:00", + "id": "658c7b8f-b1ff-4ac1-9434-4ec36950cb30", + "message": "(service migration-aws-integ-reindex-from-snapshot) has reached a steady state." + }, + { + "createdAt": "2024-06-06 23:40:14.582000+00:00", + "id": "73755b99-eaee-477a-bb82-41cc08c0d0b0", + "message": "(service migration-aws-integ-reindex-from-snapshot) has reached a steady state." + }, + { + "createdAt": "2024-06-06 17:39:49.271000+00:00", + "id": "fabf9485-c13b-4f4f-b5ee-cec7a967451f", + "message": "(service migration-aws-integ-reindex-from-snapshot) has reached a steady state." + }, + { + "createdAt": "2024-06-06 11:39:32.806000+00:00", + "id": "77a0fe9b-b238-40dd-b4ba-28785492960d", + "message": "(service migration-aws-integ-reindex-from-snapshot) has reached a steady state." + }, + { + "createdAt": "2024-06-06 05:39:09.298000+00:00", + "id": "73b74b61-d0c5-4abb-9fd7-350147cacd46", + "message": "(service migration-aws-integ-reindex-from-snapshot) has reached a steady state." + }, + { + "createdAt": "2024-06-05 23:38:49.829000+00:00", + "id": "5c4bbe3c-054f-4196-b26f-ea6bb24f0c18", + "message": "(service migration-aws-integ-reindex-from-snapshot) has reached a steady state." + }, + { + "createdAt": "2024-06-05 17:38:47.104000+00:00", + "id": "20f3bace-e3fe-4e5b-901f-823fa94df36a", + "message": "(service migration-aws-integ-reindex-from-snapshot) has reached a steady state." + }, + { + "createdAt": "2024-06-05 11:38:26.438000+00:00", + "id": "2a595421-e8ea-4f4e-8431-ad4f7e7b1761", + "message": "(service migration-aws-integ-reindex-from-snapshot) has reached a steady state." + }, + { + "createdAt": "2024-06-05 05:37:59.915000+00:00", + "id": "a3b7269e-b32a-4c50-9027-fddd5f7bc818", + "message": "(service migration-aws-integ-reindex-from-snapshot) has reached a steady state." + }, + { + "createdAt": "2024-06-04 23:37:40.906000+00:00", + "id": "5e929df6-afc1-441a-88b3-fda16b31c121", + "message": "(service migration-aws-integ-reindex-from-snapshot) has reached a steady state." + }, + { + "createdAt": "2024-06-04 17:37:40.419000+00:00", + "id": "5a480cf9-11bb-4aed-a1d3-813e397abc24", + "message": "(service migration-aws-integ-reindex-from-snapshot) has reached a steady state." + }, + { + "createdAt": "2024-06-04 11:37:39.838000+00:00", + "id": "34d28889-cddf-49e7-b19b-0ce2a124ad1b", + "message": "(service migration-aws-integ-reindex-from-snapshot) has reached a steady state." + }, + { + "createdAt": "2024-06-04 05:37:24.080000+00:00", + "id": "a8085905-3bf9-4fda-99e5-0a8633691c9d", + "message": "(service migration-aws-integ-reindex-from-snapshot) has reached a steady state." + }, + { + "createdAt": "2024-06-03 23:37:01.533000+00:00", + "id": "cc56ca8f-400d-425a-98d5-929079e44241", + "message": "(service migration-aws-integ-reindex-from-snapshot) has reached a steady state." + }, + { + "createdAt": "2024-06-03 17:36:47.040000+00:00", + "id": "0b5b31a3-4f02-42f0-b982-221a6f777946", + "message": "(service migration-aws-integ-reindex-from-snapshot) has reached a steady state." + }, + { + "createdAt": "2024-06-03 11:36:39.939000+00:00", + "id": "b0d088de-880b-41a8-bc82-0099a97628f0", + "message": "(service migration-aws-integ-reindex-from-snapshot) has reached a steady state." + }, + { + "createdAt": "2024-06-03 05:36:13.177000+00:00", + "id": "534fa9ea-bf8c-474e-a19a-93ddbc9122c1", + "message": "(service migration-aws-integ-reindex-from-snapshot) has reached a steady state." + }, + { + "createdAt": "2024-06-02 23:35:46.478000+00:00", + "id": "a9915d4c-8107-475a-a210-48cf599f3b3a", + "message": "(service migration-aws-integ-reindex-from-snapshot) has reached a steady state." + }, + { + "createdAt": "2024-06-02 17:35:30.908000+00:00", + "id": "318305be-d041-41be-ad55-136ff96359cd", + "message": "(service migration-aws-integ-reindex-from-snapshot) has reached a steady state." + }, + { + "createdAt": "2024-06-02 11:35:16.995000+00:00", + "id": "f8d919d3-cfab-40df-8e52-ecb5f6afef3f", + "message": "(service migration-aws-integ-reindex-from-snapshot) has reached a steady state." + }, + { + "createdAt": "2024-06-02 05:34:56.590000+00:00", + "id": "e57c998f-ddd2-44be-b375-ea21371207f2", + "message": "(service migration-aws-integ-reindex-from-snapshot) has reached a steady state." + }, + { + "createdAt": "2024-06-01 23:34:27.703000+00:00", + "id": "4b1cf356-39f1-4bfc-aea9-6032ceebda60", + "message": "(service migration-aws-integ-reindex-from-snapshot) has reached a steady state." + }, + { + "createdAt": "2024-06-01 17:34:12.779000+00:00", + "id": "65a5bed0-d080-4adb-8583-1720316edd77", + "message": "(service migration-aws-integ-reindex-from-snapshot) has reached a steady state." + }, + { + "createdAt": "2024-06-01 11:34:08.100000+00:00", + "id": "9871eafe-93e6-4f4a-8086-6b800bb66265", + "message": "(service migration-aws-integ-reindex-from-snapshot) has reached a steady state." + }, + { + "createdAt": "2024-06-01 05:33:47.446000+00:00", + "id": "b8ba0809-122f-4059-8e0a-dc4eac3c9ab8", + "message": "(service migration-aws-integ-reindex-from-snapshot) has reached a steady state." + }, + { + "createdAt": "2024-05-31 23:33:24.652000+00:00", + "id": "952e7ac5-c3b5-472b-949d-0fd4165e5f7f", + "message": "(service migration-aws-integ-reindex-from-snapshot) has reached a steady state." + }, + { + "createdAt": "2024-05-31 17:33:01.126000+00:00", + "id": "3f91d3b7-1609-4475-b21d-734559d2b179", + "message": "(service migration-aws-integ-reindex-from-snapshot) has reached a steady state." + }, + { + "createdAt": "2024-05-31 11:32:59.735000+00:00", + "id": "10f45e3a-6c3d-43a1-be35-cba71a6be1ff", + "message": "(service migration-aws-integ-reindex-from-snapshot) has reached a steady state." + }, + { + "createdAt": "2024-05-31 05:32:42.652000+00:00", + "id": "f4c655d9-f4ed-464f-b7a1-fc1bc58aa8fd", + "message": "(service migration-aws-integ-reindex-from-snapshot) has reached a steady state." + }, + { + "createdAt": "2024-05-30 23:32:35.748000+00:00", + "id": "e79a70a8-4101-4d63-9fdf-32260f428efb", + "message": "(service migration-aws-integ-reindex-from-snapshot) has reached a steady state." + }, + { + "createdAt": "2024-05-30 17:32:32.813000+00:00", + "id": "ae0db7b1-7e87-4550-97f9-4221f63a73f8", + "message": "(service migration-aws-integ-reindex-from-snapshot) has reached a steady state." + }, + { + "createdAt": "2024-05-30 11:32:26.824000+00:00", + "id": "c604b4c7-2d09-4765-b8fe-7ebb5fba2302", + "message": "(service migration-aws-integ-reindex-from-snapshot) has reached a steady state." + }, + { + "createdAt": "2024-05-30 05:32:10.592000+00:00", + "id": "d61220da-361f-456a-891a-382e9f9f06d4", + "message": "(service migration-aws-integ-reindex-from-snapshot) has reached a steady state." + }, + { + "createdAt": "2024-05-29 23:31:46.211000+00:00", + "id": "b2f65334-f241-4bc6-bf43-8e88d29dc9a8", + "message": "(service migration-aws-integ-reindex-from-snapshot) has reached a steady state." + }, + { + "createdAt": "2024-05-29 17:31:23.638000+00:00", + "id": "9aee290b-fede-4630-9b55-479578bf31d0", + "message": "(service migration-aws-integ-reindex-from-snapshot) has reached a steady state." + }, + { + "createdAt": "2024-05-29 17:31:23.637000+00:00", + "id": "eb278b88-281b-4838-b004-726408358a2f", + "message": "(service migration-aws-integ-reindex-from-snapshot) (deployment ecs-svc/0466178102158678106) deployment completed." + } + ], + "launchType": "FARGATE", + "loadBalancers": [], + "networkConfiguration": { + "awsvpcConfiguration": { + "assignPublicIp": "ENABLED", + "securityGroups": ["sg-0fddc78082979cda6", "sg-00593244fe8d01b08"], + "subnets": ["subnet-097061ef9615fbd90", "subnet-0aec1d00c07cdb30e"] + } + }, + "pendingCount": 0, + "placementConstraints": [], + "placementStrategy": [], + "platformFamily": "Linux", + "platformVersion": "LATEST", + "propagateTags": "NONE", + "roleArn": "arn:aws:iam::471142325910:role/aws-service-role/ecs.amazonaws.com/AWSServiceRoleForECS", + "runningCount": 1, + "schedulingStrategy": "REPLICA", + "serviceArn": "arn:aws:ecs:us-east-1:471142325910:service/migration-aws-integ-ecs-cluster/migration-aws-integ-reindex-from-snapshot", + "serviceName": "migration-aws-integ-reindex-from-snapshot", + "serviceRegistries": [], + "status": "ACTIVE", + "taskDefinition": "arn:aws:ecs:us-east-1:471142325910:task-definition/migration-aws-integ-reindex-from-snapshot:4" + } +} diff --git a/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/tests/data/ecs_update_service_response_failed.json b/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/tests/data/ecs_update_service_response_failed.json new file mode 100644 index 000000000..8adc91bd8 --- /dev/null +++ b/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/tests/data/ecs_update_service_response_failed.json @@ -0,0 +1,14 @@ +{ + "ResponseMetadata": { + "HTTPHeaders": { + "content-length": "18483", + "content-type": "application/x-amz-json-1.1", + "date": "Wed, 19 Jun 2024 16:19:27 GMT", + "x-amzn-requestid": "2840c6e1-4016-40b1-92c4-81537cc8fa44" + }, + "HTTPStatusCode": 400, + "RequestId": "2840c6e1-4016-40b1-92c4-81537cc8fa44", + "RetryAttempts": 0 + }, + "service": {} +} diff --git a/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/tests/test_backfill.py b/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/tests/test_backfill.py index 6d54de2b7..e85ef8681 100644 --- a/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/tests/test_backfill.py +++ b/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/tests/test_backfill.py @@ -6,6 +6,7 @@ from console_link.models.backfill_base import Backfill from console_link.models.backfill_osi import OpenSearchIngestionBackfill from console_link.models.backfill_rfs import DockerRFSBackfill, ECSRFSBackfill +from console_link.models.ecs_service import ECSService from tests.utils import create_valid_cluster @@ -13,6 +14,19 @@ AWS_REGION = "us-east-1" +@pytest.fixture +def ecs_rfs_backfill(): + ecs_rfs_config = { + "reindex_from_snapshot": { + "ecs": { + "cluster_name": "migration-aws-integ-ecs-cluster", + "service_name": "migration-aws-integ-reindex-from-snapshot" + } + } + } + return get_backfill(ecs_rfs_config, None, target_cluster=create_valid_cluster()) + + def test_get_backfill_valid_osi(): osi_config = { "opensearch_ingestion": { @@ -141,3 +155,21 @@ def test_cant_instantiate_with_multiple_rfs_deployment_types(): get_backfill(config, create_valid_cluster(), create_valid_cluster()) assert "Invalid config file for RFS backfill" in str(excinfo.value.args[0]) assert "More than one value is present" in str(excinfo.value.args[1]['reindex_from_snapshot'][0]) + + +def test_ecs_rfs_backfill_start_sets_ecs_desired_count(ecs_rfs_backfill, mocker): + assert ecs_rfs_backfill.default_scale == 1 + mock = mocker.patch.object(ECSService, 'set_desired_count', autospec=True) + ecs_rfs_backfill.start() + + assert isinstance(ecs_rfs_backfill, ECSRFSBackfill) + mock.assert_called_once_with(ecs_rfs_backfill.ecs_client, 1) + + +def test_ecs_rfs_backfill_stop_sets_ecs_desired_count(ecs_rfs_backfill, mocker): + assert ecs_rfs_backfill.default_scale == 1 + mock = mocker.patch.object(ECSService, 'set_desired_count', autospec=True) + ecs_rfs_backfill.stop() + + assert isinstance(ecs_rfs_backfill, ECSRFSBackfill) + mock.assert_called_once_with(ecs_rfs_backfill.ecs_client, 0) diff --git a/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/tests/test_ecs.py b/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/tests/test_ecs.py new file mode 100644 index 000000000..5678cdfa6 --- /dev/null +++ b/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/tests/test_ecs.py @@ -0,0 +1,59 @@ +import json +import pathlib + +import pytest + +import botocore.session +from botocore.stub import Stubber + +from console_link.models.utils import AWSAPIError +from console_link.models.ecs_service import ECSService + +TEST_DATA_DIRECTORY = pathlib.Path(__file__).parent / "data" +AWS_REGION = "us-east-1" + + +@pytest.fixture +def ecs_stubber(): + cw_session = botocore.session.get_session().create_client("ecs", region_name=AWS_REGION) + stubber = Stubber(cw_session) + return stubber + + +@pytest.fixture +def ecs_service(): + return ECSService("migration-aws-integ-ecs-cluster", + "migration-aws-integ-reindex-from-snapshot", + AWS_REGION) + + +def test_ecs_created_with_and_without_region(): + with_region = ECSService("cluster_name", "service_name", AWS_REGION) + assert isinstance(with_region, ECSService) + assert with_region.client is not None + + without_region = ECSService("cluster_name", "service_name") + assert isinstance(without_region, ECSService) + assert without_region.client is not None + + +def test_ecs_update_service_succesful(ecs_stubber, ecs_service): + with open(TEST_DATA_DIRECTORY / "ecs_update_service_response.json") as f: + ecs_stubber.add_response("update_service", json.load(f)) + ecs_stubber.activate() + + ecs_service.client = ecs_stubber.client + result = ecs_service.set_desired_count(1) + assert result.success is True + assert result.value is not None + + +def test_ecs_update_service_unsuccessful(ecs_stubber, ecs_service): + with open(TEST_DATA_DIRECTORY / "ecs_update_service_response_failed.json") as f: + ecs_stubber.add_response("update_service", json.load(f)) + ecs_stubber.activate() + + ecs_service.client = ecs_stubber.client + result = ecs_service.set_desired_count(1) + assert result.success is False + assert isinstance(result.value, AWSAPIError) From 729049e0f0ada9b7559a7057c52804f5c9cd1617 Mon Sep 17 00:00:00 2001 From: Mikayla Thompson Date: Wed, 19 Jun 2024 12:29:30 -0600 Subject: [PATCH 5/5] Fix exit code handling Signed-off-by: Mikayla Thompson --- .../lib/console_link/console_link/cli.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/cli.py b/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/cli.py index 1f6daa43d..281970489 100644 --- a/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/cli.py +++ b/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/cli.py @@ -4,6 +4,7 @@ import console_link.logic.clusters as logic_clusters import console_link.logic.metrics as logic_metrics import console_link.logic.backfill as logic_backfill +from console_link.logic.backfill import ExitCode from console_link.environment import Environment from console_link.models.metrics_source import Component, MetricStatistic import logging @@ -116,7 +117,7 @@ def create_backfill_cmd(ctx, pipeline_template_file, print_config_only): exitcode, message = logic_backfill.create(ctx.env.backfill, pipeline_template_path=pipeline_template_file, print_config_only=print_config_only) - if exitcode != 0: + if exitcode != ExitCode.SUCCESS: raise click.ClickException(message) click.echo(message) @@ -126,7 +127,7 @@ def create_backfill_cmd(ctx, pipeline_template_file, print_config_only): @click.pass_obj def start_backfill_cmd(ctx, pipeline_name): exitcode, message = logic_backfill.start(ctx.env.backfill, pipeline_name=pipeline_name) - if exitcode != 0: + if exitcode != ExitCode.SUCCESS: raise click.ClickException(message) click.echo(message) @@ -136,7 +137,7 @@ def start_backfill_cmd(ctx, pipeline_name): @click.pass_obj def stop_backfill_cmd(ctx, pipeline_name): exitcode, message = logic_backfill.stop(ctx.env.backfill, pipeline_name=pipeline_name) - if exitcode != 0: + if exitcode != ExitCode.SUCCESS: raise click.ClickException(message) click.echo(message) @@ -146,7 +147,7 @@ def stop_backfill_cmd(ctx, pipeline_name): @click.pass_obj def scale_backfill_cmd(ctx, units: int): exitcode, message = logic_backfill.scale(ctx.env.backfill, units) - if exitcode != 0: + if exitcode != ExitCode.SUCCESS: raise click.ClickException(message) click.echo(message) @@ -155,7 +156,7 @@ def scale_backfill_cmd(ctx, units: int): @click.pass_obj def status_backfill_cmd(ctx): exitcode, message = logic_backfill.status(ctx.env.backfill) - if exitcode != 0: + if exitcode != ExitCode.SUCCESS: raise click.ClickException(message) click.echo(message)