From 16dbd46da015c86772dc513b4ab02f8c2d43964c Mon Sep 17 00:00:00 2001 From: ernish Date: Mon, 7 Jul 2025 13:07:21 +0200 Subject: [PATCH] SW-5652 Add logic --- hooks/command | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/hooks/command b/hooks/command index 030d170..ba819d9 100755 --- a/hooks/command +++ b/hooks/command @@ -212,6 +212,24 @@ aws ecs wait services-stable \ --cluster "${cluster}" \ --services "${service_name}" || deploy_exitcode=$? +echo "--- Verifying service is running expected task definition" + +expected_task=$(aws ecs describe-task-definition \ + --task-definition "${task_family}:${task_revision}" \ + --query 'taskDefinition.taskDefinitionArn' \ + --output text) + +current_task=$(aws ecs describe-services \ + --cluster "${cluster}" \ + --services "${service_name}" \ + --query 'services[0].deployments[?status==`PRIMARY`].taskDefinition' \ + --output text) + +if [[ "$current_task" != "$expected_task" ]]; then + echo "+++ ❗⚠️ Deployment rolled back: expected task definition ${expected_task} but service is using ${current_task} ✅️" + echo "+++ ❗⚠️ Check ECS events above for root cause (e.g., task failed to start, insufficient capacity)" + exit 1 +fi service_events=$(aws ecs describe-services \ --cluster "${cluster}" \