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 pipecd builtin tags to ECS resources #4140

Merged
merged 24 commits into from
Jan 27, 2023
Merged

Conversation

TonkyH
Copy link
Contributor

@TonkyH TonkyH commented Jan 19, 2023

What this PR does / why we need it:

Add PipeCD builtin tags for ECS resources.

Which issue(s) this PR fixes:

Fixes #

Does this PR introduce a user-facing change?:

NONE

@TonkyH TonkyH marked this pull request as ready for review January 20, 2023 07:38
@khanhtc1202 khanhtc1202 changed the title Add tags to aws resources. Add pipecd builtin tags to ECS resources Jan 23, 2023
@@ -105,7 +105,7 @@ func rollback(ctx context.Context, in *executor.Input, platformProviderName stri
// Re-register TaskDef to get TaskDefArn.
// Consider using DescribeServices and get services[0].taskSets[0].taskDefinition (taskDefinition of PRIMARY taskSet)
// then store it in metadata store and use for rollback instead.
td, err := client.RegisterTaskDefinition(ctx, taskDefinition)
td, err := client.RegisterTaskDefinition(ctx, taskDefinition, serviceDefinition.Tags)
Copy link
Member

Choose a reason for hiding this comment

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

I think we only care about the cluster/service/task thus we don't need to tag the taskDefinition, since it isn't a part of the application anyway. wdyt?

Copy link
Contributor Author

@TonkyH TonkyH Jan 23, 2023

Choose a reason for hiding this comment

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

I can also get TaskDef from Task, and it certainly seems unnecessary...
Since TaskDef can also be retrieved from Task, it certainly seems unnecessary to tag the taskDef.
I'll give it some more thought and fix it!🙇

Copy link
Member

Choose a reason for hiding this comment

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

Any besides, we should check whether tags which are added to the service is automatically added to the tasks which are controlled by service or not as well 👀

Copy link
Contributor Author

@TonkyH TonkyH Jan 23, 2023

Choose a reason for hiding this comment

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

The --propagateTags parameter can be used to copy tags from a task definition or service to a task in the service🚀

"github.com/aws/aws-sdk-go-v2/service/ecs/types"
"go.uber.org/zap"
"golang.org/x/sync/singleflight"

"github.com/pipe-cd/pipecd/pkg/config"
)

const (
LabelApplication string = "pipecd-dev-application" // The application this resource belongs to.
Copy link
Member

Choose a reason for hiding this comment

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

Could you add more builtin tags for ECS resources. For instant, in case of CloudRun, we have as below
https://github.com/pipe-cd/pipecd/blob/master/pkg/app/piped/platformprovider/cloudrun/cloudrun.go#L86-L93

I think we should also have: TagManagedBy (value will be piped in all cases), LabelPiped, LabelCommitHash as the PipeCD builtin tags for ECS resources.

@@ -109,3 +119,11 @@ var defaultRegistry = &registry{
func DefaultRegistry() Registry {
return defaultRegistry
}

func CreateTags(keyValue map[string]string) []types.Tag {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
func CreateTags(keyValue map[string]string) []types.Tag {
func MakeTags(tags map[string]string) []types.Tag {

nits

khanhtc1202
khanhtc1202 previously approved these changes Jan 27, 2023
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.

Nice work 👍

Comment on lines 95 to 97
if serviceDefinition.PropagateTags == "" {
serviceDefinition.PropagateTags = types.PropagateTagsService
}
Copy link
Member

Choose a reason for hiding this comment

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

Sorry, I missed this part. I think we should always propagate the tags from the service to its tasks due to tags contains out builtin tags as well. So it's better to set the value to CreateServiceInput.PropagateTags directly in CreateService method. WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree.
I think we should always propagate tags from the service to its tasks.
So, set the value directly to CreateServiceInput.PropagateTags in the CreateService method.

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.

Here you go 🙌

@khanhtc1202 khanhtc1202 merged commit 9f1414c into pipe-cd:master Jan 27, 2023
This was referenced Feb 7, 2023
knanao pushed a commit that referenced this pull request Feb 7, 2023
* Add tags to aws resources.

* Small fix

* Small fix

* Fix initial slice length.

* Add TagResource function

* Fix deploy process

* Add tags to aws resources.

* Small fix

* Small fix

* Fix initial slice length.

* Add TagResource function

* Fix deploy process

* Delete Unnecessary blank lines

* Change how to add task's tags

* Delete TagResource method

* Fix based on linter

* Apply review

* add builtin-labels

* Add tagResource func

* Set default value of PropagateTags

* Apply review

* Apply review
knanao added a commit that referenced this pull request Feb 7, 2023
#4157 #4161 (#4163)

* Templating commit message used by Event watcher (#4120)

* Added ability to teplate eventWatcher.gitRepos.commitMessage

* parse template in the eventWatcher handler side

* Parse template in the eventWatcher handler side

* Fix html/template to text/template

* There was a useless process when retrieving rules, so I omitted it.

* Delete html/template

* Update pkg/app/piped/eventwatcher/eventwatcher.go

Co-authored-by: Khanh Tran <[email protected]>

* Update pkg/app/piped/eventwatcher/eventwatcher.go

Co-authored-by: Khanh Tran <[email protected]>

* Using template variables are only Value and EventName.

* Update pkg/app/piped/eventwatcher/eventwatcher.go

Co-authored-by: knanao <[email protected]>

* Update pkg/app/piped/eventwatcher/eventwatcher.go

Co-authored-by: knanao <[email protected]>

* Fix syntax error

* Update pkg/app/piped/eventwatcher/eventwatcher.go

Co-authored-by: Khanh Tran <[email protected]>

Co-authored-by: Khanh Tran <[email protected]>
Co-authored-by: knanao <[email protected]>

* Add environment variable expire web session (#4127)

* add field session-ttl to project

* edit values

* reflect ttl config to session

* return values

* add field in document

* return config

* change variable name

* modify document and manifest

* modify docs

* change minites tp hours

* regen

* Change build tag every time when make run/pipecd (#4130)

* add unix time to tail of build tag

* modify assigning

* change variable name

* change type pf assign

* Fix docs wrong params name (#4132)

* Fix pod config for envoy upstreaming termination error (#4134)

* add lifecycle

* add preStop to api server's manifest

* return makefile

* Fix Fix parseComitMsg's comment (#4135)

* Add kubectl version to stage log (#4137)

* Add kubectl version to stage log

* Update pkg/app/piped/executor/kubernetes/kubernetes.go

Co-authored-by: knanao <[email protected]>

Co-authored-by: knanao <[email protected]>

* Add pipecd builtin tags to ECS resources (#4140)

* Add tags to aws resources.

* Small fix

* Small fix

* Fix initial slice length.

* Add TagResource function

* Fix deploy process

* Add tags to aws resources.

* Small fix

* Small fix

* Fix initial slice length.

* Add TagResource function

* Fix deploy process

* Delete Unnecessary blank lines

* Change how to add task's tags

* Delete TagResource method

* Fix based on linter

* Apply review

* add builtin-labels

* Add tagResource func

* Set default value of PropagateTags

* Apply review

* Apply review

* Add upgrade a release method for helm (#4143)

* tool: Replace set-output with GITHUB_OUTPUT (#4155)

* Make all changes that not be listed in ignores but placed under appDir considered as touched commit (#4157)

* Release v0.41.4 (#4161)

* Release v0.41.4

* Update the release note

---------

Co-authored-by: funera1 <[email protected]>
Co-authored-by: Khanh Tran <[email protected]>
Co-authored-by: kevin55156 <[email protected]>
Co-authored-by: Tomoki Hori <[email protected]>
Co-authored-by: Naoki Kanatani <[email protected]>
@github-actions github-actions bot mentioned this pull request Feb 27, 2023
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.

2 participants