Skip to content
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

There are two clock packages with divergent history #94738

Closed
MikeSpreitzer opened this issue Sep 12, 2020 · 17 comments · Fixed by #109752
Closed

There are two clock packages with divergent history #94738

MikeSpreitzer opened this issue Sep 12, 2020 · 17 comments · Fixed by #109752
Assignees
Labels
kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery.

Comments

@MikeSpreitzer
Copy link
Member

What happened:
I discovered a need to update one of the two clock packages, and preparation for that revealed the divergent history of the two.

One line of development can be seen in

It looks like early on that was cloned into k8s.io/utils, and from there we have an independent line of development:

What you expected to happen:
The two clock packages would be kept in sync for a while and then one removed.

How to reproduce it (as minimally and precisely as possible):

Anything else we need to know?:

Environment:

  • Kubernetes version (use kubectl version):
  • Cloud provider or hardware configuration:
  • OS (e.g: cat /etc/os-release):
  • Kernel (e.g. uname -a):
  • Install tools:
  • Network plugin and version (if this is a network-related bug):
  • Others:
@MikeSpreitzer MikeSpreitzer added the kind/bug Categorizes issue or PR as related to a bug. label Sep 12, 2020
@k8s-ci-robot k8s-ci-robot added the needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. label Sep 12, 2020
@MikeSpreitzer
Copy link
Member Author

@kubernetes/sig-api-machinery-bugs

@k8s-ci-robot k8s-ci-robot added sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. and removed needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Sep 12, 2020
@liggitt liggitt added kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. and removed kind/bug Categorizes issue or PR as related to a bug. labels Sep 12, 2020
@lavalamp
Copy link
Member

Whoops! Thanks for noticing!

Tagging recent other editors: @munnerz @euank @kevindelgado

Which one should we keep?

@MikeSpreitzer
Copy link
Member Author

I think the one in k8s.io/utils is necessary, because it is consumed by component-base, on which apimachinery depends.

I created kubernetes/utils#190 to start fixing the clock package in utils.

@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Dec 14, 2020
@ash2k
Copy link
Member

ash2k commented Jan 3, 2021

/lifecycle frozen

@k8s-ci-robot k8s-ci-robot added lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Jan 3, 2021
@ash2k
Copy link
Member

ash2k commented Jan 10, 2021

/assign

@MadhavJivrajani
Copy link
Contributor

@MikeSpreitzer - once #105372 and #105375 are merged in, the codebase will be fully migrated away from k8s.io/apimachinery/pkg/util/clock.

How can we proceed with removal of this package? Is there some policy around this?
/assign

@wojtek-t
Copy link
Member

@lavalamp @liggitt ^^

[I would personally vote for just removing it - maybe just leaving some "doc" file to point to the new location of that. But let's maybe wait for others.]

@liggitt
Copy link
Member

liggitt commented Sep 30, 2021

There seem to be a lot of out-of-tree uses of it (https://grep.app/search?q=%22k8s.io/apimachinery/pkg/util/clock%22&filter[lang][0]=Go) ... if it's easy to use type aliases to map to matching k8s.io/utils interfaces/implementations and mark the k8s.io/apimachinery/pkg/util/clock versions deprecated for a release or two, that would ease people updating library versions

If that doesn't work or makes the package unmaintainable in some way, removing with a docs pointer seems ok.

@MadhavJivrajani
Copy link
Contributor

MadhavJivrajani commented Oct 22, 2021

Hey @liggitt 👋🏼
Before making any more changes, I wanted to get your opinion on where we go from here:
Following kubernetes/utils#224, since we cannot modify the interface anymore, one obvious approach that I can think of would be to introduce a new interface in k8s.io/utils/clock

// k8s.io/utils/clock
package clock
...
type WithTickerAndDelayedExecution interface {
    WithTicker
    AfterFunc(d time.Duration, f func()) Timer
}

And in k8s.io/apimachinery/pkg/util/clock (the one to deprecate)

// k8s.io/apimachinery/pkg/util/clock
package clock
clockUtils import "k8s.io/utils/clock"
type PassiveClock = clockUtils.PassiveClock
type Clock = clockUtils.WithTickerAndDelayedExecution
type RealClock = clockUtils.RealClock
// so on for fake clocks as well.

Does this sound OK?

@MadhavJivrajani
Copy link
Contributor

Friendly ping @liggitt ^ :)

@liggitt
Copy link
Member

liggitt commented Nov 9, 2021

I don't have strong opinions about the transition in k8s.io/apimachinery... using a matching library version there is expected

I'll defer to @wojtek-t on the plan for the utils interface... defining a new interface is the only real way I see to stay backward compatible with the existing exposed go API there. To avoid repeating issues of the past, settle on the final/full interface you need to collapse onto before merging to utils

@MadhavJivrajani
Copy link
Contributor

Hey @liggitt 👋🏼 Before making any more changes, I wanted to get your opinion on where we go from here: Following kubernetes/utils#224, since we cannot modify the interface anymore, one obvious approach that I can think of would be to introduce a new interface in k8s.io/utils/clock

// k8s.io/utils/clock
package clock
...
type WithTickerAndDelayedExecution interface {
    WithTicker
    AfterFunc(d time.Duration, f func()) Timer
}

And in k8s.io/apimachinery/pkg/util/clock (the one to deprecate)

// k8s.io/apimachinery/pkg/util/clock
package clock
clockUtils import "k8s.io/utils/clock"
type PassiveClock = clockUtils.PassiveClock
type Clock = clockUtils.WithTickerAndDelayedExecution
type RealClock = clockUtils.RealClock
// so on for fake clocks as well.

Does this sound OK?

@wojtek-t how does this sound to you wrt unblocking the migration?

@wojtek-t
Copy link
Member

@wojtek-t how does this sound to you wrt unblocking the migration?

This sounds good to me.
Given that we migrated everything finally, I think this is ok.

@MadhavJivrajani
Copy link
Contributor

Thanks @wojtek-t!
Based on the above, I tested out how the migration would look locally by making k8s.io/util/clock point to my local clone which has WithTickerAndDelayedExecution and it looks as follows: MadhavJivrajani@2757c57
Could you take a look whenever you get a chance and confirm if this is how we want to proceed? I just want to make sure that we are completely sure before making any more changes :)

@wojtek-t
Copy link
Member

Commented there

@MikeSpreitzer
Copy link
Member Author

Hooray! Thanks, @MadhavJivrajani !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants