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

fix(cli): ecs hotswap fails on log configuration enabled #26876

Merged
merged 2 commits into from
Aug 25, 2023

Conversation

tmokmss
Copy link
Contributor

@tmokmss tmokmss commented Aug 24, 2023

Problem

ECS hotswap fails on a task definition containing log configuration like the following.

const taskDefinition = new ecs.FargateTaskDefinition(stack, 'Task', {});

taskDefinition.addContainer('EcsApp', {
  image: ecs.ContainerImage.fromRegistry('nginx:stable'),
  logging: ecs.LogDriver.awsLogs({ streamPrefix: 'log' }),
});

Root cause

When we transform object keys in a task definition, we pass excludeFromTransform to avoid from transforming keys with arbitrary string, such as logDriver.options.

However, it was not working when we transform keys with upperCaseFirstCharacter, because the keys in excludeFromTransform was uppercased, where the source object was lowercased.

// source task definition
{
  "logConfiguration": {
      "logDriver": "awslogs",
      "options": {
          "awslogs-group": "my-test-stack-TaskEcsAppLogGroupD5C9C1DD-BPB6zgX4S0wU",
          "awslogs-region": "ap-northeast-1",
      },
  },
}

// excludeFromTransform 
{ 
  LogConfiguration: {
      Options: true,
    },
  },
}

// where it should be
{ 
  logConfiguration: {
      options: true,
    },
  },
}

This misconfiguration resulted in the output task definition uppercased in an unexpected way:

{
  "logConfiguration": {
      "logDriver": "awslogs",
      "options": {
          "Awslogs-group": "my-test-stack-TaskEcsAppLogGroupD5C9C1DD-BPB6zgX4S0wU",
          "Awslogs-region": "ap-northeast-1",
      },
  },
}

The problem was not detected by unit tests because they only contained cases with uppercase keys in a source task definition.

Fix

Use lowercased excludeFromTransform when we use it with upperCaseFirstCharacter, also adding a test case with lowercased keys in a source task definition.

Closes #26871.


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@github-actions github-actions bot added bug This issue is a bug. p2 admired-contributor [Pilot] contributed between 13-24 PRs to the CDK labels Aug 24, 2023
@aws-cdk-automation aws-cdk-automation requested a review from a team August 24, 2023 21:25
Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pull request linter has failed. See the aws-cdk-automation comment below for failure reasons. If you believe this pull request should receive an exemption, please comment and provide a justification.

A comment requesting an exemption should contain the text Exemption Request. Additionally, if clarification is needed add Clarification Request to a comment.

@aws-cdk-automation aws-cdk-automation added the pr/needs-cli-test-run This PR needs CLI tests run against it. label Aug 24, 2023
@tmokmss
Copy link
Contributor Author

tmokmss commented Aug 24, 2023

Exemption Request: this should be covered with cli-integ tests. Also I tested e2e hotswap manually in my aws account.

@aws-cdk-automation aws-cdk-automation added pr-linter/exemption-requested The contributor has requested an exemption to the PR Linter feedback. pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. labels Aug 24, 2023
@github-actions github-actions bot added effort/small Small work item – less than a day of effort p1 and removed p2 labels Aug 25, 2023
@aws-cdk-automation aws-cdk-automation added pr/needs-maintainer-review This PR needs a review from a Core Team Member and removed pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. labels Aug 25, 2023
@rix0rrr rix0rrr added pr-linter/exempt-integ-test The PR linter will not require integ test changes pr-linter/cli-integ-tested Assert that any CLI changes have been integ tested labels Aug 25, 2023
@aws-cdk-automation aws-cdk-automation dismissed their stale review August 25, 2023 05:54

✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.

@aws-cdk-automation aws-cdk-automation removed pr/needs-maintainer-review This PR needs a review from a Core Team Member pr/needs-cli-test-run This PR needs CLI tests run against it. labels Aug 25, 2023
@mergify
Copy link
Contributor

mergify bot commented Aug 25, 2023

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mergify mergify bot merged commit 6cffca0 into aws:main Aug 25, 2023
8 of 9 checks passed
@mergify
Copy link
Contributor

mergify bot commented Aug 25, 2023

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: 772576b
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

tmokmss added a commit to tmokmss/aws-cdk that referenced this pull request Sep 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
admired-contributor [Pilot] contributed between 13-24 PRs to the CDK bug This issue is a bug. effort/small Small work item – less than a day of effort p1 pr-linter/cli-integ-tested Assert that any CLI changes have been integ tested pr-linter/exempt-integ-test The PR linter will not require integ test changes pr-linter/exemption-requested The contributor has requested an exemption to the PR Linter feedback.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CDK Deploy: Deploy with hotswap now failing
3 participants