-
Notifications
You must be signed in to change notification settings - Fork 226
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
OCPBUGS-23435: Fix Progressing and Degraded condition during workload rollouts. #1855
base: master
Are you sure you want to change the base?
Conversation
@atiratree: This pull request references Jira Issue OCPBUGS-23435, which is invalid:
Comment The bug has been updated to refer to the pull request using the external bug tracker. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
/jira refresh |
@atiratree: This pull request references Jira Issue OCPBUGS-23435, which is valid. The bug has been moved to the POST state. 3 validation(s) were run on this bug
Requesting review from QA contact: In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
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.
Looks good to me. Dropped 2 unblocker comments.
@@ -353,6 +375,33 @@ func isUpdatingTooLong(operatorStatus *operatorv1.OperatorStatus, progressingCon | |||
return progressing != nil && progressing.Status == operatorv1.ConditionTrue && time.Now().After(progressing.LastTransitionTime.Add(15*time.Minute)), nil | |||
} | |||
|
|||
// hasDeploymentProgressed returns true if the deployment reports NewReplicaSetAvailable | |||
// via the DeploymentProgressing condition | |||
func hasDeploymentProgressed(status appsv1.DeploymentStatus) bool { |
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.
nit:
func hasDeploymentProgressed(status appsv1.DeploymentStatus) bool { | |
func hasDeploymentProgressed(status appsv1.DeploymentStatus) bool { | |
for _, cond := range status.Conditions { | |
if cond.Type == appsv1.DeploymentProgressing { | |
return cond.Status == corev1.ConditionTrue && cond.Reason == "NewReplicaSetAvailable" | |
} | |
} | |
return false | |
} |
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.
yup, that looks better - I have mostly copied the utility functions from k/k :D
func hasDeploymentProgressed(status appsv1.DeploymentStatus) bool { | ||
for i := range status.Conditions { | ||
c := status.Conditions[i] | ||
if c.Type == appsv1.DeploymentProgressing { |
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.
Would it make sense taking workloadIsBeingUpdated := workload.Status.UpdatedReplicas < desiredReplicas
into account in addition to this? or NewReplicaSetAvailable
is already covering?
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.
that is already covered by the condition
- https://github.com/kubernetes/kubernetes/blob/5ffb0528dd0ca2faa9c8c4c360216268926ee0ee/pkg/controller/deployment/progress.go#L60
- https://github.com/kubernetes/kubernetes/blob/5ffb0528dd0ca2faa9c8c4c360216268926ee0ee/pkg/controller/deployment/util/deployment_util.go#L708
There can be a short amount of time when this condition is stale, before the deployment controller observes the new revision - so I made the workloadIsBeingUpdated
variable depend also on the workloadAtHighestGeneration
and added a test case for that.
9d0ad43
to
015ac38
Compare
/lgtm |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: ardaguclu, atiratree The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
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.
Can you create a proof PR for an operator that makes heavy use of this controller?
// update is done when all pods have been updated to the latest revision | ||
// and the deployment controller has reported NewReplicaSetAvailable | ||
workloadIsBeingUpdated := !workloadAtHighestGeneration || !hasDeploymentProgressed(workload.Status) | ||
workloadHasOldTerminatingPods := workload.Status.AvailableReplicas == desiredReplicas && terminatingPods > 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.
In theory this math could indicate a terminating pod that's not actually "old", right?
Like, desiredReplicas == 3
and I have AvailableReplicas == 3
, but one of the available replicas is an old pod, and one of the terminating pods is not "old".
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 mostly works (workload.Status.AvailableReplicas
does not include terminating replica), but yeah there is one edge case. If you delete a new pod and it terminates for a longer time then the new one takes to become available. Then this status would be incorrect.
I originally wanted to bring in the deployment controller logic in, but in the end decided against it. It would require a lot of code for matching pods/hashes and revisions/replicasets. And I would prefer not to maintain this logic.
I have noticed that all of the uses of the WorkloadController use EnsureAtMostOnePodPerNode
function in the following repos:
- https://github.com/openshift/cluster-authentication-operator
- https://github.com/openshift/cluster-openshift-apiserver-operator
When we depend on the DeploymentProgressing
condition from now on and EnsureAtMostOnePodPerNode
function, we first terminate the pod on each node before we create a new one.
So I have removed the terminating pods logic and added a note that this is a user of this controller responsibility to ensure if old terminating pods can be a part of the complete deployment or not. Which is done by using EnsureAtMostOnePodPerNode
together with this PR. Or it can be also done by a DeploymentPodReplacementPolicy
feature once it is merged upstream.
deploymentProgressingCondition = deploymentProgressingCondition. | ||
WithStatus(operatorv1.ConditionTrue). | ||
WithReason("PreviousGenerationPodsPresent"). | ||
WithMessage(fmt.Sprintf("deployment/%s.%s: %d pod(s) from the previous generation are still present", workload.Name, c.targetNamespace, terminatingPods)) |
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 don't see any changes to the Degraded condition, could you explain how this patch fixes it? Is it somehow affected by this hunk?
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.
The condition resolution is changed by the workloadIsBeingUpdated
variable which depends on the Deployment's Progressing
condition now
015ac38
to
7b42f2b
Compare
New changes are detected. LGTM label has been removed. |
Deployment rollout should depend on the Deployment Progressing condition to asses the state of the deployment as there can be unavailable pods during the deployment. This is capped by a 15 minute deadline. As a result - Degraded condition should be False during the deployment rollout. - Progressing condition should be True during the deployment rollout. Co-authored-by: Standa Láznička <[email protected]>
7b42f2b
to
8989fea
Compare
@atiratree: This pull request references Jira Issue OCPBUGS-23435, which is valid. 3 validation(s) were run on this bug
Requesting review from QA contact: In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
@atiratree: all tests passed! Full PR test history. Your PR dashboard. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
Deployment rollout should depend on the Deployment Progressing condition
to asses the state of the deployment as there can be unavailable pods
during the deployment. This is capped by a 15 minute deadline. As a result
followup for #1732