cleanup(reporter): address review follow-ups on unchanged-condition skip - #334
Conversation
✅ Deploy Preview for node-readiness-controller ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Hi @LightCreator1007. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Tip We noticed you've done this a few times! Consider joining the org to skip this step and gain Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions 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. |
|
Thanks for iterating on this! /cc @AnuragThePathak as he had the original comments |
|
@ajaysundark: GitHub didn't allow me to request PR reviews from the following users: had, the, original, AnuragThePathak, as, he. Note that only kubernetes-sigs members and repo collaborators can review this PR, and authors cannot review their own PRs. DetailsIn 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 kubernetes-sigs/prow repository. |
AnuragThePathak
left a comment
There was a problem hiding this comment.
Thanks for following up @LightCreator1007 glad you decided not to wrap up the chapter with merging of the original PR.
|
/cc @AnuragThePathak |
|
/ok-to-test |
| } | ||
| } | ||
|
|
||
| if !found { |
There was a problem hiding this comment.
I must admit, this is something I never had my eyes on, and didn't anticipate this change either until I saw this today (the major reason being it was not part of what you changed earlier and existed way before that). This slightly makes me question whether your former approach to use existingCondition was actually better, but considering that involves pointer, and considering simplicity of our current needs I'm approving this.
|
/assign @ajaysundark |
|
/unassign @ajaysundark |
AnuragThePathak
left a comment
There was a problem hiding this comment.
I have two more suggestions, I see that we are not testing two situations now.
- Smoke test for node not found error path
- Validation of the LastTransitionTime
Since we spent so much time refactoring, I think working on these two and sealing these two will elevate the standard of this method significantly.
|
|
||
| countUpdates := func() int { | ||
| n := 0 | ||
| updateCalled := func() bool { |
There was a problem hiding this comment.
About this, I gave some thought about this, I think your original approach of counting was better. So please revert this one.
But change the wantUpdateCalled to integer value (update name of that variable too as wantUpdateCalled sounds boolean to anyone).
|
Heads up, #367 merged into
Keeping both, in either order, clears it. I resolved it that way locally and It might also sort itself out. The review note above suggests folding that case into the existing table rather than keeping a separate test, and if Sorry about the collision, that was my PR that landed. |
AnuragThePathak
left a comment
There was a problem hiding this comment.
Remaining looks good other than the addressed 3
| for _, a := range client.Actions() { | ||
| if a.GetVerb() == "update" && a.GetSubresource() == "status" && a.GetResource().Resource == "nodes" { | ||
| n++ | ||
| var objs []runtime.Object |
There was a problem hiding this comment.
var client *fake.Clientset
if tt.existingNode != nil {
client = fake.NewClientset(tt.existingNode)
} else {
client = fake.NewClientset()
}
var previousTransition metav1.Time
if tt.existingNode != nil {
for _, cond := range tt.existingNode.Status.Conditions {
if string(cond.Type) == conditionType {
previousTransition = cond.LastTransitionTime
break
}
}
}
if previousTransition.IsZero() {
previousTransition = metav1.NewTime(time.Now())
}Decouple client and previousTransition.
|
|
||
| err := updateNodeCondition(context.Background(), client, nodeName, conditionType, tt.health, tt.heartbeatPeriod) | ||
| if tt.existingNode == nil { | ||
| if !apierrors.IsNotFound(err) { |
There was a problem hiding this comment.
This log/condition won't tell exact failure scenario, as it doesn't differentiate between no error and error being something other than not found.
if err != nil {
if tt.wantNotFoundErr {
if !apierrors.IsNotFound(err) {
t.Fatalf("updateNodeCondition() error = %v, want a NotFound error", err)
}
if got := countUpdateCalls(client); got != tt.wantUpdateCount {
t.Errorf("UpdateStatus called = %v, want %v", got, tt.wantUpdateCount)
}
return
}
t.Fatalf("updateNodeCondition() error = %v", err)
}
if tt.wantNotFoundErr {
t.Fatalf("updateNodeCondition() succeeded, want a NotFound error")
}Also introduced wantNotFoundErr because inputs in tests are not often expected to remain the same during the runtime most often.
| wantStatus corev1.ConditionStatus | ||
| wantReason string | ||
| wantUpdateCount int | ||
| wantTransitionPreserved bool |
AnuragThePathak
left a comment
There was a problem hiding this comment.
@ajaysundark this one looks good to me. Feel free to merge as per release and other convince as no functional change
| return n | ||
| } | ||
| if previousTransition.IsZero() { | ||
| previousTransition = metav1.NewTime(time.Now()) |
There was a problem hiding this comment.
nit: it'd be good to base previousTransition to a fixed / deterministic timestamp instead of injecting 'now' as you're using it to comparing later.
ajaysundark
left a comment
There was a problem hiding this comment.
@LightCreator1007 Thanks for this nice refactor!
added a nit comment (non blocking) if you could find time to update, please consider handling this.
/hold
/lgtm
/approve
edc3734 to
158bfa3
Compare
|
Thanks @LightCreator1007 @AnuragThePathak ! |
AnuragThePathak
left a comment
There was a problem hiding this comment.
LGTM with the update on deterministic previousTransistion. We are not exactly testing the equality of time stamp, time.Now() put by the updateNodeCondition, but that should be fine I believe in current situation I think.
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: ajaysundark, AnuragThePathak, LightCreator1007 The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Description
Follow-up to #263, addressing the review comments left open when it merged.
needsUpdateflag and the separatetransitionTimevariable, the split logic was hard to follow.heartbeatPeriodrather than a hardcoded "5 minutes", since the period is configurable.State change triggers immediate writetoupdate condition on state change— the immediate write is the outcome, not the cause, and is now noted in a comment.No behaviour change.
Related Issue
None
Type of Change
/kind cleanup
Testing
This change is a refactor only.
Checklist
make testpassesmake lintpassesDoes this PR introduce a user-facing change?