-
Notifications
You must be signed in to change notification settings - Fork 38.6k
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
add StatefulSet MinReadySeconds e2e test #104078
Conversation
Hi @atiratree. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. 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/test-infra 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.
Thank you for the PR @atiratree. Please look at my comments.
setHTTPProbe(ss) | ||
ss, err := c.AppsV1().StatefulSets(ns).Create(context.TODO(), ss, metav1.CreateOptions{}) | ||
framework.ExpectNoError(err) | ||
e2estatefulset.WaitForStatusAvailableReplicas(c, ss, 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.
Why this 0? Do you want to show that the replicas won't be available immediately? If yes, this could be racy if reaching this statement would take more than 10 seconds.
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 did not want to put a longer time so the test can complete quickly.
There are two ways to solve this.
- make MinReadySeconds a bit higher - eg 30s? (test takes longer)
- remove the 0 check
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.
@ravisantoshgudimetla and yes I want to check the replicas are not available immediately
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.
Kube as a whole is eventually consistent. So, better to make the value here longer like 30 seconds as you mentioned and wait till 5 or 10 seconds and make sure that the AvailableReplicas is not updated. Even this may be racy somtimes. I'd prefer having -ve tests in integration of units by faking clock.
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.
for now I put 30 there with the additional wait (thanks for the suggestion). I expect it not be that racy since we are just waiting for the controller to pick up the resource and set 0 (so waiting time should be our poll 10s)
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 can revisit the test if it is failing(flaking).
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 have similar concerns here as Ravi, this might be flaking when STS controller immediately creates the first replica and you'll never meet 0 status 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.
This is not about the creation of a replica, but about the availability and since we set MinReadySeconds to 30 we should observe 0 for the first 30 seconds. WaitForStatusAvailableReplicas is waiting only 0-10s to observe the 0 to prevent the race
test/e2e/apps/statefulset.go
Outdated
@@ -1154,6 +1154,42 @@ var _ = SIGDescribe("StatefulSet", func() { | |||
framework.ExpectNoError(err) | |||
e2estatefulset.WaitForStatusAvailableReplicas(c, ss, 1) | |||
}) | |||
|
|||
ginkgo.It("MinReadySeconds should update availableReplicas accordingly when enabled [Feature:StatefulSetMinReadySeconds] [alpha]", func() { |
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.
AvailableReplicas should depend on the MinReadySeconds value specified?
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.
updated
|
||
ginkgo.By("check Available Replicas are shown in status") | ||
out, err := framework.RunKubectl(ns, "get", "statefulset", ss.Name, "-o=yaml") | ||
framework.ExpectNoError(err) |
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.
Please add a comment.
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.
isn't the .By
enough? What else do you have in mind?
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.
Ya, By
is good enough, I usually add a comment to separate code for different tests.
f749b15
to
59e674f
Compare
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.
Just some nits but looks good for me.
@soltysh can you review as well?
59e674f
to
5172c2b
Compare
5172c2b
to
c2a91d9
Compare
/kind cleanup |
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.
setHTTPProbe(ss) | ||
ss, err := c.AppsV1().StatefulSets(ns).Create(context.TODO(), ss, metav1.CreateOptions{}) | ||
framework.ExpectNoError(err) | ||
e2estatefulset.WaitForStatusAvailableReplicas(c, ss, 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.
We can revisit the test if it is failing(flaking).
/retest |
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.
A few nits, but mostly looks good.
/ok-to-test
/priority backlog
/traige accepted
/approve
/assign @ravisantoshgudimetla
for final lgtm
test/e2e/apps/statefulset.go
Outdated
@@ -1154,6 +1154,50 @@ var _ = SIGDescribe("StatefulSet", func() { | |||
framework.ExpectNoError(err) | |||
e2estatefulset.WaitForStatusAvailableReplicas(c, ss, 1) | |||
}) | |||
|
|||
ginkgo.It("AvailableReplicas should get updated accordingly when MinReadySeconds is enabled [Feature:StatefulSetMinReadySeconds] [alpha]", func() { |
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: this is beta now that we merged #104045
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.
thanks, fixed
setHTTPProbe(ss) | ||
ss, err := c.AppsV1().StatefulSets(ns).Create(context.TODO(), ss, metav1.CreateOptions{}) | ||
framework.ExpectNoError(err) | ||
e2estatefulset.WaitForStatusAvailableReplicas(c, ss, 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 have similar concerns here as Ravi, this might be flaking when STS controller immediately creates the first replica and you'll never meet 0 status condition.
framework.ExpectNoError(err) | ||
e2estatefulset.WaitForStatusAvailableReplicas(c, ss, 0) | ||
// let's check that the availableReplicas have still not updated | ||
time.Sleep(5 * time.Second) |
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'd prefer not to use time.Sleep
but rather add those extra 5s in the next WaitFor...
, if needed.
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.
Although looking at WaitForStatusAvailableReplicas
it waits up to 10mins, so you can just drop that bit.
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.
as mentioned in #104078 (comment) we might observe 0 AvailableReplicas immediately and this ensures that we wait at least 5 seconds to check it still stays 0.
The next WaitForStatusAvailableReplicas check for Availability. This one checks for UnAvailability
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.
Oh, I see what you mean, I missed the initial MinReadySeconds
being set, I assumed it's not.
600b9ce
to
2cad64d
Compare
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
framework.ExpectNoError(err) | ||
e2estatefulset.WaitForStatusAvailableReplicas(c, ss, 0) | ||
// let's check that the availableReplicas have still not updated | ||
time.Sleep(5 * time.Second) |
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.
Oh, I see what you mean, I missed the initial MinReadySeconds
being set, I assumed it's not.
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: atiratree, soltysh 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 |
/triage accepted |
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.
Verfication failed, other than that LGTM.
/retest |
What type of PR is this?
What this PR does / why we need it:
2nd part of #103073 adding additional e2e test:
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: