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

chore: Fix possible Registration TTL race condition #1665

Conversation

jonathan-innis
Copy link
Member

@jonathan-innis jonathan-innis commented Sep 15, 2024

Fixes #N/A

Description

The current liveness TTL has a small race condition. It's possible that the first condition check l.clock.Since(registered.LastTransitionTime.Time) < registrationTTL can return a true value where registrationTTL - l.clock.Since(registered.LastTransitionTime.Time) > 0; however, since the clock can advance while we are in this conditional statement, by the time we get to the line return reconcile.Result{RequeueAfter: registrationTTL - l.clock.Since(registered.LastTransitionTime.Time)}, nil, registrationTTL - l.clock.Since(registered.LastTransitionTime.Time) is no longer greater than 0 and is now either equal to 0 or negative.

In either case, controller-runtime does not respect any RequeueAfter value that is equal to or less than 0. Thus, this effectively results in us returning the response reconcile.Result{}, nil. This can leave the NodeClaim in a state where it never gets deleted since we returned an empty result.

How was this change tested?

make presubmit

No tests were added since it's basically impossible to reproduce this race condition in testing code.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Sep 15, 2024
@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Sep 15, 2024
@jonathan-innis jonathan-innis force-pushed the fix-possible-registration-ttl-race branch from 81c29c8 to ff15130 Compare September 15, 2024 05:42
@coveralls
Copy link

coveralls commented Sep 15, 2024

Pull Request Test Coverage Report for Build 10868592923

Details

  • 2 of 2 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.02%) to 80.772%

Totals Coverage Status
Change from base Build 10838752554: 0.02%
Covered Lines: 8393
Relevant Lines: 10391

💛 - Coveralls

@jonathan-innis jonathan-innis force-pushed the fix-possible-registration-ttl-race branch from ff15130 to 83936a4 Compare September 15, 2024 05:55
@jonathan-innis jonathan-innis force-pushed the fix-possible-registration-ttl-race branch from 83936a4 to 2631197 Compare September 15, 2024 05:55
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jonathan-innis, rschalo

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

@engedaam
Copy link
Contributor

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 18, 2024
@k8s-ci-robot k8s-ci-robot merged commit 6396e9c into kubernetes-sigs:main Sep 18, 2024
11 checks passed
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. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants