Skip to content

Commit bc7b883

Browse files
BCDA-9586: Adjust workflows for prod fargate (#1279)
1 parent 8ae8e39 commit bc7b883

File tree

1 file changed

+7
-62
lines changed

1 file changed

+7
-62
lines changed

.github/workflows/deploy-all.yml

Lines changed: 7 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ jobs:
152152
text: "Started deploy to ${{ env.RELEASE_ENV }} (run: <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|${{ github.run_id }}>)."
153153
mrkdown_in:
154154
- text
155+
# FARGATE FIXUP: Can remove this step
155156
- name: Get AMIs
156157
run: |
157158
export BCDA_AMI=`aws ec2 describe-images --region ${{ vars.AWS_REGION }} --filters 'Name=tag:app,Values=bcda-app' 'Name=tag:version,Values=${{ env.RELEASE_VERSION }}' --query 'Images[*][CreationDate,ImageId] | reverse(sort_by(@,&[0])) | [0][1]' --output text`
@@ -163,8 +164,6 @@ jobs:
163164
- name: Install tenv
164165
uses: cmsgov/cdap/actions/setup-tenv@8343fb96563ce4b74c4dececee9b268f42bd4a40
165166
- name: Init, Plan OpenTofu
166-
# FARGATE FIXUP: adding fargate vars to tf plan
167-
if: ${{ env.RELEASE_ENV != 'prod' }}
168167
working-directory: terraform/${{ env.RELEASE_ENV }}
169168
run: |
170169
IFS=":@" read -r -a STRS <<< ${{ env.DATABASE_URL }}
@@ -180,35 +179,11 @@ jobs:
180179
-var 'worker_image_tag=${{ env.RELEASE_VERSION }}' \
181180
-var 'fargate_switch={start_ec2=false, start_fargate=true, fargate_traffic=100}' \
182181
-out 'bcda-release-api-worker.tfplan'
183-
- name: Init, Plan OpenTofu
184-
# FARGATE FIXUP: adding fargate vars to tf plan
185-
if: ${{ env.RELEASE_ENV == 'prod' }}
186-
working-directory: terraform/${{ env.RELEASE_ENV }}
187-
run: |
188-
IFS=":@" read -r -a STRS <<< ${{ env.DATABASE_URL }}
189-
export APP_DB_PW=${STRS[2]}
190-
tofu init
191-
tofu plan \
192-
-var 'env=${{ env.RELEASE_ENV }}' \
193-
-var 'ami_id=${{ env.BCDA_AMI }}' \
194-
-var 'worker_ami_id=${{ env.WORKER_AMI }}' \
195-
-var 'instance_type=${{ vars.INSTANCE_CLASS }}' \
196-
-out 'bcda-release-api-worker.tfplan'
197182
- name: OpenTofu Apply
198183
working-directory: terraform/${{ env.RELEASE_ENV }}
199184
run: |
200185
tofu apply bcda-release-api-worker.tfplan
201-
- name: Refresh AutoScaling Groups
202-
# FARGATE FIXUP:
203-
if: ${{ env.RELEASE_ENV == 'prod' }}
204-
run: |
205-
export ASG=`aws autoscaling describe-auto-scaling-groups --region ${{ vars.AWS_REGION }} --filters "Name=tag:Name,Values=bcda-${{ env.RELEASE_ENV }}-api" --query 'AutoScalingGroups[0].AutoScalingGroupName' --output text`
206-
aws autoscaling start-instance-refresh --region ${{ vars.AWS_REGION }} --auto-scaling-group-name ${ASG}
207-
export WORKER_ASG=`aws autoscaling describe-auto-scaling-groups --region ${{ vars.AWS_REGION }} --filters "Name=tag:Name,Values=bcda-${{ env.RELEASE_ENV }}-worker" --query 'AutoScalingGroups[0].AutoScalingGroupName' --output text`
208-
aws autoscaling start-instance-refresh --region ${{ vars.AWS_REGION }} --auto-scaling-group-name ${WORKER_ASG}
209186
- name: Refresh Deployments
210-
# FARGATE FIXUP:
211-
if: ${{ env.RELEASE_ENV != 'prod' }}
212187
run: |
213188
aws ecs update-service --cluster bcda-${{ env.RELEASE_ENV }} --service bcda-${{ env.RELEASE_ENV }}-api --force-new-deployment
214189
aws ecs update-service --cluster bcda-${{ env.RELEASE_ENV }} --service bcda-${{ env.RELEASE_ENV }}-ssas --force-new-deployment
@@ -267,40 +242,8 @@ jobs:
267242
fi
268243
done
269244
270-
# FARGATE FIXUP: can remove this in favor of below check
271-
verify_worker_version:
272-
needs: [deploy]
273-
runs-on: codebuild-bcda-app-${{github.run_id}}-${{github.run_attempt}}
274-
environment: ${{ inputs.env != '0' && inputs.env || 'dev' }}
275-
steps:
276-
- uses: aws-actions/configure-aws-credentials@v4
277-
with:
278-
aws-region: ${{ vars.AWS_REGION }}
279-
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/delegatedadmin/developer/${{ vars.AWS_ROLE_TO_ASSUME }}
280-
- run: |
281-
TRY=1
282-
283-
until [ $TRY -gt $VERIFICATION_RETRIES ]; do
284-
export IMAGE_ID=`aws ec2 describe-instances --region ${{ vars.AWS_REGION }} --filters 'Name=tag:Name,Values=bcda-${{ env.RELEASE_ENV }}-worker' 'Name=instance-state-name,Values=running' --query 'Reservations[0].Instances[*][LaunchTime,ImageId] | reverse(sort_by(@,&[0])) | [0][1]' --output text`
285-
# Was unable to escape the backticks (`), creating this function seems to get around that
286-
get_image_version () {
287-
aws ec2 describe-images --region ${{ vars.AWS_REGION }} --image-ids ${IMAGE_ID} --query 'Images[0].Tags[?Key==`version`].Value' --output text
288-
}
289-
export BCDA_WORKER_VERSION=`get_image_version`
290-
291-
if [[ $BCDA_WORKER_VERSION != ${{ env.RELEASE_VERSION }} ]]; then
292-
echo "BCDA Worker expected release version: ${{ env.RELEASE_VERSION }} did not match aws version found: ${BCDA_WORKER_VERSION}."
293-
TRY=$(($TRY + 1))
294-
if [ $TRY -gt $VERIFICATION_RETRIES ]; then
295-
exit 1
296-
else
297-
sleep $VERIFICATION_SLEEP
298-
fi
299-
else
300-
break
301-
fi
302-
done
303-
245+
# Temporarily we need to manually verify worker is on correct version
246+
304247
# # FARGATE FIXUP:
305248
# This needs the 'image_tag' tag to be added to each service before this will work
306249
# verify_worker_version:
@@ -332,7 +275,8 @@ jobs:
332275
# done
333276

334277
smoketests:
335-
needs: [migrate_db, migrate_ssas_db, deploy, verify_api_version, verify_ssas_version, verify_worker_version]
278+
# needs: [migrate_db, migrate_ssas_db, deploy, verify_api_version, verify_ssas_version, verify_worker_version]
279+
needs: [migrate_db, migrate_ssas_db, deploy, verify_api_version, verify_ssas_version]
336280
uses: ./.github/workflows/smoke-tests.yml
337281
with:
338282
release_version: ${{ inputs.release_version || 'main' }}
@@ -345,7 +289,8 @@ jobs:
345289
secrets: inherit
346290

347291
notify_newrelic:
348-
needs: [migrate_db, migrate_ssas_db, deploy, verify_api_version, verify_ssas_version, verify_worker_version]
292+
# needs: [migrate_db, migrate_ssas_db, deploy, verify_api_version, verify_ssas_version, verify_worker_version]
293+
needs: [migrate_db, migrate_ssas_db, deploy, verify_api_version, verify_ssas_version]
349294
environment: ${{ inputs.env || 'dev' }}
350295
runs-on: codebuild-bcda-app-${{github.run_id}}-${{github.run_attempt}}
351296
steps:

0 commit comments

Comments
 (0)