GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — chore(cli): deploy and update task resources for `task run` by Louise15926 · Pull Request #1176 · aws/copilot-cli

This repository was archived by the owner on Jun 22, 2026. It is now read-only.

Conversation

@Louise15926

@Louise15926 Louise15926 commented Jul 21, 2020

Copy link
Copy Markdown
Contributor

This PR implements Execute for task run

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Louise15926
Louise15926 requested review from bvtujo, efekarakus, iamhopaul123 and piradeepk July 21, 2020 23:59
@amazon-ecs-cli-v2-pr-manager
amazon-ecs-cli-v2-pr-manager requested a review from seongm-1 July 22, 2020 00:00
@Louise15926
Louise15926 removed the request for review from seongm-1 July 22, 2020 00:00
@Lou1415926
chore: deploy/update task in execute
33b292c
@Louise15926
Louise15926 force-pushed the task-run/deploy branch 2 times, most recently from 57a7e55 to 33b292c Compare July 22, 2020 15:57
@Louise15926
Louise15926 marked this pull request as ready for review July 22, 2020 16:01
@Louise15926
Louise15926 requested a review from a team as a code owner July 22, 2020 16:01
@Louise15926 Louise15926 changed the title chore(cli): execute taks run chore(cli): deploy and update task resources for task run Jul 22, 2020
efekarakus
efekarakus reviewed Jul 22, 2020
View reviewed changes
Comment thread internal/pkg/cli/task_run.go Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread internal/pkg/cli/task_run.go
}

return &runTaskOpts{
sess, err := session.NewProvider().Default()

@efekarakus efekarakus Jul 22, 2020

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

If a user provides an environment after Ask or with flags, we should instead use the environment manager role to create the task stack:

copilot-cli/internal/pkg/cli/svc_deploy.go

Line 255 in 2fb935f

envSession, err := o.sessProvider.FromRole(o.targetEnvironment.ManagerRoleARN, o.targetEnvironment.Region)

This is a role that Copilot creates when a user runs copilot env init for developers to assume and create/monitor their services or tasks.


The way we've been initializing clients that require data after the Ask method is with function fields, for example:

copilot-cli/internal/pkg/cli/svc_logs.go

Lines 74 to 84 in 2fb935f

initCwLogsSvc: func(o *svcLogsOpts, envName string) error {
env, err := o.configStore.GetEnvironment(o.AppName(), envName)
if err != nil {
return fmt.Errorf("get environment: %w", err)
}
sess, err := session.NewProvider().FromRole(env.ManagerRoleARN, env.Region)
if err != nil {
return err
}
o.cwlogsSvc[env.Name] = cloudwatchlogs.New(sess)
return nil

The reason is that in our tests we can override the initCwLogsSvc field to return a mock instead. This way we don't need to define global variables in the code.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@Louise15926 Louise15926 Jul 22, 2020

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

For the second one (initializing clients): that's exactly what I did! it's coming in the next PR.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

efekarakus reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

@Louise15926 Louise15926 Jul 22, 2020

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I actually have coded everything for task_run.go but the PR got too large, so I split it into three smaller ones. This is the first of the smaller PR.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@Louise15926 Louise15926 Jul 22, 2020

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I will use envSession to configure runtime clients in the next PR (since this PR doesn't involve any runtime clients yet)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread internal/pkg/cli/task_run.go Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread internal/pkg/cli/task_run.go Outdated
}

func (o *runTaskOpts) deployTaskResources() error {
o.spinner.Start(fmt.Sprintf("Deploying resources for task %s", color.HighlightUserInput(o.groupName)))

@efekarakus efekarakus Jul 22, 2020

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I feel like it would be nice for users to get a sense of the type of resources that we need to create to run the task. What do you think of?

Suggested change
o.spinner.Start(fmt.Sprintf("Deploying resources for task %s", color.HighlightUserInput(o.groupName)))
o.spinner.Start(fmt.Sprintf("Creating a task definition for %s and the necessary permissions", color.HighlightUserInput(o.groupName)))

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@Louise15926 Louise15926 Jul 22, 2020 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I like that! Then should I also mention the ECR repo and log group that are also created?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@efekarakus efekarakus Jul 22, 2020 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I wasn't sure about that in case this step only did a stack update instead of create 🤔
Do you know which resource takes the longest to create? I feel like as long as we mention that one the rest shouldn't matter as much 8)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@Louise15926 Louise15926 Jul 22, 2020

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

In fact, neither of the stack resource (roles, ecr repo, log group) takes long to provision. From CloudFormation console, each of them takes about 1-2seconds to create lol.

Task definition is not created at the first call; it's only created/updated after the image is pushed, i.e. the second call. During the second call, it takes ~2 seconds to create the task definition - according to CloudFormation console.

So most of the waiting is spent on building and pushing images, and waiting for tasks to start.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@Louise15926 Louise15926 Jul 22, 2020

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I wasn't sure about that in case this step only did a stack update instead of create 🤔

We can perhaps use the word 'Preparing' instead of 'Creating' or 'Deploying', if we want to include ECR/log group.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@piradeepk piradeepk Jul 22, 2020 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Does it make sense to use Provisioning resources for task %s instead of preparing?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Louise15926 reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
Comment thread internal/pkg/cli/task_run.go Resolved

Uh oh!

There was an error while loading. Please reload this page.

Lou1415926 and others added 2 commits July 22, 2020 12:55
@Lou1415926 @efekarakus
Update internal/pkg/cli/task_run.go
449a24a
Co-authored-by: Efe Karakus <[email protected]>
@Lou1415926
address feedback
3ecdc16
piradeepk
piradeepk reviewed Jul 22, 2020
View reviewed changes
Comment thread internal/pkg/cli/task_run_test.go Resolved

Uh oh!

There was an error while loading. Please reload this page.

@Lou1415926
address feedback
cf650e1
efekarakus
efekarakus approved these changes Jul 22, 2020
View reviewed changes
Lou1415926 added 2 commits July 22, 2020 16:03
@Lou1415926
udpate output message
310e280
@Lou1415926
fix test
8eb544b
piradeepk
piradeepk reviewed Jul 22, 2020
View reviewed changes
Comment thread internal/pkg/cli/task_run.go Resolved

Uh oh!

There was an error while loading. Please reload this page.

piradeepk
piradeepk approved these changes Jul 22, 2020
View reviewed changes

@piradeepk piradeepk left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

A minor comment, but looks great! 💯

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Louise15926 Louise15926 added the do-not-merge Pull requests that mergify shouldn't merge until the requester allows it. label Jul 22, 2020
Lou1415926 and others added 2 commits July 22, 2020 16:10
@Lou1415926
fix
047989e
@mergify
Merge branch 'master' into task-run/deploy
eb9c147
@Louise15926 Louise15926 removed the do-not-merge Pull requests that mergify shouldn't merge until the requester allows it. label Jul 22, 2020
@mergify
mergify Bot merged commit a136b03 into aws:master Jul 22, 2020
@Louise15926
Louise15926 deleted the task-run/deploy branch August 5, 2020 19:37
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

@bvtujo bvtujo Awaiting requested review from bvtujo
@iamhopaul123 iamhopaul123 Awaiting requested review from iamhopaul123
2 more reviewers
@efekarakus efekarakus efekarakus approved these changes
@piradeepk piradeepk piradeepk approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@Louise15926 @efekarakus @piradeepk @Lou1415926
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.