-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Fix negative unavailable replicas #14046
Fix negative unavailable replicas #14046
Conversation
[test] |
func MaxUnavailable(config deployapi.DeploymentConfig) int32 { | ||
if !IsRollingConfig(&config) { | ||
func MaxUnavailable(config *deployapi.DeploymentConfig) int32 { | ||
if !IsRollingConfig(config) { |
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.
do we want to pass a pointer there when we don't mutate?
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 am not sure what the convention is but since in Go this would be just a shallow copy it can't guarantee you that you won't change the object so passing it by pointer makes it clear that the modifications might have a side effect + the struct is fairly large
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.
@tnozicka exactly
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.
one nit, LGTM |
rcs []*kapi.ReplicationController | ||
|
||
expected deployapi.DeploymentConfigStatus | ||
}{} |
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.
@Kargakis where are the test cases? this seems like an empty array...
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 add them today
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.
added unit tests to exercise the changes this PR introduces, ptal
func MaxUnavailable(config deployapi.DeploymentConfig) int32 { | ||
if !IsRollingConfig(&config) { | ||
func MaxUnavailable(config *deployapi.DeploymentConfig) int32 { | ||
if !IsRollingConfig(config) { |
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 am not sure what the convention is but since in Go this would be just a shallow copy it can't guarantee you that you won't change the object so passing it by pointer makes it clear that the modifications might have a side effect + the struct is fairly large
{ | ||
name: "unavailable deployment", | ||
|
||
dc: newDC(2, availableCond), |
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.
@Kargakis is this intentional or should it be unavailableCond
?
UpdatedReplicas: int32(0), | ||
UnavailableReplicas: int32(1), | ||
Conditions: []deployapi.DeploymentCondition{ | ||
availableCond, |
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.
same here
Signed-off-by: Michail Kargakis <[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
LGTM [merge] |
Evaluated for origin merge up to 9364ad8 |
test flake is #13943 [test] |
Evaluated for origin test up to 9364ad8 |
continuous-integration/openshift-jenkins/test FAILURE (https://ci.openshift.redhat.com/jenkins/job/test_pull_request_origin/1551/) (Base Commit: fb92178) |
continuous-integration/openshift-jenkins/merge SUCCESS (https://ci.openshift.redhat.com/jenkins/job/merge_pull_request_origin/702/) (Base Commit: 5e6c6f7) (Image: devenv-rhel7_6240) |
@mfojtik @tnozicka saw this in one of our jobs
https://ci.openshift.redhat.com/jenkins/view/All/job/ami_build_origin_int_rhel_fork/7/consoleFull#-169259343956c60d7be4b02b88ae8c268b
Similar fix to kubernetes/kubernetes#38299
Also fixes #11462
Still need to finish the unit test for calculateStatus but this is ready for reviews.