-
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 <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>
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 <tkikuchi07f@gmail.com>
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 <tkikuchi07f@gmail.com>
This reverts commit a0f3459. Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>
This reverts commit 7d65824. Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>
This reverts commit dcd7dc9. Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>
This reverts commit 5103158. Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>
This reverts commit d17a9b7. Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>
This reverts commit cf3efbf. Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>
This reverts commit 6b2af75. Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>
Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>
…gnore-desired-count Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>
Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>
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 <tkikuchi07f@gmail.com>
…/pipecd into ecs-ignore-desired-count Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>
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 <tkikuchi07f@gmail.com> * ignore desiredCount on updateService if needed Signed-off-by: t-kikuc <tkikuchi07f@gmail.com> * Add a flag ignoreDesiredCountOnUpdate into each func Signed-off-by: t-kikuc <tkikuchi07f@gmail.com> * Format func params and comment Signed-off-by: t-kikuc <tkikuchi07f@gmail.com> * add docs Signed-off-by: t-kikuc <tkikuchi07f@gmail.com> * fix tests: add a missing attribute Signed-off-by: t-kikuc <tkikuchi07f@gmail.com> * recover desiredCount in CreateService (mistake) Signed-off-by: t-kikuc <tkikuchi07f@gmail.com> * add mentioning driftdetection Signed-off-by: t-kikuc <tkikuchi07f@gmail.com> * Revert changes of adding ignoreDesiredCountOnUpdate This reverts commit a0f3459. Signed-off-by: t-kikuc <tkikuchi07f@gmail.com> * Revert commits of adding ignoreDesiredCount" This reverts commit 7d65824. Signed-off-by: t-kikuc <tkikuchi07f@gmail.com> * Revert "add docs" This reverts commit dcd7dc9. Signed-off-by: t-kikuc <tkikuchi07f@gmail.com> * Revert "Format func params and comment" This reverts commit 5103158. Signed-off-by: t-kikuc <tkikuchi07f@gmail.com> * Revert "Add a flag ignoreDesiredCountOnUpdate into each func" This reverts commit d17a9b7. Signed-off-by: t-kikuc <tkikuchi07f@gmail.com> * Revert "ignore desiredCount on updateService if needed" This reverts commit cf3efbf. Signed-off-by: t-kikuc <tkikuchi07f@gmail.com> * Revert "add a flag: ignoreDesiredCountOnUpdate" This reverts commit 6b2af75. Signed-off-by: t-kikuc <tkikuchi07f@gmail.com> * ignore updating desiredCount if it's 0 or not defined Signed-off-by: t-kikuc <tkikuchi07f@gmail.com> * Use pruning when 'recreate' is on Signed-off-by: t-kikuc <tkikuchi07f@gmail.com> * add docs Signed-off-by: t-kikuc <tkikuchi07f@gmail.com> * refine docs Signed-off-by: t-kikuc <tkikuchi07f@gmail.com> * Clarify procedure of configuring Signed-off-by: t-kikuc <tkikuchi07f@gmail.com> --------- Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>
…5030) * add a flag: ignoreDesiredCountOnUpdate Signed-off-by: t-kikuc <tkikuchi07f@gmail.com> * ignore desiredCount on updateService if needed Signed-off-by: t-kikuc <tkikuchi07f@gmail.com> * Add a flag ignoreDesiredCountOnUpdate into each func Signed-off-by: t-kikuc <tkikuchi07f@gmail.com> * Format func params and comment Signed-off-by: t-kikuc <tkikuchi07f@gmail.com> * add docs Signed-off-by: t-kikuc <tkikuchi07f@gmail.com> * fix tests: add a missing attribute Signed-off-by: t-kikuc <tkikuchi07f@gmail.com> * recover desiredCount in CreateService (mistake) Signed-off-by: t-kikuc <tkikuchi07f@gmail.com> * add mentioning driftdetection Signed-off-by: t-kikuc <tkikuchi07f@gmail.com> * Revert changes of adding ignoreDesiredCountOnUpdate This reverts commit a0f3459. Signed-off-by: t-kikuc <tkikuchi07f@gmail.com> * Revert commits of adding ignoreDesiredCount" This reverts commit 7d65824. Signed-off-by: t-kikuc <tkikuchi07f@gmail.com> * Revert "add docs" This reverts commit dcd7dc9. Signed-off-by: t-kikuc <tkikuchi07f@gmail.com> * Revert "Format func params and comment" This reverts commit 5103158. Signed-off-by: t-kikuc <tkikuchi07f@gmail.com> * Revert "Add a flag ignoreDesiredCountOnUpdate into each func" This reverts commit d17a9b7. Signed-off-by: t-kikuc <tkikuchi07f@gmail.com> * Revert "ignore desiredCount on updateService if needed" This reverts commit cf3efbf. Signed-off-by: t-kikuc <tkikuchi07f@gmail.com> * Revert "add a flag: ignoreDesiredCountOnUpdate" This reverts commit 6b2af75. Signed-off-by: t-kikuc <tkikuchi07f@gmail.com> * ignore updating desiredCount if it's 0 or not defined Signed-off-by: t-kikuc <tkikuchi07f@gmail.com> * Use pruning when 'recreate' is on Signed-off-by: t-kikuc <tkikuchi07f@gmail.com> * add docs Signed-off-by: t-kikuc <tkikuchi07f@gmail.com> * refine docs Signed-off-by: t-kikuc <tkikuchi07f@gmail.com> * Clarify procedure of configuring Signed-off-by: t-kikuc <tkikuchi07f@gmail.com> --------- Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>
* 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 <khanhtc1202@gmail.com> Co-authored-by: snyk-bot <snyk-bot@snyk.io> Signed-off-by: t-kikuc <tkikuchi07f@gmail.com> * 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 <snyk-bot@snyk.io> Signed-off-by: t-kikuc <tkikuchi07f@gmail.com> * 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 <tkikuchi07f@gmail.com> Co-authored-by: snyk-bot <snyk-bot@snyk.io> Co-authored-by: Tetsuya Kikuchi <97105818+t-kikuc@users.noreply.github.com> Signed-off-by: t-kikuc <tkikuchi07f@gmail.com> * 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 <snyk-bot@snyk.io> Signed-off-by: t-kikuc <tkikuchi07f@gmail.com> * [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 <shin@warashi.dev> * Bump alpine Signed-off-by: Shinnosuke Sawada-Dazai <shin@warashi.dev> --------- Signed-off-by: Shinnosuke Sawada-Dazai <shin@warashi.dev> Co-authored-by: snyk-bot <snyk-bot@snyk.io> Co-authored-by: Shinnosuke Sawada-Dazai <shin@warashi.dev> Signed-off-by: t-kikuc <tkikuchi07f@gmail.com> * Upgrade google-cloud-sdk (#5042) * Use x86_64 version of google-cloud-sdk Signed-off-by: Shinnosuke Sawada-Dazai <shin@warashi.dev> * Upgrade google-cloud-sdk Signed-off-by: Shinnosuke Sawada-Dazai <shin@warashi.dev> --------- Signed-off-by: Shinnosuke Sawada-Dazai <shin@warashi.dev> Signed-off-by: t-kikuc <tkikuchi07f@gmail.com> * 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 <26101787+hungran@users.noreply.github.com> * remove change in docs v0.47.x Signed-off-by: hungran <26101787+hungran@users.noreply.github.com> * update docs Signed-off-by: hungran <26101787+hungran@users.noreply.github.com> * update logic for having getGroupsAsString() Signed-off-by: hungran <26101787+hungran@users.noreply.github.com> * using <!subteam^ID> for group mentioning Signed-off-by: hungran <26101787+hungran@users.noreply.github.com> * typo Signed-off-by: hungran <26101787+hungran@users.noreply.github.com> * call both getAccountsAsString and getGroupsAsString Signed-off-by: hungran <26101787+hungran@users.noreply.github.com> * revert change pkg/model/notificationevent.pb.go Signed-off-by: hungran <26101787+hungran@users.noreply.github.com> * use same format for group <!subteam^ID> Signed-off-by: hungran <26101787+hungran@users.noreply.github.com> * same method to format slack group Signed-off-by: hungran <26101787+hungran@users.noreply.github.com> * following slack api, !subteam^ is a literal string that should not change Signed-off-by: hungran <26101787+hungran@users.noreply.github.com> * feat: add slackUsers field and mark slack as deprecated field Signed-off-by: hungran <26101787+hungran@users.noreply.github.com> * revert pkg/model/notificationevent.pb.go Signed-off-by: hungran <26101787+hungran@users.noreply.github.com> * update doc Using the groupID or teamID in the documents makes it easier for users to use this feature. Signed-off-by: hungran <26101787+hungran@users.noreply.github.com> * add code gen Signed-off-by: hungran <26101787+hungran@users.noreply.github.com> * adjust mention users and slack logic Signed-off-by: hungran <26101787+hungran@users.noreply.github.com> * unify the process to get users and groups in the same method Signed-off-by: hungran <26101787+hungran@users.noreply.github.com> --------- Signed-off-by: hungran <26101787+hungran@users.noreply.github.com> Signed-off-by: t-kikuc <tkikuchi07f@gmail.com> * Ignore `desiredCount` of ECS when it's 0 or not set for AutoScaling (#5030) * add a flag: ignoreDesiredCountOnUpdate Signed-off-by: t-kikuc <tkikuchi07f@gmail.com> * ignore desiredCount on updateService if needed Signed-off-by: t-kikuc <tkikuchi07f@gmail.com> * Add a flag ignoreDesiredCountOnUpdate into each func Signed-off-by: t-kikuc <tkikuchi07f@gmail.com> * Format func params and comment Signed-off-by: t-kikuc <tkikuchi07f@gmail.com> * add docs Signed-off-by: t-kikuc <tkikuchi07f@gmail.com> * fix tests: add a missing attribute Signed-off-by: t-kikuc <tkikuchi07f@gmail.com> * recover desiredCount in CreateService (mistake) Signed-off-by: t-kikuc <tkikuchi07f@gmail.com> * add mentioning driftdetection Signed-off-by: t-kikuc <tkikuchi07f@gmail.com> * Revert changes of adding ignoreDesiredCountOnUpdate This reverts commit a0f3459. Signed-off-by: t-kikuc <tkikuchi07f@gmail.com> * Revert commits of adding ignoreDesiredCount" This reverts commit 7d65824. Signed-off-by: t-kikuc <tkikuchi07f@gmail.com> * Revert "add docs" This reverts commit dcd7dc9. Signed-off-by: t-kikuc <tkikuchi07f@gmail.com> * Revert "Format func params and comment" This reverts commit 5103158. Signed-off-by: t-kikuc <tkikuchi07f@gmail.com> * Revert "Add a flag ignoreDesiredCountOnUpdate into each func" This reverts commit d17a9b7. Signed-off-by: t-kikuc <tkikuchi07f@gmail.com> * Revert "ignore desiredCount on updateService if needed" This reverts commit cf3efbf. Signed-off-by: t-kikuc <tkikuchi07f@gmail.com> * Revert "add a flag: ignoreDesiredCountOnUpdate" This reverts commit 6b2af75. Signed-off-by: t-kikuc <tkikuchi07f@gmail.com> * ignore updating desiredCount if it's 0 or not defined Signed-off-by: t-kikuc <tkikuchi07f@gmail.com> * Use pruning when 'recreate' is on Signed-off-by: t-kikuc <tkikuchi07f@gmail.com> * add docs Signed-off-by: t-kikuc <tkikuchi07f@gmail.com> * refine docs Signed-off-by: t-kikuc <tkikuchi07f@gmail.com> * Clarify procedure of configuring Signed-off-by: t-kikuc <tkikuchi07f@gmail.com> --------- Signed-off-by: t-kikuc <tkikuchi07f@gmail.com> --------- Signed-off-by: khanhtc1202 <khanhtc1202@gmail.com> Signed-off-by: t-kikuc <tkikuchi07f@gmail.com> Signed-off-by: Shinnosuke Sawada-Dazai <shin@warashi.dev> Signed-off-by: hungran <26101787+hungran@users.noreply.github.com> Co-authored-by: Khanh Tran <32532742+khanhtc1202@users.noreply.github.com> Co-authored-by: snyk-bot <snyk-bot@snyk.io> Co-authored-by: Chris Aniszczyk <caniszczyk@gmail.com> Co-authored-by: Shinnosuke Sawada-Dazai <shin@warashi.dev> Co-authored-by: Henry Vu <26101787+hungran@users.noreply.github.com>
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