Skip to content

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

stuggi
Copy link
Contributor

@stuggi stuggi commented Apr 11, 2025

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

@openshift-ci openshift-ci bot requested review from abays and viroel April 11, 2025 13:43
@stuggi
Copy link
Contributor Author

stuggi commented Apr 11, 2025

@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.

@stuggi stuggi requested review from slawqo and karelyatin and removed request for viroel April 11, 2025 13:45
Comment on lines -325 to -329
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())
Copy link
Contributor Author

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.

Copy link
Contributor

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

Copy link
Contributor

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 :)

Copy link
Contributor

@slawqo slawqo left a 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 {
Copy link
Contributor

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

Copy link
Contributor

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

Copy link
Contributor Author

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

[1] https://github.com/openstack-k8s-operators/lib-common/blob/main/modules/common/statefulset/statefulset.go#L142-L145

Copy link
Contributor

openshift-ci bot commented Apr 11, 2025

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@@ -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()
Copy link
Contributor

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.

Copy link
Contributor Author

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment on lines -325 to -329
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())
Copy link
Contributor

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]>
@stuggi
Copy link
Contributor Author

stuggi commented Apr 14, 2025

/retest

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants