Skip to content

Commit

Permalink
Merge pull request #188 from openinfradev/refactor-stages
Browse files Browse the repository at this point in the history
app-serving: Refactor stages
  • Loading branch information
seungkyua authored May 24, 2023
2 parents ba53596 + c4c911f commit c36e83d
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 218 deletions.
91 changes: 20 additions & 71 deletions app_serving/abort-java-app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ spec:
templates:
- name: exit-handler
steps:
- - name: notify-bluegreen-abort-failure
- - name: notify-abort-failure
templateRef:
name: update-tks-asa-status
template: updateTksAsaStatus
Expand All @@ -42,35 +42,17 @@ spec:
- name: asa_task_id
value: "{{workflow.parameters.asa_task_id}}"
- name: status
value: "BLUEGREEN_ABORT_FAILED"
value: "ABORT_FAILED"
- name: output
value: "{{workflow.outputs.parameters.abort_output_global}}"
when: "{{workflow.status}} != Succeeded && '{{workflow.parameters.strategy}}' == 'blue-green'"
- - name: notify-canary-abort-failure
templateRef:
name: update-tks-asa-status
template: updateTksAsaStatus
arguments:
parameters:
- name: organization_id
value: "{{workflow.parameters.organization_id}}"
- name: asa_id
value: "{{workflow.parameters.asa_id}}"
- name: asa_task_id
value: "{{workflow.parameters.asa_task_id}}"
- name: status
value: "CANARY_ABORT_FAILED"
- name: output
value: "{{workflow.outputs.parameters.abort_output_global}}"
when: "{{workflow.status}} != Succeeded && '{{workflow.parameters.strategy}}' == 'canary'"
when: "{{workflow.status}} != Succeeded"

- name: main
steps:
- - name: notify-bluegreen-abort-start
- - name: notify-abort-start
templateRef:
name: update-tks-asa-status
template: updateTksAsaStatus
when: "'{{workflow.parameters.strategy}}' == 'blue-green'"
arguments:
parameters:
- name: organization_id
Expand All @@ -80,14 +62,18 @@ spec:
- name: asa_task_id
value: "{{workflow.parameters.asa_task_id}}"
- name: status
value: "BLUEGREEN_ABORTING"
value: "ABORTING"
- name: output
value: ""
- - name: notify-canary-abort-start
- - name: abort-app
template: abort-app
## Stage for updating preview endpoint to 'N/A'
## All other values shouldn't be updated.
## (These values for endpoint & helm_revision are discarded by the API)
- - name: update-endpoint-url
templateRef:
name: update-tks-asa-status
template: updateTksAsaStatus
when: "'{{workflow.parameters.strategy}}' == canary"
name: update-tks-asa-endpoint
template: updateTksAsaEndpoint
arguments:
parameters:
- name: organization_id
Expand All @@ -96,12 +82,12 @@ spec:
value: "{{workflow.parameters.asa_id}}"
- name: asa_task_id
value: "{{workflow.parameters.asa_task_id}}"
- name: status
value: "CANARY_ABORTING"
- name: output
- name: endpoint
value: ""
- - name: abort-app
template: abort-app
- name: preview_endpoint
value: "N/A"
- name: helm_revision
value: 0
- - name: notify-abort-success
templateRef:
name: update-tks-asa-status
Expand All @@ -115,27 +101,9 @@ spec:
- name: asa_task_id
value: "{{workflow.parameters.asa_task_id}}"
- name: status
value: "{{steps.abort-app.outputs.parameters.status}}"
value: "ABORT_SUCCESS"
- name: output
value: "{{steps.abort-app.outputs.parameters.abort_output}}"
- - name: update-endpoint-url
templateRef:
name: update-tks-asa-endpoint
template: updateTksAsaEndpoint
arguments:
parameters:
- name: organization_id
value: "{{workflow.parameters.organization_id}}"
- name: asa_id
value: "{{workflow.parameters.asa_id}}"
- name: asa_task_id
value: "{{workflow.parameters.asa_task_id}}"
- name: endpoint
value: ""
- name: preview_endpoint
value: "N/A"
- name: helm_revision
value: "{{steps.abort-app.outputs.parameters.revision}}"

#######################
# Template Definition #
Expand All @@ -151,12 +119,6 @@ spec:
valueFrom:
path: /mnt/out/abort_output.log
globalName: abort_output_global
- name: status
valueFrom:
path: /mnt/out/abort_status
- name: revision
valueFrom:
path: /mnt/out/revision
container:
image: harbor-cicd.taco-cat.xyz/tks/appserving-worker:latest
volumeMounts:
Expand Down Expand Up @@ -288,8 +250,6 @@ spec:
exit 1
fi
# write revision
write_revision
# Perform abort
kubectl argo rollouts abort ${app_name} -n $ns
Expand All @@ -309,7 +269,7 @@ spec:
check_rollout_replicas
# TODO: Is just "undoing without revision" not enough?
#==========================================================
# undo to the latest active revision
#==========================================================
Expand All @@ -327,14 +287,3 @@ spec:
#==========================================================
check_rollout_phase "Healthy" "Healthy"
#==========================================================
# write information
#==========================================================
# Write deployment status to file for next step
if [[ "$strategy" == "blue-green" ]]; then
echo "BLUEGREEN_ABORT_SUCCESS" > /mnt/out/abort_status
elif [[ "$strategy" == "canary" ]]; then
echo "CANARY_ABORT_SUCCESS" > /mnt/out/abort_status
fi
91 changes: 19 additions & 72 deletions app_serving/promote-java-app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ spec:
templates:
- name: exit-handler
steps:
- - name: notify-bluegreen-promote-failure
- - name: notify-promote-failure
templateRef:
name: update-tks-asa-status
template: updateTksAsaStatus
Expand All @@ -42,35 +42,17 @@ spec:
- name: asa_task_id
value: "{{workflow.parameters.asa_task_id}}"
- name: status
value: "BLUEGREEN_PROMOTE_FAILED"
value: "PROMOTE_FAILED"
- name: output
value: "{{workflow.outputs.parameters.promote_output_global}}"
when: "{{workflow.status}} != Succeeded && '{{workflow.parameters.strategy}}' == 'blue-green'"
- - name: notify-canary-promote-failure
templateRef:
name: update-tks-asa-status
template: updateTksAsaStatus
arguments:
parameters:
- name: organization_id
value: "{{workflow.parameters.organization_id}}"
- name: asa_id
value: "{{workflow.parameters.asa_id}}"
- name: asa_task_id
value: "{{workflow.parameters.asa_task_id}}"
- name: status
value: "CANARY_PROMOTE_FAILED"
- name: output
value: "{{workflow.outputs.parameters.promote_output_global}}"
when: "{{workflow.status}} != Succeeded && '{{workflow.parameters.strategy}}' == canary"
when: "{{workflow.status}} != Succeeded"

- name: main
steps:
- - name: notify-bluegreen-promote-start
- - name: notify-promote-start
templateRef:
name: update-tks-asa-status
template: updateTksAsaStatus
when: "'{{workflow.parameters.strategy}}' == 'blue-green'"
arguments:
parameters:
- name: organization_id
Expand All @@ -80,14 +62,18 @@ spec:
- name: asa_task_id
value: "{{workflow.parameters.asa_task_id}}"
- name: status
value: "BLUEGREEN_PROMOTING"
value: "PROMOTING"
- name: output
value: ""
- - name: notify-canary-promote-start
- - name: promote-app
template: promote-app
## Stage for updating preview endpoint to 'N/A'
## All other values shouldn't be updated.
## (These values for endpoint & helm_revision are discarded by the API)
- - name: update-endpoint-url
templateRef:
name: update-tks-asa-status
template: updateTksAsaStatus
when: "'{{workflow.parameters.strategy}}' == canary"
name: update-tks-asa-endpoint
template: updateTksAsaEndpoint
arguments:
parameters:
- name: organization_id
Expand All @@ -96,12 +82,12 @@ spec:
value: "{{workflow.parameters.asa_id}}"
- name: asa_task_id
value: "{{workflow.parameters.asa_task_id}}"
- name: status
value: "CANARY_PROMOTING"
- name: output
- name: endpoint
value: ""
- - name: promote-app
template: promote-app
- name: preview_endpoint
value: "N/A"
- name: helm_revision
value: 0
- - name: notify-promote-success
templateRef:
name: update-tks-asa-status
Expand All @@ -115,27 +101,9 @@ spec:
- name: asa_task_id
value: "{{workflow.parameters.asa_task_id}}"
- name: status
value: "{{steps.promote-app.outputs.parameters.status}}"
value: "PROMOTE_SUCCESS"
- name: output
value: "{{steps.promote-app.outputs.parameters.promote_output}}"
- - name: update-endpoint-url
templateRef:
name: update-tks-asa-endpoint
template: updateTksAsaEndpoint
arguments:
parameters:
- name: organization_id
value: "{{workflow.parameters.organization_id}}"
- name: asa_id
value: "{{workflow.parameters.asa_id}}"
- name: asa_task_id
value: "{{workflow.parameters.asa_task_id}}"
- name: endpoint
value: ""
- name: preview_endpoint
value: "N/A"
- name: helm_revision
value: "{{steps.promote-app.outputs.parameters.revision}}"

#######################
# Template Definition #
Expand All @@ -154,12 +122,6 @@ spec:
# - name: endpoint
# valueFrom:
# path: /mnt/out/endpoint
- name: status
valueFrom:
path: /mnt/out/promote_status
- name: revision
valueFrom:
path: /mnt/out/revision
container:
image: harbor-cicd.taco-cat.xyz/tks/appserving-worker:latest
volumeMounts:
Expand Down Expand Up @@ -272,7 +234,6 @@ spec:
}
#==========================================================
# Start promoting Rollout
#==========================================================
Expand All @@ -286,9 +247,6 @@ spec:
exit 1
fi
# write revision
write_revision
# Perform promotion
kubectl argo rollouts promote ${app_name} -n {{workflow.parameters.namespace}}
Expand All @@ -305,14 +263,3 @@ spec:
#==========================================================
check_rollout_replicas
#==========================================================
# write information
#==========================================================
# Write deployment status to file for next step
if [[ "$strategy" == "blue-green" ]]; then
echo "BLUEGREEN_PROMOTE_SUCCESS" > /mnt/out/promote_status
elif [[ "$strategy" == "canary" ]]; then
echo "CANARY_PROMOTE_SUCCESS" > /mnt/out/promote_status
fi
32 changes: 16 additions & 16 deletions app_serving/rollback-java-app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,22 +67,6 @@ spec:
value: ""
- - name: rollback-app
template: rollback-app
- - name: notify-rollback-success
templateRef:
name: update-tks-asa-status
template: updateTksAsaStatus
arguments:
parameters:
- name: organization_id
value: "{{workflow.parameters.organization_id}}"
- name: asa_id
value: "{{workflow.parameters.asa_id}}"
- name: asa_task_id
value: "{{workflow.parameters.asa_task_id}}"
- name: status
value: "{{steps.rollback-app.outputs.parameters.status}}"
- name: output
value: "{{steps.rollback-app.outputs.parameters.rollback_output}}"
- - name: update-endpoint-url
templateRef:
name: update-tks-asa-endpoint
Expand All @@ -101,6 +85,22 @@ spec:
value: "N/A"
- name: helm_revision
value: "{{steps.rollback-app.outputs.parameters.revision}}"
- - name: notify-rollback-success
templateRef:
name: update-tks-asa-status
template: updateTksAsaStatus
arguments:
parameters:
- name: organization_id
value: "{{workflow.parameters.organization_id}}"
- name: asa_id
value: "{{workflow.parameters.asa_id}}"
- name: asa_task_id
value: "{{workflow.parameters.asa_task_id}}"
- name: status
value: "{{steps.rollback-app.outputs.parameters.status}}"
- name: output
value: "{{steps.rollback-app.outputs.parameters.rollback_output}}"

#######################
# Template Definition #
Expand Down
Loading

0 comments on commit c36e83d

Please sign in to comment.