-
Notifications
You must be signed in to change notification settings - Fork 521
CLOUDP-69096: Implement correct scale down logic #190
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
Changes from all commits
276c030
b9bdad0
595b45e
1173c31
b915732
017f6e4
3cc7e22
50e55e5
5a6137d
a9a606b
6469e8c
c141d78
3fbe0bd
b29d4d3
71d7f4b
531394e
d74ce96
cc4033c
7fefc74
b474a1d
741f9c8
bc22e44
c63f8da
9fb4105
13ab601
f970435
a8ca532
76aeef6
fadd770
b8fc319
be838db
eaceb22
0055b25
3cee13a
8990f71
31f74a0
62e6693
13b0031
8252180
ae19bde
935e9f9
c36a4a0
95c7c1a
969b2ba
e5b1ad2
a9b892c
6b04176
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,7 +31,8 @@ spec: | |
| - name: OPERATOR_NAME | ||
| value: "mongodb-kubernetes-operator" | ||
| - name: AGENT_IMAGE # The MongoDB Agent the operator will deploy to manage MongoDB deployments | ||
| value: quay.io/mongodb/mongodb-agent:10.19.0.6562-1 | ||
| value: quay.io/mongodb/mongodb-agent-dev:scaledown | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this image is the same as the previous one, but just with a new readiness probe, I will create a separate PR once this is no longer a dev image. |
||
| # value: quay.io/mongodb/mongodb-agent:10.19.0.6562-1 | ||
| - name: VERSION_UPGRADE_HOOK_IMAGE | ||
| value: quay.io/mongodb/mongodb-kubernetes-operator-version-upgrade-post-start-hook:1.0.2 | ||
| - name: MONGODB_IMAGE | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -201,8 +201,11 @@ type AuthMode string | |
| type MongoDBStatus struct { | ||
| MongoURI string `json:"mongoUri"` | ||
| Phase Phase `json:"phase"` | ||
| Members int `json:"members"` | ||
| Message string `json:"message,omitempty"` | ||
|
|
||
| CurrentStatefulSetReplicas int `json:"currentStatefulSetReplicas"` | ||
| CurrentMongoDBMembers int `json:"currentMongoDBMembers"` | ||
|
|
||
| Message string `json:"message,omitempty"` | ||
| } | ||
|
|
||
| // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object | ||
|
|
@@ -220,16 +223,13 @@ type MongoDB struct { | |
| Status MongoDBStatus `json:"status,omitempty"` | ||
| } | ||
|
|
||
| func (m MongoDB) DesiredReplicas() int { | ||
| return m.Spec.Members | ||
| } | ||
|
|
||
| func (m MongoDB) CurrentReplicas() int { | ||
| return m.Status.Members | ||
| } | ||
|
|
||
| func (m *MongoDB) ReplicasThisReconciliation() int { | ||
| return scale.ReplicasThisReconciliation(m) | ||
| func (m MongoDB) AutomationConfigMembersThisReconciliation() int { | ||
| // determine the correct number of automation config replica set members | ||
| // based on our desired number, and our current number | ||
| return scale.ReplicasThisReconciliation(automationConfigReplicasScaler{ | ||
| desired: m.Spec.Members, | ||
| current: m.Status.CurrentMongoDBMembers, | ||
| }) | ||
| } | ||
|
|
||
| // MongoURI returns a mongo uri which can be used to connect to this deployment | ||
|
|
@@ -298,6 +298,30 @@ func (m MongoDB) GetFCV() string { | |
| return strings.Join(parts[:minorIndex+1], ".") | ||
| } | ||
|
|
||
| func (m MongoDB) DesiredReplicas() int { | ||
| return m.Spec.Members | ||
| } | ||
|
|
||
| func (m MongoDB) CurrentReplicas() int { | ||
| return m.Status.CurrentStatefulSetReplicas | ||
| } | ||
|
|
||
| func (m *MongoDB) StatefulSetReplicasThisReconciliation() int { | ||
| return scale.ReplicasThisReconciliation(m) | ||
| } | ||
|
|
||
| type automationConfigReplicasScaler struct { | ||
| current, desired int | ||
| } | ||
|
|
||
| func (a automationConfigReplicasScaler) DesiredReplicas() int { | ||
| return a.desired | ||
| } | ||
|
|
||
| func (a automationConfigReplicasScaler) CurrentReplicas() int { | ||
| return a.current | ||
| } | ||
|
Comment on lines
+301
to
+323
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. re-use existing interface to allow us to get the correct number of automation config members each reconciliation (we will get all of them on first creation, otherwise we scale up/down one at a time) |
||
|
|
||
| // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object | ||
|
|
||
| // MongoDBList contains a list of MongoDB | ||
|
|
||
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.
Will update this again once I've moved the readiness probe to the correct bucket