Skip to content

Conversation

@kevindelgado
Copy link
Contributor

What type of PR is this?
/kind bug

What this PR does / why we need it:
Currently, FakeClock::Reset only successfully resets the timer and returns true when the timer has neither fired nor been stopped.

This is incorrect behavior as real clocks allow for resetting in both of those situations (as long has the channel has been drained).

This is useful in tests that use a fake clock to test wait.BackofManager, as the timer resets after each iteration of Backoff() after the timer has already fired.

Does this PR introduce a user-facing change?:

NONE

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. kind/bug Categorizes issue or PR as related to a bug. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Aug 28, 2020
@k8s-ci-robot
Copy link
Contributor

Hi @kevindelgado. 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 /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

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.

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Aug 28, 2020
@kevindelgado
Copy link
Contributor Author

This PR came about while trying to write the unit test for #94235 using a fake clock instead of a real clock. The way the backoff manager resets its timer after successive iterations exposed the fact that the current fake clock implementation does not allow for resetting fake timers that have already fired.

@kevindelgado
Copy link
Contributor Author

One outstanding question I have is whether this conflicts with the behavior previously fixed by 3e898d6#diff-2feab94c4d7d3f50c86be9853504ace6L313-L319. It seems to me that previously Reset() would reset the timer if already fired (while returning false).

I’m unclear on the context of that change and if this is reverting something that was intentionally modified (albeit, it was modified to a behavior misaligned with the behavior of real clock).

@kevindelgado
Copy link
Contributor Author

/cc @lavalamp

@kevindelgado
Copy link
Contributor Author

/assign @caesarxuchao

@lavalamp
Copy link
Contributor

/ok-to-test

Let's see if this breaks anything :)

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Aug 28, 2020
@kevindelgado
Copy link
Contributor Author

looks like it passed, PTAL @lavalamp

Current FakeClock::Reset only successfully resets the timer and
returns true when the timer has neither fired nore been stopped.

This is incorrect behavior as real clocks allow for reseting
in both of those situations (as long has the channel has been drained).

This is useful in tests that use a fake clock to test
wait.BackofManager, as the timer resets after each iteration of
Backoff() after the timer has already fired.
@kevindelgado kevindelgado force-pushed the draft/fix-fakeclock-reset branch from 5a7404a to 7e7ee90 Compare September 1, 2020 18:12
@kevindelgado
Copy link
Contributor Author

/test pull-kubernetes-e2e-kind

@lavalamp
Copy link
Contributor

lavalamp commented Sep 1, 2020

/lgtm
/approve
/milestone 1.20

thanks a ton for fixing this! I don't think this should break e2e tests, only unit tests. So should be good to go.

@k8s-ci-robot
Copy link
Contributor

@lavalamp: The provided milestone is not valid for this repository. Milestones in this repository: [next-candidate, v1.16, v1.17, v1.18, v1.19, v1.20-phase-bug-low-risk, v1.20-phase-bug, v1.20-phase-feature, v1.20, v1.21, v1.22]

Use /milestone clear to clear the milestone.

In response to this:

/lgtm
/approve
/milestone 1.20

thanks a ton for fixing this! I don't think this should break e2e tests, only unit tests. So should be good to go.

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.

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 1, 2020
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: kevindelgado, lavalamp

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 1, 2020
@lavalamp
Copy link
Contributor

lavalamp commented Sep 1, 2020

/milestone v1.20

Missing the v, I guess that's v for "very sure I want 1.20".

@k8s-ci-robot k8s-ci-robot added this to the v1.20 milestone Sep 1, 2020
@kevindelgado
Copy link
Contributor Author

/remove-needs-sig

@justaugustus
Copy link
Member

@justaugustus justaugustus removed the needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. label Sep 2, 2020
@k8s-ci-robot k8s-ci-robot merged commit d8eac8d into kubernetes:master Sep 2, 2020
@kevindelgado kevindelgado deleted the draft/fix-fakeclock-reset branch September 3, 2020 00:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note-none Denotes a PR that doesn't merit a release note. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants