Skip to content

Commit 7de7e79

Browse files
authored
Merge pull request #24 from DNXLabs/fix/error-msg
Fix/error msg
2 parents d5110d4 + e544505 commit 7de7e79

File tree

2 files changed

+25
-27
lines changed

2 files changed

+25
-27
lines changed

Dockerfile

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
FROM dnxsolutions/aws:1.22.48-dnx2
1+
FROM dnxsolutions/aws:2.1.9-dnx1
22

33
WORKDIR /work
44

55
COPY src .
66

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

1312
ENTRYPOINT [ "python3", "-u" ]
1413

src/deploy.py

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,16 @@
118118
# deploy.status
119119
deploy.get_deployment(deploy.deploymentId)
120120

121-
while deploy.status in ['Created', 'InProgress']:
121+
def stop_deploy(deployment_id):
122+
try:
123+
deploy.stop_deployment(deployment_id)
124+
print('Rollback deployment success')
125+
except:
126+
print('Rollback deployment failed')
127+
finally:
128+
exit(1)
129+
130+
while deploy.status in ['Created', 'InProgress', 'Queued']:
122131
# Tail logs from ECS service
123132
ecs_events = task.tail_ecs_events(cluster_name, app_name)
124133
for event in ecs_events:
@@ -133,24 +142,12 @@
133142

134143
if last_task_status == 'STOPPED':
135144
print('Containers are being stoped: %s' % last_task_reason)
136-
try:
137-
deploy.stop_deployment(deploy.deploymentId)
138-
print('Rollback deployment success')
139-
except:
140-
print('Rollback deployment failed')
141-
finally:
142-
exit(1)
145+
stop_deploy(deploy.deploymentId)
143146

144147
# Rechead limit
145148
if deploy_timeout_period >= deploy_timeout:
146149
print('Deployment timeout: %s seconds' % deploy_timeout)
147-
try:
148-
deploy.stop_deployment(deploy.deploymentId)
149-
print('Rollback deployment success')
150-
except:
151-
print('Rollback deployment failed')
152-
finally:
153-
exit(1)
150+
stop_deploy(deploy.deploymentId)
154151

155152
# Get status, increment limit and sleep
156153
deploy.get_deployment(deploy.deploymentId)
@@ -161,13 +158,15 @@
161158
deployment_info = deploy.get_deployment(deploy.deploymentId)
162159

163160
print()
164-
if deploy.status not in ['Ready', 'Succeeded']:
165-
print('Deployment failed: %s' % deployment_info['deploymentInfo']['errorInformation']['code'])
166-
print('Error: %s' % deployment_info['deploymentInfo']['errorInformation']['message'])
167-
168161
if deploy.status == "Ready":
169162
print('Deployment of application %s on deployment group %s ready and waiting for cutover' % (application_name, deployment_group))
170-
163+
exit(0)
164+
171165
if deploy.status == "Succeeded":
172166
print('Deployment of application %s on deployment group %s succeeded' % (application_name, deployment_group))
173-
167+
exit(0)
168+
169+
if deployment_info.get('deploymentInfo', {}).get('errorInformation'):
170+
print('Deployment failed: %s' % deployment_info.get('deploymentInfo', {}).get('errorInformation', {}).get('code'))
171+
print('Error: %s' % deployment_info.get('deploymentInfo', {}).get('errorInformation', {}).get('message'))
172+
exit(1)

0 commit comments

Comments
 (0)