Skip to content

chore: set tasks fewer than spot_from to fargate cp when min and spot_from equal#4187

Merged
mergify[bot] merged 5 commits intoaws:mainlinefrom
huanjani:spot
Nov 17, 2022
Merged

chore: set tasks fewer than spot_from to fargate cp when min and spot_from equal#4187
mergify[bot] merged 5 commits intoaws:mainlinefrom
huanjani:spot

Conversation

@huanjani
Copy link
Copy Markdown
Contributor

Addresses: https://gitter.im/aws/copilot-cli?at=637244e418f21c023bb057cc

Previously, the logic to scale into Fargate Spot only applied if the spot_from value was greater than the min value. So in edge case of users having equal values greater than 1 for those fields, as in the case linked to above, all of the tasks would have Fargate Spot as their capacity provider, rather than the spot_from value determining the threshold for Fargate vs Fargate Spot. This kind of config is somewhat atypical, as the min value isn't guaranteed if that number task has Fargate Spot as a capacity provider, but if users do set up their scaling this way, at least we are honoring the spot_from value.

With this change:
min: 3 and spot_from: 3 --> 2 Fargate, 1 Spot
min: 2 and spot_from: 2 --> 1 Fargate, 1 Spot
min: 1 and spot_from: 1 --> 0 Fargate, 1 Spot
min: 0 and spot_from: 0 --> 0 Fargate, 1 Spot

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the Apache 2.0 License.

@huanjani huanjani requested a review from a team as a code owner November 15, 2022 23:28
@huanjani huanjani requested review from paragbhingre and removed request for a team November 15, 2022 23:28
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Nov 15, 2022

🍕 Here are the new binary sizes!

Name New size (kiB) v1.23.0 size (kiB) Delta (%)
macOS (amd) 47676 47548 +0.27
macOS (arm) 47676 48200 ❤️ -1.09
linux (amd) 41928 41812 +0.28
linux (arm) 41928 41220 🥺 +1.72
windows (amd) 38768 38664 +0.27

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Nov 15, 2022

Codecov Report

Merging #4187 (9bcbede) into mainline (e7fadd1) will decrease coverage by 0.01%.
The diff coverage is 100.00%.

@@             Coverage Diff              @@
##           mainline    #4187      +/-   ##
============================================
- Coverage     69.30%   69.29%   -0.02%     
============================================
  Files           250      250              
  Lines         35919    35946      +27     
  Branches        264      264              
============================================
+ Hits          24893    24907      +14     
- Misses         9834     9847      +13     
  Partials       1192     1192              
Impacted Files Coverage Δ
...al/pkg/deploy/cloudformation/stack/transformers.go 77.19% <100.00%> (ø)
internal/pkg/manifest/errors.go 53.08% <100.00%> (+1.18%) ⬆️
internal/pkg/manifest/validate.go 84.14% <100.00%> (+0.08%) ⬆️
internal/pkg/cli/env_deploy.go 54.31% <0.00%> (-2.99%) ⬇️
...ternal/pkg/deploy/cloudformation/cloudformation.go 72.47% <0.00%> (-0.55%) ⬇️
internal/pkg/cli/deploy/env.go 75.19% <0.00%> (+0.58%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Copy link
Copy Markdown
Contributor

@efekarakus efekarakus left a comment

Choose a reason for hiding this comment

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

Awesome, ty Janice!

// to one less than spotFrom
if spotFrom > min {
if spotFrom >= min {
base := spotFrom - 1
Copy link
Copy Markdown
Contributor

@efekarakus efekarakus Nov 16, 2022

Choose a reason for hiding this comment

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

huh so you can you can have spotFrom and min be 0?
and it doesn't error if the base ends up being -1?

According to the commit message, we get:

min: 0 and spot_from: 0 --> 0 Fargate, 1 Spot

I think this is pretty strange, I would have expected 0 Fargate and 0 Spot here.

edit: I take this back 1 fargate spot makes sense if your cpu_percentage is like 70% because when you have 0 tasks the avg cpu is at 0%, so ECS has to scale up resulting in 1 spot task.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Side-note: should we make sure that min, max and spot_from is >= 0 here:

func (r RangeConfig) validate() error {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Screen Shot 2022-11-16 at 3 33 02 PM

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this has got to be a bug lol 😂 like what could -1 base mean conceptually

@iamhopaul123 iamhopaul123 added the do-not-merge Pull requests that mergify shouldn't merge until the requester allows it. label Nov 16, 2022
@efekarakus efekarakus removed the do-not-merge Pull requests that mergify shouldn't merge until the requester allows it. label Nov 17, 2022
@mergify mergify Bot merged commit b3336ba into aws:mainline Nov 17, 2022
@huanjani huanjani deleted the spot branch November 17, 2022 21:37
KollaAdithya pushed a commit to KollaAdithya/copilot-cli that referenced this pull request Nov 21, 2022
…`spot_from` equal (aws#4187)

Addresses: https://gitter.im/aws/copilot-cli?at=637244e418f21c023bb057cc

Previously, the logic to scale into Fargate Spot only applied if the `spot_from` value was greater than the `min` value. So in edge case of users having equal values greater than 1 for those fields, as in the case linked to above, all of the tasks would have Fargate Spot as their capacity provider, rather than the `spot_from` value determining the threshold for Fargate vs Fargate Spot. This kind of config is somewhat atypical, as the `min` value isn't guaranteed if that number task has Fargate Spot as a capacity provider, but if users do set up their scaling this way, at least we are honoring the `spot_from` value.

With this change:
`min: 3` and `spot_from: 3` --> 2 Fargate, 1 Spot
`min: 2` and `spot_from: 2` --> 1 Fargate, 1 Spot
`min: 1` and `spot_from: 1` --> 0 Fargate, 1 Spot
`min: 0` and `spot_from: 0` --> 0 Fargate, 1 Spot

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the Apache 2.0 License.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants