Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add timeout option #33

Closed
clareliguori opened this issue Feb 12, 2020 · 4 comments · Fixed by #37
Closed

Add timeout option #33

clareliguori opened this issue Feb 12, 2020 · 4 comments · Fixed by #37

Comments

@clareliguori
Copy link
Member

wait-for-services-stable currently only waits 10 minutes, which might not be long enough for all deployments

@amazingguni
Copy link

I need this too 😄

@clareliguori
Copy link
Member Author

@amazingguni how long of a timeout do you need?

@amazingguni
Copy link

@clareliguori

In my case, it should be more than 15 minutes.
But I think it's better to support a parameter to set the timeout like circleci orbs aws/ecs.
(max-poll-attempts , 'poll-interval')
https://circleci.com/orbs/registry/orb/circleci/aws-ecs

echo "Verifying that << parameters.task-definition-arn >> is deployed.."
attempt=0
while [ "$attempt" -lt << parameters.max-poll-attempts >> ]
do
    DEPLOYMENTS=$(aws ecs describe-services \
        --cluster << parameters.cluster-name >> \
        --services ${SERVICE_NAME} \
        --output text \
        --query 'services[0].deployments[].[taskDefinition, status]')
    NUM_DEPLOYMENTS=$(aws ecs describe-services \
        --cluster << parameters.cluster-name >> \
        --services ${SERVICE_NAME} \
        --output text \
        --query 'length(services[0].deployments)')
    TARGET_REVISION=$(aws ecs describe-services \
        --cluster << parameters.cluster-name >> \
        --services ${SERVICE_NAME} \
        --output text \
        --query "services[0].deployments[?taskDefinition==\`<< parameters.task-definition-arn >>\` && runningCount == desiredCount && (status == \`PRIMARY\` || status == \`ACTIVE\`)][taskDefinition]")
    echo "Current deployments: $DEPLOYMENTS"
    if [ "$NUM_DEPLOYMENTS" = "1" ] && [ "$TARGET_REVISION" = "<< parameters.task-definition-arn >>" ]; then
        echo "The task definition revision $TARGET_REVISION is the only deployment for the service and has attained the desired running task count."
        exit 0
    else
        echo "Waiting for revision << parameters.task-definition-arn >> to reach desired running count / older revisions to be stopped.."
        sleep << parameters.poll-interval >>
    fi
    attempt=$((attempt + 1))
done
echo "Stopped waiting for deployment to be stable - please check the status of << parameters.task-definition-arn >> on the AWS ECS console."

@clareliguori
Copy link
Member Author

@amazingguni Yep makes sense to have a configurable timeout, and probably also to raise the default timeout :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants