CircleCI-Public / aws-code-deploy-orb

Easily deploy applications to AWS CodeDeploy on CircleCI with the aws-code-deploy orb
https://circleci.com/orbs/registry/orb/circleci/aws-code-deploy
MIT License
9 stars 13 forks source link

In CircleCI Cloud pager is set to "less" by default on deploying machine #5

Closed malipek closed 4 years ago

malipek commented 4 years ago

Orb Version 1.0.1

Describe the bug During deployment when the output is long enough client-pager is executed. In CircleCI cloud output, when there's enough lines, output is piped via less and waits for "return" input. Web interface timeouts after 10 minutes. Full output form CircleCI Web Interface (deployment stage):

#!/bin/bash -eo pipefail
ID=$(aws deploy create-deployment \
        --application-name APP_NAME \
        --deployment-group-name DG_NAME \
        --deployment-config-name CodeDeployDefault.OneAtATime \
        --s3-location bucket=S3_BUCKET,bundleType=zip,key=codedeploy/deployment.zip \
        --output text \
        --query '[deploymentId]')
STATUS=$(aws deploy get-deployment \
          --deployment-id $ID \
          --output text \
          --query '[deploymentInfo.status]')
while [[ $STATUS == "Created" || $STATUS == "InProgress" || $STATUS == "Pending" || $STATUS == "Queued" || $STATUS == "Ready" ]]; do
  echo "Status: $STATUS..."
  STATUS=$(aws deploy get-deployment \
            --deployment-id $ID \
            --output text \
            --query '[deploymentInfo.status]')
  sleep 5
done
if [[ $STATUS == "Succeeded" ]]; then
  EXITCODE=0
  echo "Deployment finished."
else
  EXITCODE=1
  echo "Deployment failed!"
fi
aws deploy get-deployment --deployment-id $ID
exit $EXITCODE
Status: InProgress...
Status: InProgress...
Status: InProgress...
Status: InProgress...
Status: InProgress...
Status: InProgress...
Status: InProgress...
Status: InProgress...
Status: InProgress...
Status: InProgress...
Status: InProgress...
Status: InProgress...
Status: InProgress...
Status: InProgress...
Status: InProgress...
Status: InProgress...
Status: InProgress...
Status: InProgress...
Deployment finished.
WARNING: terminal is not fully functional
{ress RETURN)
    "deploymentInfo": {
        "applicationName": "APP_NAME",
        "deploymentGroupName": "DG_NAME",
        "deploymentConfigName": "CodeDeployDefault.OneAtATime",
        "deploymentId": "DeploymentID",
        "revision": {
            "revisionType": "S3",
            "s3Location": {
                "bucket": "S3_BUCKET",
                "key": "codedeploy/deployment.zip",
                "bundleType": "zip"
            }
        },
        "status": "Succeeded",
        "createTime": "2020-05-12T06:27:54.543000+00:00",
        "completeTime": "2020-05-12T06:29:38.413000+00:00",
        "deploymentOverview": {
            "Pending": 0,
            "InProgress": 0,
            "Succeeded": 1,
            "Failed": 0,
            "Skipped": 0,
:

Too long with no output (exceeded 10m0s): context deadline exceeded

To Reproduce

  1. Create small EC2 instance so deploy would take long time
  2. Execute deployment with aws-code-deploy
  3. Deploy fails in CircleCI Web Interface with timeout regardless of result (Success or Fail)

Example config.yml

version: 2.1

orbs:
  aws-cli: circleci/aws-cli@1
  aws-code-deploy: circleci/aws-code-deploy@1

executors:
  alpine:
    docker:
      - image: alpine:latest

jobs:
  checkout_code:
    executor: alpine
    steps:
      - checkout
      - persist_to_workspace:
          root: ~/project
          paths:
            - .

  deploy_to_staging:
    executor: aws-cli/default
    steps:
      - attach_workspace:
          at: ~/project
      - aws-cli/setup:
          aws-access-key-id: STAGING_AWS_ACCESS_KEY_ID
          aws-secret-access-key: STAGING_AWS_SECRET_ACCESS_KEY
          aws-region: STAGING_AWS_DEFAULT_REGION
      - aws-code-deploy/push-bundle:
          application-name: APP_NAME
          bundle-bucket: S3_BUCKET
          bundle-key: codedeploy/deployment
      - aws-code-deploy/deploy-bundle:
          application-name: APP_NAME
          deployment-group: DG_NAME
          bundle-bucket: S3_BUCKET
          bundle-key: codedeploy/deployment

workflows:
  version: 2
  build_test_deploy:
    jobs:
      - checkout_code
      - deploy_to_staging:
          requires:
            - checkout_code
          filters:
            branches:
              only: master

Expected behavior

No client-side pager is used while deploying. Environment variable AWS_PAGER set to empty string in ORB.

Additional context

Applied workaround - "AWS_PAGER=" set as a first step in deployment job

...
executor: aws-cli/default
    steps:
      - run:
          name: Setup Environment Variables
          # https://docs.aws.amazon.com/cli/latest/userguide/cli-usage-pagination.html#cli-usage-pagination-clientside
          command: |
            echo "export AWS_PAGER=" >> $BASH_ENV
      - attach_workspace:
          at: ~/project
      - aws-cli/setup:
  ...
malipek commented 4 years ago

It looks like it's fixed now in https://github.com/CircleCI-Public/aws-cli-orb/commit/c3f351390262635206a2b45527c2cb3d721fed9d Closing.