-
Notifications
You must be signed in to change notification settings - Fork 55
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
Rework replica logic #427
Rework replica logic #427
Conversation
Signed-off-by: Kim Tsao <ktsao@redhat.com>
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #427 +/- ##
==========================================
- Coverage 81.26% 81.22% -0.04%
==========================================
Files 32 32
Lines 4788 4848 +60
==========================================
+ Hits 3891 3938 +47
- Misses 705 713 +8
- Partials 192 197 +5 ☔ View full report in Codecov by Sentry. |
replica := resources.Deployments[0].Spec.Replicas | ||
if replica != nil { | ||
// if there is no component attribute, we will use the value in the deployment spec | ||
currentReplica = *replica | ||
} else { | ||
// default value is 1. We shouldn't hit this code path since this check is done in the update logic and will write the attribute deployment/replicas:1 | ||
currentReplica = 1 | ||
} |
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 think these lines can be simplified?
- we are checking if replica is set in deploy
- if it is, we are reading it and setting it back 🤔
Even when we are checking if its empty and setting it to 1, do we even need to? Its 1 by default in Kubernetes i.e. if you were to create a pod without this property there is only one repllca, no?
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.
It looks redundant but it's because we are searching for the component attribute key first in line 129
currentReplica := int32(component.Attributes.GetNumber(ReplicaKey, &replicaErr))
We are relying on the presence of the attribute to override anything that's set in deployment but if it doesn't exist, it'll return a KeyNotFoundError
and assign a 0 value. Similar to the previous comment it's there to "reset" the value
Signed-off-by: Kim Tsao <ktsao@redhat.com>
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: kim-tsao, maysunfaisal The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
What does this PR do?:
deployment/replicas: 1
will be written for the default case and will trigger an update to the component model.Which issue(s)/story(ies) does this PR fixes:
https://issues.redhat.com/browse/RHTAPBUGS-12
PR acceptance criteria:
Unit/Functional tests
Documentation
Client Impact
How to test changes / Special notes to the reviewer: