-
Notifications
You must be signed in to change notification settings - Fork 153
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
Ignore desiredCount
of ECS when it's 0 or not set for AutoScaling
#5030
Conversation
Signed-off-by: t-kikuc <[email protected]>
Signed-off-by: t-kikuc <[email protected]>
Signed-off-by: t-kikuc <[email protected]>
Signed-off-by: t-kikuc <[email protected]>
Signed-off-by: t-kikuc <[email protected]>
Signed-off-by: t-kikuc <[email protected]>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #5030 +/- ##
==========================================
+ Coverage 22.42% 22.46% +0.03%
==========================================
Files 522 522
Lines 56915 57056 +141
==========================================
+ Hits 12766 12816 +50
- Misses 43123 43213 +90
- Partials 1026 1027 +1 ☔ View full report in Codecov by Sentry. |
Signed-off-by: t-kikuc <[email protected]>
if !ignoreDesiredCount { | ||
input.DesiredCount = aws.Int32(service.DesiredCount) | ||
} |
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.
@t-kikuc I think when users tend to ignore expressly setting the desiredCount
value, they will leave it empty (or remove that line from the manifests); having this flag added can lead to some confusing configuration when users set the desiredCount
value in service file but set this flag in the app configuration as true 🤔
For whatever cases, how about to change this logic as
input := &ecs.UpdateServiceInput{
Cluster: service.ClusterArn,
....
}
if service.DesiredCount != 0 {
input.DesiredCount = aws.Int32(service.DesiredCount)
}
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.
@khanhtc1202
Thank you so much. Your code seems really simple and great, and I also think they will remove desiredCount
.
However, there are two patterns we should consider.
- Even if a user truly wants to scale-in tasks to 0 by
desiredCount: 0
,desiredCount
won't be 0.- e.g. When a user wants to keep the service but it does not need to serve.
- DriftDetection will be inevitable because a piped cannot judge whether to ignore
desiredCount
.- case-a.
- current
desiredCount
= 5 - ->Scale up to 10 by AutoScaling
- -> DriftDetection will reconcile to 5.
- current
- case-b.
- current
desiredCount
= 5 - -> new
desiredCount
= 0 - -> DriftDetection will try to reconcile to 0 every time (but it won't actually be 0).
- current
- case-a.
That's why I think the new config attribute is required.
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.
@t-kikuc Across the Kubernetes QuickSync configuration of pipecd, I think currently we don't support prune resource (tasks) for ECS application, which mean we can forget about the behavior when users set desiredCount
to zero to remove the tasks (ref: https://pipecd.dev/docs-v0.48.x/user-guide/configuration-reference/#kubernetesquicksync).
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.
Of course, I understand the need to support the prune resource on deployment, but I think it should be a separate change, not this PR. Also, in such cases, we can just add a new interface (not update this UpdateService) but call the new function like PruneService. Then, in the implementation, we set the desiredCount to zero.
My point is, we should not change the interface whenever we need a change that is not actually worth; creating a new one is a better choice 😄 (If follow the OOP principles - if you're a former java dev, you know what I mean 😉 )
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.
we don't support prune resource
To be precise, this is not pruning, it's scaling-in.
Of course, I know the principle and won't use UpdateService() for pruning.
You mean scaling-in to 0 tasks is not necessary?
DriftDetection
I found a simpler way based on your code.
Let's ignore the drift If
- diff is only
desiredCount
desiredCount
in new commit = 0
Then we can support both of two patterns:
- reconciling to
desiredCount
(>0) in the new commit - skipping reconciling when
desiredCount
is 0 or not defined
In case I mentioned, a user should remove desiredCount
from the serviceDef.
case-b.
current desiredCount= 5
-> new desiredCount= 0
-> DriftDetection will try to reconcile to 0 every time (but it won't actually be 0).
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.
@khanhtc1202
What do you think about recreating? It sets desiredCount
as 0.
https://github.com/pipe-cd/pipecd/blob/master/pkg/app/piped/executor/ecs/ecs.go#L277-L286
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.
@t-kikuc Thanks for making it clear; I forgot about the recreating case 😢
Then, how about
- only allow desiredCount ignored for CreateService interface (aka. make a change to this interface: https://github.com/pipe-cd/pipecd/blob/master/pkg/app/piped/platformprovider/ecs/client.go#L93)
- for UpdateService, only if the user directly sets desiredCount to 0 -> scales down in the size of the task to 0. If users don't mention desiredCount in the service manifest, just ignore it from the UpdateServiceInput
wdyt?
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.
@khanhtc1202
Thanks,
Let's ignore "scaling-in to 0 tasks is not necessary" cases for simplicity.
It is not a common case for production-ready services.
If needed, let's support prune
feature like K8sApp.
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.
Thank you 🙏
Signed-off-by: t-kikuc <[email protected]>
This reverts commit a0f3459. Signed-off-by: t-kikuc <[email protected]>
This reverts commit 7d65824. Signed-off-by: t-kikuc <[email protected]>
This reverts commit dcd7dc9. Signed-off-by: t-kikuc <[email protected]>
This reverts commit 5103158. Signed-off-by: t-kikuc <[email protected]>
This reverts commit d17a9b7. Signed-off-by: t-kikuc <[email protected]>
This reverts commit cf3efbf. Signed-off-by: t-kikuc <[email protected]>
This reverts commit 6b2af75. Signed-off-by: t-kikuc <[email protected]>
Signed-off-by: t-kikuc <[email protected]>
…gnore-desired-count Signed-off-by: t-kikuc <[email protected]>
Signed-off-by: t-kikuc <[email protected]>
Signed-off-by: t-kikuc <[email protected]>
desiredCount
on updating a servicedesiredCount
of ECS when it's 0 or not set for AutoScaling
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.
LGTM, thank you 🪨
- As long as `desiredCount` is 0 or not set, `desiredCount` of your service will NOT be updated in deployments. | ||
- If `desiredCount` is 0 or not set for a new service, the service's `desiredCount` will be 0. | ||
- `capacityProviderStrategy` is not supported. |
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.
[Ask] When enabling ECS autoscaling, what should users do? In my understanding, they set desiredCount
to 0 after setting up autoscaling. Is it right?
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.
Just to sure. I have the same question.
Users can follow the below steps to create an autoscaled service. Is this correct?
- create a service with the desiredCount as 0 or not specified. if it is not specified, the desiredCount is treated as 0.
- configure autoscaling, and autoscaling policy or something like this updates desiredCount.
- when updating a service, piped ignores the desiredCount. So the count of tasks is not touched.
Signed-off-by: t-kikuc <[email protected]>
…/pipecd into ecs-ignore-desired-count Signed-off-by: t-kikuc <[email protected]>
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.
LGTM
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.
LGTM 🆗
…5030) * add a flag: ignoreDesiredCountOnUpdate Signed-off-by: t-kikuc <[email protected]> * ignore desiredCount on updateService if needed Signed-off-by: t-kikuc <[email protected]> * Add a flag ignoreDesiredCountOnUpdate into each func Signed-off-by: t-kikuc <[email protected]> * Format func params and comment Signed-off-by: t-kikuc <[email protected]> * add docs Signed-off-by: t-kikuc <[email protected]> * fix tests: add a missing attribute Signed-off-by: t-kikuc <[email protected]> * recover desiredCount in CreateService (mistake) Signed-off-by: t-kikuc <[email protected]> * add mentioning driftdetection Signed-off-by: t-kikuc <[email protected]> * Revert changes of adding ignoreDesiredCountOnUpdate This reverts commit a0f3459. Signed-off-by: t-kikuc <[email protected]> * Revert commits of adding ignoreDesiredCount" This reverts commit 7d65824. Signed-off-by: t-kikuc <[email protected]> * Revert "add docs" This reverts commit dcd7dc9. Signed-off-by: t-kikuc <[email protected]> * Revert "Format func params and comment" This reverts commit 5103158. Signed-off-by: t-kikuc <[email protected]> * Revert "Add a flag ignoreDesiredCountOnUpdate into each func" This reverts commit d17a9b7. Signed-off-by: t-kikuc <[email protected]> * Revert "ignore desiredCount on updateService if needed" This reverts commit cf3efbf. Signed-off-by: t-kikuc <[email protected]> * Revert "add a flag: ignoreDesiredCountOnUpdate" This reverts commit 6b2af75. Signed-off-by: t-kikuc <[email protected]> * ignore updating desiredCount if it's 0 or not defined Signed-off-by: t-kikuc <[email protected]> * Use pruning when 'recreate' is on Signed-off-by: t-kikuc <[email protected]> * add docs Signed-off-by: t-kikuc <[email protected]> * refine docs Signed-off-by: t-kikuc <[email protected]> * Clarify procedure of configuring Signed-off-by: t-kikuc <[email protected]> --------- Signed-off-by: t-kikuc <[email protected]>
…5030) * add a flag: ignoreDesiredCountOnUpdate Signed-off-by: t-kikuc <[email protected]> * ignore desiredCount on updateService if needed Signed-off-by: t-kikuc <[email protected]> * Add a flag ignoreDesiredCountOnUpdate into each func Signed-off-by: t-kikuc <[email protected]> * Format func params and comment Signed-off-by: t-kikuc <[email protected]> * add docs Signed-off-by: t-kikuc <[email protected]> * fix tests: add a missing attribute Signed-off-by: t-kikuc <[email protected]> * recover desiredCount in CreateService (mistake) Signed-off-by: t-kikuc <[email protected]> * add mentioning driftdetection Signed-off-by: t-kikuc <[email protected]> * Revert changes of adding ignoreDesiredCountOnUpdate This reverts commit a0f3459. Signed-off-by: t-kikuc <[email protected]> * Revert commits of adding ignoreDesiredCount" This reverts commit 7d65824. Signed-off-by: t-kikuc <[email protected]> * Revert "add docs" This reverts commit dcd7dc9. Signed-off-by: t-kikuc <[email protected]> * Revert "Format func params and comment" This reverts commit 5103158. Signed-off-by: t-kikuc <[email protected]> * Revert "Add a flag ignoreDesiredCountOnUpdate into each func" This reverts commit d17a9b7. Signed-off-by: t-kikuc <[email protected]> * Revert "ignore desiredCount on updateService if needed" This reverts commit cf3efbf. Signed-off-by: t-kikuc <[email protected]> * Revert "add a flag: ignoreDesiredCountOnUpdate" This reverts commit 6b2af75. Signed-off-by: t-kikuc <[email protected]> * ignore updating desiredCount if it's 0 or not defined Signed-off-by: t-kikuc <[email protected]> * Use pruning when 'recreate' is on Signed-off-by: t-kikuc <[email protected]> * add docs Signed-off-by: t-kikuc <[email protected]> * refine docs Signed-off-by: t-kikuc <[email protected]> * Clarify procedure of configuring Signed-off-by: t-kikuc <[email protected]> --------- Signed-off-by: t-kikuc <[email protected]>
* fix: upgrade @loadable/component from 5.14.1 to 5.16.4 (#5000) Snyk has created this PR to upgrade @loadable/component from 5.14.1 to 5.16.4. See this package in yarn: @loadable/component See this project in Snyk: https://app.snyk.io/org/pipecd/project/f41c5767-b506-4f59-beb9-ef662258eb9a?utm_source=github&utm_medium=referral&page=upgrade-pr Signed-off-by: khanhtc1202 <[email protected]> Co-authored-by: snyk-bot <[email protected]> Signed-off-by: t-kikuc <[email protected]> * fix: upgrade @reduxjs/toolkit from 1.8.5 to 1.9.7 (#4999) Snyk has created this PR to upgrade @reduxjs/toolkit from 1.8.5 to 1.9.7. See this package in yarn: @reduxjs/toolkit See this project in Snyk: https://app.snyk.io/org/pipecd/project/f41c5767-b506-4f59-beb9-ef662258eb9a?utm_source=github&utm_medium=referral&page=upgrade-pr Co-authored-by: snyk-bot <[email protected]> Signed-off-by: t-kikuc <[email protected]> * fix: upgrade react-router-dom from 5.2.0 to 5.3.4 (#5001) Snyk has created this PR to upgrade react-router-dom from 5.2.0 to 5.3.4. See this package in yarn: react-router-dom See this project in Snyk: https://app.snyk.io/org/pipecd/project/f41c5767-b506-4f59-beb9-ef662258eb9a?utm_source=github&utm_medium=referral&page=upgrade-pr Signed-off-by: t-kikuc <[email protected]> Co-authored-by: snyk-bot <[email protected]> Co-authored-by: Tetsuya Kikuchi <[email protected]> Signed-off-by: t-kikuc <[email protected]> * fix: upgrade grpc-web from 1.0.7 to 1.5.0 (#4984) Snyk has created this PR to upgrade grpc-web from 1.0.7 to 1.5.0. See this package in yarn: grpc-web See this project in Snyk: https://app.snyk.io/org/pipecd/project/f41c5767-b506-4f59-beb9-ef662258eb9a?utm_source=github&utm_medium=referral&page=upgrade-pr Co-authored-by: snyk-bot <[email protected]> Signed-off-by: t-kikuc <[email protected]> * [Snyk] Security upgrade alpine from 3.17 to 3.20 (#5014) * fix: docs/Dockerfile to reduce vulnerabilities The following vulnerabilities are fixed with an upgrade: - https://snyk.io/vuln/SNYK-ALPINE317-OPENSSL-7413590 - https://snyk.io/vuln/SNYK-ALPINE317-OPENSSL-7413590 - https://snyk.io/vuln/SNYK-ALPINE317-OPENSSL-7413591 - https://snyk.io/vuln/SNYK-ALPINE317-OPENSSL-7413591 Signed-off-by: Shinnosuke Sawada-Dazai <[email protected]> * Bump alpine Signed-off-by: Shinnosuke Sawada-Dazai <[email protected]> --------- Signed-off-by: Shinnosuke Sawada-Dazai <[email protected]> Co-authored-by: snyk-bot <[email protected]> Co-authored-by: Shinnosuke Sawada-Dazai <[email protected]> Signed-off-by: t-kikuc <[email protected]> * Upgrade google-cloud-sdk (#5042) * Use x86_64 version of google-cloud-sdk Signed-off-by: Shinnosuke Sawada-Dazai <[email protected]> * Upgrade google-cloud-sdk Signed-off-by: Shinnosuke Sawada-Dazai <[email protected]> --------- Signed-off-by: Shinnosuke Sawada-Dazai <[email protected]> Signed-off-by: t-kikuc <[email protected]> * feat: add support mention slack groups for NotificationReceiverSlack and NotificationMention (#4903) * feat: add support mentione groups for NotifactionReceiverSlack and slackGroups for NotificationMention Signed-off-by: hungran <[email protected]> * remove change in docs v0.47.x Signed-off-by: hungran <[email protected]> * update docs Signed-off-by: hungran <[email protected]> * update logic for having getGroupsAsString() Signed-off-by: hungran <[email protected]> * using <!subteam^ID> for group mentioning Signed-off-by: hungran <[email protected]> * typo Signed-off-by: hungran <[email protected]> * call both getAccountsAsString and getGroupsAsString Signed-off-by: hungran <[email protected]> * revert change pkg/model/notificationevent.pb.go Signed-off-by: hungran <[email protected]> * use same format for group <!subteam^ID> Signed-off-by: hungran <[email protected]> * same method to format slack group Signed-off-by: hungran <[email protected]> * following slack api, !subteam^ is a literal string that should not change Signed-off-by: hungran <[email protected]> * feat: add slackUsers field and mark slack as deprecated field Signed-off-by: hungran <[email protected]> * revert pkg/model/notificationevent.pb.go Signed-off-by: hungran <[email protected]> * update doc Using the groupID or teamID in the documents makes it easier for users to use this feature. Signed-off-by: hungran <[email protected]> * add code gen Signed-off-by: hungran <[email protected]> * adjust mention users and slack logic Signed-off-by: hungran <[email protected]> * unify the process to get users and groups in the same method Signed-off-by: hungran <[email protected]> --------- Signed-off-by: hungran <[email protected]> Signed-off-by: t-kikuc <[email protected]> * Ignore `desiredCount` of ECS when it's 0 or not set for AutoScaling (#5030) * add a flag: ignoreDesiredCountOnUpdate Signed-off-by: t-kikuc <[email protected]> * ignore desiredCount on updateService if needed Signed-off-by: t-kikuc <[email protected]> * Add a flag ignoreDesiredCountOnUpdate into each func Signed-off-by: t-kikuc <[email protected]> * Format func params and comment Signed-off-by: t-kikuc <[email protected]> * add docs Signed-off-by: t-kikuc <[email protected]> * fix tests: add a missing attribute Signed-off-by: t-kikuc <[email protected]> * recover desiredCount in CreateService (mistake) Signed-off-by: t-kikuc <[email protected]> * add mentioning driftdetection Signed-off-by: t-kikuc <[email protected]> * Revert changes of adding ignoreDesiredCountOnUpdate This reverts commit a0f3459. Signed-off-by: t-kikuc <[email protected]> * Revert commits of adding ignoreDesiredCount" This reverts commit 7d65824. Signed-off-by: t-kikuc <[email protected]> * Revert "add docs" This reverts commit dcd7dc9. Signed-off-by: t-kikuc <[email protected]> * Revert "Format func params and comment" This reverts commit 5103158. Signed-off-by: t-kikuc <[email protected]> * Revert "Add a flag ignoreDesiredCountOnUpdate into each func" This reverts commit d17a9b7. Signed-off-by: t-kikuc <[email protected]> * Revert "ignore desiredCount on updateService if needed" This reverts commit cf3efbf. Signed-off-by: t-kikuc <[email protected]> * Revert "add a flag: ignoreDesiredCountOnUpdate" This reverts commit 6b2af75. Signed-off-by: t-kikuc <[email protected]> * ignore updating desiredCount if it's 0 or not defined Signed-off-by: t-kikuc <[email protected]> * Use pruning when 'recreate' is on Signed-off-by: t-kikuc <[email protected]> * add docs Signed-off-by: t-kikuc <[email protected]> * refine docs Signed-off-by: t-kikuc <[email protected]> * Clarify procedure of configuring Signed-off-by: t-kikuc <[email protected]> --------- Signed-off-by: t-kikuc <[email protected]> --------- Signed-off-by: khanhtc1202 <[email protected]> Signed-off-by: t-kikuc <[email protected]> Signed-off-by: Shinnosuke Sawada-Dazai <[email protected]> Signed-off-by: hungran <[email protected]> Co-authored-by: Khanh Tran <[email protected]> Co-authored-by: snyk-bot <[email protected]> Co-authored-by: Chris Aniszczyk <[email protected]> Co-authored-by: Shinnosuke Sawada-Dazai <[email protected]> Co-authored-by: Henry Vu <[email protected]>
What this PR does / why we need it:
- Introduced a new config attributeignoreDesiredCountOnUpdate,
which ignoresdesiredCount
when updating a service.desiredCount
on updating a service if it's 0 or not set.Which issue(s) this PR fixes:
Fixes #5027
Does this PR introduce a user-facing change?: Yes
They can use a new config attribute.no