-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Console] Implement start/stop for RFS backfill on ECS (#740)
* Clean up handling of CommandResults Signed-off-by: Mikayla Thompson <[email protected]> * Move the aws utils Signed-off-by: Mikayla Thompson <[email protected]> * Add ECS service and implement rfs start/stop Signed-off-by: Mikayla Thompson <[email protected]> * Add tests Signed-off-by: Mikayla Thompson <[email protected]> * Fix exit code handling Signed-off-by: Mikayla Thompson <[email protected]> --------- Signed-off-by: Mikayla Thompson <[email protected]>
- Loading branch information
1 parent
aee343f
commit 39cf3b7
Showing
12 changed files
with
753 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
...tion/src/main/docker/migrationConsole/lib/console_link/console_link/models/ecs_service.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.