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

Support QuickSync for ECS without ELB or target groups #4685

Merged
merged 10 commits into from
Nov 27, 2023

Conversation

t-kikuc
Copy link
Member

@t-kikuc t-kikuc commented Nov 22, 2023

What this PR does / why we need it:
This PR supports QuickSync for ECS using Service Discovery, not ELB and target groups.
I will support canary and blue/green for Service Discovery later.

Which issue(s) this PR fixes:

Part of #4616

Does this PR introduce a user-facing change?:

  • How are users affected by this change: not affected including configs.
  • Is this breaking change: no
  • How to migrate (if breaking change): no

@t-kikuc t-kikuc changed the title Support QuickSync for ECS using Service Discovery Support QuickSync for ECS without ELB or target groups Nov 22, 2023
Copy link

codecov bot commented Nov 22, 2023

Codecov Report

Attention: 2 lines in your changes are missing coverage. Please review.

Comparison is base (8bad596) 30.82% compared to head (8159ba7) 30.83%.

Files Patch % Lines
pkg/config/application_ecs.go 83.33% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master    #4685   +/-   ##
=======================================
  Coverage   30.82%   30.83%           
=======================================
  Files         221      221           
  Lines       25935    25947   +12     
=======================================
+ Hits         7995     8001    +6     
- Misses      17289    17295    +6     
  Partials      651      651           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

input:
serviceDefinitionFile: /path/to/servicedef.yaml
taskDefinitionFile: /path/to/taskdef.yaml
accessType: SERVICE_DISCOVERY
Copy link
Member

Choose a reason for hiding this comment

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

This constant is defined by us or by AWS lib? 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

"This constant" means 'SERVICE_DISCOVERY'?

If so, it's defined by us, not by AWS.

And other names would be added in the future, like 'APP_MESH'

Copy link
Member

Choose a reason for hiding this comment

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

Then we should define these values as constant of ECS platform provider and have validate in config package

Copy link
Member Author

Choose a reason for hiding this comment

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

thanks, I got it. I'll fix it.

Copy link
Member Author

Choose a reason for hiding this comment

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

@khanhtc1202
I did it. Could you check again?
919cc3c

@khanhtc1202
Copy link
Member

/review

Copy link

PR Analysis

Main theme

This PR introduces support for two types of access to ECS services: ELB and service discovery.

PR summary

This PR adds a new field, AccessType, to the ECSDeploymentInput struct in the application_ecs.go file. It also adds validation for the AccessType field and updates the ensureSync function in the deploy.go file to handle the different access types.

Type of PR

Refactoring

PR Feedback:

General suggestions

The changes in this PR look good overall. The addition of support for different access types is a valuable enhancement. The code is well-structured, and the use of constants for the access types improves readability.

Code feedback

pkg/app/piped/executor/ecs/deploy.go

  • Line 97:
    • suggestion: Consider extracting the logic of parsing target groups into a separate function to improve modularity and code readability. [medium]
  • Line 104:
    • suggestion: Since the loadTargetGroups function is only called when ecsInput.IsAccessedViaELB() is true, you can simplify the code by using an if statement instead of an if-else statement. [medium]

pkg/config/application_ecs.go

  • Line 16:
    • suggestion: It would be helpful to add comments explaining the purpose of the constant accessTypeELB. [medium]
  • Line 17:
    • suggestion: Please consider renaming the constant accessTypeServiveDiscovery to accessTypeServiceDiscovery to fix the typo. [medium]
  • Line 42:
    • suggestion: Consider adding a comment describing the purpose of the validateAccessType method. [medium]
  • Line 47:
    • suggestion: Use a switch-case statement instead of an if-else ladder to validate the AccessType field in the ECSDeploymentInput struct. This will improve code readability. [medium]

pkg/config/application_ecs_test.go

  • Line 70:
    • suggestion: Add a test case to cover the scenario where AccessType is set to SERVICE_DISCOVERY. [important]

Security concerns:

No

@t-kikuc
Copy link
Member Author

t-kikuc commented Nov 23, 2023

/review

Copy link

PR Analysis

Main theme

type: Refactoring
description: Adding support for ECS service access type in the application configuration.

PR summary

type: Refactoring
description: This PR introduces changes to support different ways of accessing ECS services by adding an AccessType field to the ECSDeploymentInput struct in the ECS application configuration.

Type of PR

Refactoring

PR Feedback:

General suggestions

The changes look good overall. The addition of the AccessType field enhances the flexibility of ECS deployments. However, there are a few suggestions that could further improve the new code.

Code feedback

File: pkg/app/piped/executor/ecs/deploy.go

L9

The import statement for the github.com/aws/aws-sdk-go-v2/service/ecs/types package is unused and can be removed.

L19-L25

The check for ecsInput.IsAccessedViaELB() can be simplified. Instead of wrapping the subsequent code block with an if condition, you can return model.StageStatus_STAGE_FAILURE directly if !ecsInput.IsAccessedViaELB() is true. This would eliminate the need for the ok variable and reduce the nesting level.

File: pkg/config/application_ecs.go

L18-L27

Consider extracting the constant access type values (ELB and SERVICE_DISCOVERY) into their own const block for better code organization.

L41-L42

The validateAccessType() function can be improved by returning an error message that reflects the invalid AccessType. For example, you can modify the error message to fmt.Errorf("invalid accessType: %s", in.AccessType). This would provide a more specific error message when an invalid AccessType is used.

File: pkg/config/application_ecs_test.go

L71-L77

Consider adding additional test cases to cover the scenarios where accessType is set to SERVICE_DISCOVERY and an invalid AccessType value is used. This would provide broader test coverage for the new AccessType feature.

Security concerns

no

@khanhtc1202
Copy link
Member

@t-kikuc commented 👍

@t-kikuc t-kikuc force-pushed the support-ecs-service-discovery-sync branch from 903955c to ddc3d02 Compare November 27, 2023 05:26
Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>
Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>
Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>
Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>
Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>
Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>
Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>
Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>
Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>
@t-kikuc t-kikuc force-pushed the support-ecs-service-discovery-sync branch from ddc3d02 to 840f2ce Compare November 27, 2023 06:21
@t-kikuc
Copy link
Member Author

t-kikuc commented Nov 27, 2023

@khanhtc1202
I removed unrelated commits.

One test/go failed, but it's due to flakiness #4630
And it's passed by a re-run.

Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>
Copy link
Member

@khanhtc1202 khanhtc1202 left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

@khanhtc1202 khanhtc1202 merged commit a64f250 into pipe-cd:master Nov 27, 2023
13 checks passed
@github-actions github-actions bot mentioned this pull request Dec 1, 2023
sZma5a pushed a commit to sZma5a/pipecd that referenced this pull request Dec 17, 2023
* Support QuickSync for ECS Service Discovery pattern

Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>

* Update the test expectation of ELB pattern

Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>

* Add a test of QuickSync of ECS Service Discovery

Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>

* fix comment

Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>

* Add a description of Input values

Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>

* Add consts and validation of accessType

Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>

* Modify consts to public for using in switch-case

Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>

* Fix a typo

Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>

* Refactor validation func

Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>

* Add a blank line in import

Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>

---------

Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>
sZma5a pushed a commit to sZma5a/pipecd that referenced this pull request Dec 17, 2023
* Support QuickSync for ECS Service Discovery pattern

Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>

* Update the test expectation of ELB pattern

Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>

* Add a test of QuickSync of ECS Service Discovery

Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>

* fix comment

Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>

* Add a description of Input values

Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>

* Add consts and validation of accessType

Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>

* Modify consts to public for using in switch-case

Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>

* Fix a typo

Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>

* Refactor validation func

Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>

* Add a blank line in import

Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>

---------

Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>
sZma5a pushed a commit to sZma5a/pipecd that referenced this pull request Dec 17, 2023
* Support QuickSync for ECS Service Discovery pattern

Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>

* Update the test expectation of ELB pattern

Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>

* Add a test of QuickSync of ECS Service Discovery

Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>

* fix comment

Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>

* Add a description of Input values

Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>

* Add consts and validation of accessType

Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>

* Modify consts to public for using in switch-case

Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>

* Fix a typo

Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>

* Refactor validation func

Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>

* Add a blank line in import

Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>

---------

Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>
Signed-off-by: sZma5a <masaaki.haribote@gmail.com>
@github-actions github-actions bot mentioned this pull request Feb 6, 2024
sZma5a pushed a commit to sZma5a/pipecd that referenced this pull request Feb 12, 2024
* Support QuickSync for ECS Service Discovery pattern

Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>

* Update the test expectation of ELB pattern

Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>

* Add a test of QuickSync of ECS Service Discovery

Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>

* fix comment

Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>

* Add a description of Input values

Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>

* Add consts and validation of accessType

Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>

* Modify consts to public for using in switch-case

Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>

* Fix a typo

Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>

* Refactor validation func

Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>

* Add a blank line in import

Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>

---------

Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>
Signed-off-by: 鈴木 優耀 <suzuki_masaaki@cyberagent.co.jp>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants