-
Notifications
You must be signed in to change notification settings - Fork 37
Use statefulset.IsReady() to validate status #430
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
base: main
Are you sure you want to change the base?
Conversation
@slawqo @karelyatin can you please review if this is appropriate for the ovndbcluster statefulset. I did not fully get the current envtest and the update I did is good. |
Eventually(func(g Gomega) { | ||
conditions := GetOVNDBCluster(dbs[0]).Status.Conditions | ||
cond := conditions.Get(condition.ExposeServiceReadyCondition) | ||
g.Expect(cond.Status).To(Equal(corev1.ConditionFalse)) | ||
}).Should(Succeed()) |
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.
this error part is not what I got.
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 error was added on purpose some months back by @averdagu , let's check that first
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.
Hi, sorry for late response. This test was added due to OSPRH-6798. Where it could happen some panic due to checking Out of Range item on a list. What this test is checking is to not report ready if pods are not created.
Eventho this test scales up the replicas to 3, reconcile loop won't create the new pods (and len(pods) will always be 1), this is like this due to pods are created on function CreateOVNDBClusters more specifically on SimulateStatefulSetReplicaReadyWithPods.
I checked the code with master, tomorrow will check code with your code to see why you're not seeing this error :)
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 for me
@@ -662,7 +665,7 @@ func (r *OVNDBClusterReconciler) reconcileNormal(ctx context.Context, instance * | |||
return ctrl.Result{}, err | |||
} | |||
|
|||
if instance.Status.ReadyCount > 0 && len(svcList.Items) > 0 { | |||
if statefulset.IsReady(deploy) && len(svcList.Items) > 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.
I may be wrong here but I don't really know why we need this additional condition there really. Maybe @karelyatin will know something more about it
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 need to ensure statefulset is ready before setting Ready Condition
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.
thats what statefulset.IsReady(deploy)
is checking [1]. it is not just checking that we have >0 replica, it is checking:
// IsReady - validates when deployment is ready deployed to whats being requested
// - the requested replicas in the spec matches the ReadyReplicas of the status
// - both when the Generatation of the object matches the ObservedGeneration of the Status
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: slawqo, stuggi 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 |
@@ -603,7 +603,10 @@ func (r *OVNDBClusterReconciler) reconcileNormal(ctx context.Context, instance * | |||
return ctrlResult, nil | |||
} | |||
|
|||
instance.Status.ReadyCount = sfset.GetStatefulSet().Status.ReadyReplicas | |||
deploy := sfset.GetStatefulSet() |
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.
hmm we shoudn't use "deploy" vars for statefulsets :) , we need to cleanup some conditions too for this.
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 can do that, I kept it as deploy
since a statefulset is basically also a deployment. let me change it
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.
done
Eventually(func(g Gomega) { | ||
conditions := GetOVNDBCluster(dbs[0]).Status.Conditions | ||
cond := conditions.Get(condition.ExposeServiceReadyCondition) | ||
g.Expect(cond.Status).To(Equal(corev1.ConditionFalse)) | ||
}).Should(Succeed()) |
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 error was added on purpose some months back by @averdagu , let's check that first
Changes to use the common IsReady() func to validate a deployment is fully up as requested and e.g. no update rollout in progress. During a minor update this has seen to already report/mark the condition ready, even the deployment is still in progress, or the replacement pod failed. Jira: OSPRH-14472 Depends-On: openstack-k8s-operators/lib-common#616 Signed-off-by: Martin Schuppert <[email protected]>
/retest |
Changes to use the common IsReady() func to validate a deployment is fully up as requested and e.g. no update rollout in progress. During a minor update this has seen to already report/mark the condition ready, even the deployment is still in progress, or the replacement pod failed.
Jira: OSPRH-14472
Depends-On: openstack-k8s-operators/lib-common#616