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(codepipeline-actions): use IBaseService instead of BaseService in EcsDeployActionProps #6412

Merged
merged 18 commits into from
Mar 11, 2020

Conversation

atsushi-ishibashi
Copy link
Contributor

@atsushi-ishibashi atsushi-ishibashi commented Feb 23, 2020

refer: #6408

  • Replace BaseService with IBaseService in EcsDeployActionProps

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

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 8be4b51
  • Result: FAILED
  • Build Logs (available for 30 days)

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

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: f38e6f4
  • Result: FAILED
  • Build Logs (available for 30 days)

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

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 2333da2
  • Result: FAILED
  • Build Logs (available for 30 days)

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

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 441f276
  • Result: FAILED
  • Build Logs (available for 30 days)

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

@atsushi-ishibashi
Copy link
Contributor Author

This PR got the below errors.
But ECS Service cannot be defined uniquely by ARN, for example arn:aws:ecs:us-west-2:123456789012:service/my-http-service, which contains only service name and you can create the same name service in different cluster.
So far I have no idea to avoid this incompatible changes🤔
Let me know if there is a better way👍

@aws-cdk/aws-ecs... CHANGES.
Original assembly: @aws-cdk/aws-ecs@1.25.0
Updated assembly:  @aws-cdk/aws-ecs@1.25.0
API elements with incompatible changes:
err  - METHOD @aws-cdk/aws-ecs.Ec2Service.fromEc2ServiceArn: has been removed [removed:@aws-cdk/aws-ecs.Ec2Service.fromEc2ServiceArn]
err  - METHOD @aws-cdk/aws-ecs.FargateService.fromFargateServiceArn: has been removed [removed:@aws-cdk/aws-ecs.FargateService.fromFargateServiceArn]
err  - PROP @aws-cdk/aws-ecs.IEc2Service.serviceArn: has been removed [removed:@aws-cdk/aws-ecs.IEc2Service.serviceArn]
err  - PROP @aws-cdk/aws-ecs.IFargateService.serviceArn: has been removed [removed:@aws-cdk/aws-ecs.IFargateService.serviceArn]
err  - PROP @aws-cdk/aws-ecs.IService.serviceArn: has been removed [removed:@aws-cdk/aws-ecs.IService.serviceArn]

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 51fc085
  • Result: FAILED
  • Build Logs (available for 30 days)

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

@skinny85
Copy link
Contributor

This PR got the below errors.
But ECS Service cannot be defined uniquely by ARN, for example arn:aws:ecs:us-west-2:123456789012:service/my-http-service, which contains only service name and you can create the same name service in different cluster.
So far I have no idea to avoid this incompatible changes🤔
Let me know if there is a better way👍

@aws-cdk/aws-ecs... CHANGES.
Original assembly: @aws-cdk/aws-ecs@1.25.0
Updated assembly:  @aws-cdk/aws-ecs@1.25.0
API elements with incompatible changes:
err  - METHOD @aws-cdk/aws-ecs.Ec2Service.fromEc2ServiceArn: has been removed [removed:@aws-cdk/aws-ecs.Ec2Service.fromEc2ServiceArn]
err  - METHOD @aws-cdk/aws-ecs.FargateService.fromFargateServiceArn: has been removed [removed:@aws-cdk/aws-ecs.FargateService.fromFargateServiceArn]
err  - PROP @aws-cdk/aws-ecs.IEc2Service.serviceArn: has been removed [removed:@aws-cdk/aws-ecs.IEc2Service.serviceArn]
err  - PROP @aws-cdk/aws-ecs.IFargateService.serviceArn: has been removed [removed:@aws-cdk/aws-ecs.IFargateService.serviceArn]
err  - PROP @aws-cdk/aws-ecs.IService.serviceArn: has been removed [removed:@aws-cdk/aws-ecs.IService.serviceArn]

See this comment on how to achieve this.

You need to remove all of your breaking changes, these are stables modules, so no breaking changes are allowed.

There is already a PR attempting these changes: #6203 , but it's not building ATM, and there's hasn't been much activity on it lately.

Copy link
Contributor

@skinny85 skinny85 left a comment

Choose a reason for hiding this comment

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

@mergify mergify bot dismissed skinny85’s stale review February 24, 2020 17:59

Pull request has been modified.

@atsushi-ishibashi atsushi-ishibashi changed the title fix(codepipeline-actions): use IService instead of BaseService in EcsDeployActionProps fix(codepipeline-actions): use IBaseService instead of BaseService in EcsDeployActionProps Feb 24, 2020
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 61f2f5f
  • Result: FAILED
  • Build Logs (available for 30 days)

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

/**
* The name of the cluster that hosts the service.
*/
readonly clusterName: string;
Copy link
Contributor

Choose a reason for hiding this comment

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

This needs to be ICluster. Not clusterName.

/**
* The service ARN.
*/
readonly serviceArn: string;
Copy link
Contributor

Choose a reason for hiding this comment

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

There should also be serviceName, and one of serviceArn or serviceName is required.

Copy link
Contributor Author

@atsushi-ishibashi atsushi-ishibashi Feb 24, 2020

Choose a reason for hiding this comment

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

I added validation to prevent from setting both or neither. If both are set, it may be confusing.

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 8c9e994
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

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

@mergify mergify bot dismissed skinny85’s stale review February 24, 2020 19:21

Pull request has been modified.

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: b44e309
  • Result: FAILED
  • Build Logs (available for 30 days)

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

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: e786f9f
  • Result: FAILED
  • Build Logs (available for 30 days)

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

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: bee67c6
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

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

@atsushi-ishibashi
Copy link
Contributor Author

atsushi-ishibashi commented Feb 25, 2020

I said to extract the body of fromEc2ServiceAttributes and fromFargateServiceAttributes to a module-private function to reduce duplication. I never said anything about a class.

I will add public static function to class BaseService. If I couldn't understand your intention, please correct me🙇 @skinny85

@skinny85
Copy link
Contributor

skinny85 commented Feb 26, 2020

I said to extract the body of fromEc2ServiceAttributes and fromFargateServiceAttributes to a module-private function to reduce duplication. I never said anything about a class.

I will add public static function to class BaseService. If I couldn't understand your intention, please correct me🙇 @skinny85

No. I don't want to make this function a part of the public contract of the ECS module. Do this instead:

// file: from-service-attributes.ts
export interface ServiceAttributes {
  // serviceName, serviceArn, cluster
  ...
}

export function fromServiceAtrributes(scope: Construct, id: string, attributes: ServiceAttributes): IBaseService {
  ... 
}

Then call this function from fromEc2ServiceAttributes and fromFargateServiceAttributes. It will work because of TypeScript's structural typing.

@mergify mergify bot dismissed skinny85’s stale review February 26, 2020 02:56

Pull request has been modified.

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 6e1d696
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

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

@atsushi-ishibashi
Copy link
Contributor Author

@skinny85 please review again. Thanks

Copy link
Contributor

@skinny85 skinny85 left a comment

Choose a reason for hiding this comment

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

Thanks @atsushi-ishibashi , looking good! We're almost there. Just a few last comments before I'm comfortable shipping this.

import * as codepipeline from '@aws-cdk/aws-codepipeline';
import { FakeSourceAction } from '@aws-cdk/aws-codepipeline/test/fake-source-action';
Copy link
Contributor

Choose a reason for hiding this comment

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

Please just use one of the source actions from this package. FakeSourceAction is private to the @aws-codepipeline package.

});
const artifact = new codepipeline.Artifact('Artifact');

test.doesNotThrow(() => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove the test.doesNotThrow(), it's redundant.

const stack = new cdk.Stack();
const service = ecs.FargateService.fromFargateServiceAttributes(stack, 'FargateService', {
serviceName: 'my-http-service',
cluster: new ecs.Cluster(stack, 'Cluster', {
Copy link
Contributor

Choose a reason for hiding this comment

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

Import the cluster with a well-known name as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You mean like this?

const service = ecs.FargateService.fromFargateServiceAttributes(stack, 'FargateService', {
  serviceName: 'service-name',
  cluster: new ecs.Cluster(stack, 'Cluster', {
    clusterName: 'cluster-name',
  }),
});

Copy link
Contributor

Choose a reason for hiding this comment

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

I meant more Cluster.fromClusterAttributes(), but this should work as well (I want a specific name in the test assertion, not a CFN Ref expression).

Name: 'Source',
ActionTypeId: {
Category: "Source",
Provider: "Fake"
Copy link
Contributor

Choose a reason for hiding this comment

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

No reason for these assertions here, just leave it as:

Stages: [
  {},
  {
     "Name": "Deploy",
     "Actions": [
       {
         // ...
       }
     ],
  }
]

/**
* The service ARN.
*
* @default - generated from serviceName
Copy link
Contributor

Choose a reason for hiding this comment

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

This comment is wrong (should be "either this, or {@link serviceName}, is required").

/**
* The name of the service.
*
* @default - generated from serviceArn
Copy link
Contributor

Choose a reason for hiding this comment

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

This comment is wrong (should be "either this, or {@link serviceArn}, is required").

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is @default - {@link serviceArn}, is required what you want?
Optional property must have @default documentation.

Copy link
Contributor

Choose a reason for hiding this comment

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

I want:

/**
 * The name of the imported service.
 *
 * @default - either this, or {@link serviceArn}, is required
 */
readonly serviceName?: string;

/**
* The service ARN.
*
* @default - generated from serviceName
Copy link
Contributor

Choose a reason for hiding this comment

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

This comment is wrong (should be "either this, or {@link serviceName}, is required").

/**
* The name of the service.
*
* @default - generated from serviceArn
Copy link
Contributor

Choose a reason for hiding this comment

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

This comment is wrong (should be "either this, or {@link serviceArn}, is required").

/**
* The service ARN.
*
* @default - generated from serviceName
Copy link
Contributor

Choose a reason for hiding this comment

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

This comment is wrong (should be "either this, or {@link serviceName}, is required").

/**
* The name of the service.
*
* @default - generated from serviceArn
Copy link
Contributor

Choose a reason for hiding this comment

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

This comment is wrong (should be "either this, or {@link serviceArn}, is required").

@mergify mergify bot dismissed skinny85’s stale review February 28, 2020 01:58

Pull request has been modified.

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 583b8af
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

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

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: fee33f2
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

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

@atsushi-ishibashi
Copy link
Contributor Author

Ready for review👍 @skinny85
If you need update branch, please do it! I may fall in asleep

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 2a4e1f3
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

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

@atsushi-ishibashi
Copy link
Contributor Author

@skinny85 I'd like you to include this PR in the next release:bow: In out product, we're constructing CD pipeline refering existing ECS services. So this feature is important to proceed it.
Thanks!

@atsushi-ishibashi
Copy link
Contributor Author

@skinny85 @SomayaB
Please review this PR. Sorry to remind you many times🙏

@jkdilunika
Copy link

@skinny85 really appreciate if you could merge this fix to next release of CDK (if it has solved the blocking issue). I have to carry forward my blocked pipeline ticket for the third sprint now. I was criticized during last sprint retro for picking CDK for this project :). I will be more careful next time when picking new AWS frameworks for my work place projects ...

@skinny85
Copy link
Contributor

Hey all,

sorry, I was out on vacation the last week and a half. Will review soon.

Thanks,
Adam

Copy link
Contributor

@skinny85 skinny85 left a comment

Choose a reason for hiding this comment

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

Thanks for your patience @atsushi-ishibashi !

@mergify
Copy link
Contributor

mergify bot commented Mar 11, 2020

Thank you for contributing! Your pull request will be updated from master 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: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 5310ca4
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

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

@mergify
Copy link
Contributor

mergify bot commented Mar 11, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-ecs Related to Amazon Elastic Container
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants