-
Notifications
You must be signed in to change notification settings - Fork 18
fix(update_service): fixes TaskDefinition inactive exception #135
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
Open
rokibulislaam
wants to merge
3
commits into
GetSimpl:master
Choose a base branch
from
rokibulislaam:fix/TaskDefinition-inactive-error
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -46,4 +46,12 @@ def check_aws_instance_type(instance_type): | |
| continue | ||
| else: | ||
| return False, i | ||
| return True, "" | ||
| return True, "" | ||
|
|
||
| def service_update_preflight_checks(current_version, service_name, environment, ecr_client): | ||
| # If the current deployment is considered dirty, make sure that an image tagged as 'master' is uploaded to ECR otherwise on service update, the service will try to use an image tagged as 'master' which does not exist | ||
| if current_version == 'dirty': | ||
| repo_name = service_name + '-repo' | ||
| res = ecr_client.batch_get_image(repositoryName=repo_name, imageIds=[{'imageTag': 'master'}]) | ||
| if res['images'] == []: | ||
| raise UnrecoverableException("Current deployment is dirty. Please push an image tagged as 'master' to ECR.") | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Need to add cloudlift specific command to push to ecr. This can be done with |
||
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -15,7 +15,8 @@ | |
| from cloudlift.config.logging import log, log_bold, log_err | ||
| from cloudlift.deployment.progress import get_stack_events, print_new_events | ||
| from cloudlift.deployment.service_template_generator import ServiceTemplateGenerator | ||
|
|
||
| from cloudlift.deployment.service_information_fetcher import ServiceInformationFetcher | ||
| from cloudlift.config.pre_flight import service_update_preflight_checks | ||
|
|
||
| class ServiceCreator(object): | ||
| ''' | ||
|
|
@@ -29,6 +30,7 @@ def __init__(self, name, environment): | |
| self.stack_name = get_service_stack_name(environment, name) | ||
| self.client = get_client_for('cloudformation', self.environment) | ||
| self.s3client = get_client_for('s3', self.environment) | ||
| self.ecrClient = get_client_for('ecr', self.environment) | ||
| self.bucket_name = 'cloudlift-service-template' | ||
| self.environment_stack = self._get_environment_stack() | ||
| self.existing_events = get_stack_events(self.client, self.stack_name) | ||
|
|
@@ -106,6 +108,9 @@ def update(self): | |
| ''' | ||
|
|
||
| log_bold("Starting to update service") | ||
| current_version = ServiceInformationFetcher( | ||
| self.name, self.environment).get_current_version(skip_master_reset=True) | ||
| service_update_preflight_checks(current_version=current_version, service_name=self.name, environment=self.environment, ecr_client=self.ecrClient) | ||
| self.service_configuration.edit_config() | ||
| try: | ||
| template_generator = ServiceTemplateGenerator( | ||
|
|
@@ -164,4 +169,4 @@ def _print_progress(self): | |
| if "FAIL" in final_status: | ||
| log_err("Finished with status: %s" % (final_status)) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should emit a non-zero exit code |
||
| else: | ||
| log_bold("Finished with status: %s" % (final_status)) | ||
| log_bold("Finished with status: %s" % (final_status)) | ||
This file contains hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On further thought, we should just bail stating that the current deployment is dirty and that an update cannot be made.