-
Notifications
You must be signed in to change notification settings - Fork 277
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
Replace time.Now()
with clock.Clock.Now()
in pkg/pod
#3775
base: main
Are you sure you want to change the base?
Conversation
Hi @TusharMohapatra07. 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 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-sigs/prow repository. |
✅ Deploy Preview for kubernetes-sigs-kueue canceled.
|
/ok-to-test |
Please take a look at this kueue/pkg/controller/jobs/pod/pod_controller.go Line 1331 in bd1b989
|
I think here
|
/test all |
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
Thanks!
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: mbobrovskyi, TusharMohapatra07 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 |
LGTM label has been added. Git tree hash: 61d3b47cefc9c126048fe8f7e1ba6dcc33707d7f
|
@@ -206,6 +209,13 @@ func (p *Pod) isUnretriableGroup() bool { | |||
return false | |||
} | |||
|
|||
func (p *Pod) getClock() clock.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.
Instead a function like this - can we please make sure the clock is always set, this will make the code much simpler to reason about, and can prevent panics when someone assumes it is set and forgets to call the function. It is very hard to see this type of a bug when reviewing and seeing on GH only fragment of the code.
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.
@mimowo So, pod doesnot have a constructor so, we can no more implement options in it. What other approach do you think would fit in this situation ?
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 synced with @PBundyra and he should be able to help more, but I think it you could make this work with:
- make the
lastActiveTime
andsortInactivePods
to be receiving the (p *Pod) received fromFindMatchingWorkloads
- then we could have a function like
NewPod
accepting the clock (possibly as an option). In production code pass the real clock, and in tests the fake one
You can follow the pattern for the WorkloadReconciler from workload_controller.go
What all fields should i include in the argument so that it must and should be passed while called (rest could be made passed as an option)
For Example, in
|
What type of PR is this?
/kind cleanup
What this PR does / why we need it:
Replaces
time.Now()
to use the Now() function present insideclock
package.Which issue(s) this PR fixes:
Part of #3380
Special notes for your reviewer:
This PR is work-in-progress.