Skip to content

Commit

Permalink
Merge pull request #24 from DNXLabs/fix/error-msg
Browse files Browse the repository at this point in the history
Fix/error msg
  • Loading branch information
lgothelipe authored May 30, 2023
2 parents d5110d4 + e544505 commit 7de7e79
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 27 deletions.
11 changes: 5 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
FROM dnxsolutions/aws:1.22.48-dnx2
FROM dnxsolutions/aws:2.1.9-dnx1

WORKDIR /work

COPY src .

# RUN apk add libcurl=7.79.1-r5 \
# && apk add curl=7.79.1-r5 \
# && apk add git=2.32.6-r0 \
# && apk add python3=3.9.16-r0 \
# && apk add python3-dev=3.9.16-r0
RUN python3 -m pip install --no-cache-dir pip==23.1.2 \
&& pip install --no-cache-dir awscli==1.27.142 \
&& pip install --no-cache-dir botocore==1.29.142 \
&& pip install --no-cache-dir boto3==1.26.142

ENTRYPOINT [ "python3", "-u" ]

Expand Down
41 changes: 20 additions & 21 deletions src/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,16 @@
# deploy.status
deploy.get_deployment(deploy.deploymentId)

while deploy.status in ['Created', 'InProgress']:
def stop_deploy(deployment_id):
try:
deploy.stop_deployment(deployment_id)
print('Rollback deployment success')
except:
print('Rollback deployment failed')
finally:
exit(1)

while deploy.status in ['Created', 'InProgress', 'Queued']:
# Tail logs from ECS service
ecs_events = task.tail_ecs_events(cluster_name, app_name)
for event in ecs_events:
Expand All @@ -133,24 +142,12 @@

if last_task_status == 'STOPPED':
print('Containers are being stoped: %s' % last_task_reason)
try:
deploy.stop_deployment(deploy.deploymentId)
print('Rollback deployment success')
except:
print('Rollback deployment failed')
finally:
exit(1)
stop_deploy(deploy.deploymentId)

# Rechead limit
if deploy_timeout_period >= deploy_timeout:
print('Deployment timeout: %s seconds' % deploy_timeout)
try:
deploy.stop_deployment(deploy.deploymentId)
print('Rollback deployment success')
except:
print('Rollback deployment failed')
finally:
exit(1)
stop_deploy(deploy.deploymentId)

# Get status, increment limit and sleep
deploy.get_deployment(deploy.deploymentId)
Expand All @@ -161,13 +158,15 @@
deployment_info = deploy.get_deployment(deploy.deploymentId)

print()
if deploy.status not in ['Ready', 'Succeeded']:
print('Deployment failed: %s' % deployment_info['deploymentInfo']['errorInformation']['code'])
print('Error: %s' % deployment_info['deploymentInfo']['errorInformation']['message'])

if deploy.status == "Ready":
print('Deployment of application %s on deployment group %s ready and waiting for cutover' % (application_name, deployment_group))

exit(0)

if deploy.status == "Succeeded":
print('Deployment of application %s on deployment group %s succeeded' % (application_name, deployment_group))

exit(0)

if deployment_info.get('deploymentInfo', {}).get('errorInformation'):
print('Deployment failed: %s' % deployment_info.get('deploymentInfo', {}).get('errorInformation', {}).get('code'))
print('Error: %s' % deployment_info.get('deploymentInfo', {}).get('errorInformation', {}).get('message'))
exit(1)

0 comments on commit 7de7e79

Please sign in to comment.