-
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()
code with clock.Clock.Now()
#3380
Comments
/cc @mbobrovskyi |
can i work on this issue ? @PBundyra @mbobrovskyi |
Sure, please take it. |
@mbobrovskyi thanks! i'm on it |
/assign @TusharMohapatra07 |
@mbobrovskyi am i supposed to change the time.Now() instance everywhere inside the project or just those instances which are present inside pkg folder ?? |
Let's focus on
|
I would say the end goal is to use it everywhere, but starting with scheduler might be a good idea to see if there are any obstacles, then feel free to follow up in the next PR. |
@mimowo understood |
…e in pkg/scheduler(#3380) (#3421) * refactor time.Now() in pkg/scheduler * replace time.Since() with Since() present in clock package * add new option to provide fakeclock to scheduler * add realClock to options and pass in fakeClock while testing * use options.clock instead of realClock * add more fakeClock(s)
/reopen To fix it in other places. |
@mbobrovskyi: Reopened this issue. In 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. |
@mbobrovskyi yes, i'm on it |
@mbobrovskyi I don't see any significant place to replace time.Now in |
What about this one kueue/pkg/workload/admissionchecks.go Line 96 in 0f54466
Also here kueue/pkg/workload/admissionchecks.go Line 110 in 0f54466
Could you please check is it possible to propagate This is an example kueue/pkg/workload/admissionchecks.go Line 32 in 0f54466
|
@mbobrovskyi Actually, LastTransitionTime takes metav1.Time, so time.Time won't work ig. We could probably pass in the clock.Clock interface inside the function to proceed with this.. |
Why we can't use like this I think just propagation to function is enough for it. Also |
@mbobrovskyi so, if we propogate it in the function, we have to pass it whenever we're calling the function ? kueue/pkg/scheduler/preemption/preemption.go Line 225 in 0f54466
|
Exactly and Preemptor should have clock? If not please add to Preemptor as well. |
@mbobrovskyi understood |
Hey @mbobrovskyi, sorry for being late but i'm a bit busy with some commitments. I'll restart working on this in a day or two. |
…e in pkg/scheduler(kubernetes-sigs#3380) (kubernetes-sigs#3421) * refactor time.Now() in pkg/scheduler * replace time.Since() with Since() present in clock package * add new option to provide fakeclock to scheduler * add realClock to options and pass in fakeClock while testing * use options.clock instead of realClock * add more fakeClock(s)
What would you like to be added:
There are packages like e.g.
pkg/scheduler
that usetime.Now()
. As a result this code is hard to test and prone to flakiness as we are not able to directly control the time during tests. It should be replaced withclock.Clock.Now()
as it is in WorkloadControllerWhy is this needed:
Completion requirements:
This enhancement requires the following artifacts:
The artifacts should be linked in subsequent comments.
The text was updated successfully, but these errors were encountered: