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

Simplified and corrected logic around context cancelation #87059

Closed

Conversation

MikeSpreitzer
Copy link
Member

What type of PR is this?

Uncomment only one /kind <> line, hit enter to put that in a new line, and remove leading whitespace from that line:

/kind api-change

/kind bug

/kind cleanup
/kind deprecation
/kind design
/kind documentation
/kind failing-test
/kind feature
/kind flake

What this PR does / why we need it:
This PR tightens up the logic around cancelation of the context.Context. Previously a request could get more than one decision (in series), with a decisionCancel overwriting a decisionReject or decisionExecute and causing confusion. Now a request gets exactly one decision, and QueueSet allows context cancelation to only cut short the time spent waiting in the queue. This PR also adds a QueueSet test for context cancelation. This PR also fixes a metrics oversight.

There is no official issue for this PR, but the problem was reported in a conversation that ended at MikeSpreitzer@1c31b2b#r36721437 .

Which issue(s) this PR fixes:

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

NONE

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


@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/L Denotes a PR that changes 100-499 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. area/apiserver 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 Jan 10, 2020
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: MikeSpreitzer
To complete the pull request process, please assign deads2k
You can assign the PR to them by writing /assign @deads2k in a comment when ready.

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

MikeSpreitzer referenced this pull request in MikeSpreitzer/kubernetes Jan 10, 2020
(1) Replaced random-looking assortment of counter increments and
decrements with something hopefully more principalled-looking.  Most
importantly, introduced the MutablePromise abstraction to neatly wrap
up the complicated business of unioning multiple sources of
unblocking.

(2) Improved debug logging.

(3) Somewhat more interesting test cases, and a bug fix wrt round
robin index.
@MikeSpreitzer
Copy link
Member Author

@tedyu
/cc @aaron-prindle


// Readable is a variable that is initially not set and later becomes
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

variable: it is an interface.

Please rephrase

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

IsSet() bool
}

// ReadableLocked is a Readable whose implementation is protected by a lock
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ReadableLocked: wrong type name

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, editing oversight.

}

// ReadableLocked is a Readable whose implementation is protected by a lock
type LockingReadable interface {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the func names below, it seems Locked is better than Locking

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"locked" is a state that a mutex may or may not be in; entered via Mutex::Lock() and exited by Mutex::Unlock(). I am following the convention here that ending a method name in "Locked" signals that the caller must already have locked the mutex. I chose "LockingReadable" rather than "LockedReadable" because the Readable's mutex is not always locked, rather I am trying to signal that locking is part of how the Readable works.

@MikeSpreitzer
Copy link
Member Author

Thanks, @tedyu .

@MikeSpreitzer
Copy link
Member Author

@bjrara

@MikeSpreitzer
Copy link
Member Author

@tedyu , would you like to take another look?

@tedyu
Copy link
Contributor

tedyu commented Jan 13, 2020

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 13, 2020
@MikeSpreitzer
Copy link
Member Author

/assign @deads2k
/unassign @tedyu

@k8s-ci-robot k8s-ci-robot assigned deads2k and unassigned tedyu Jan 13, 2020
break
}
}
return
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

after remove canceled req, totRequestsWaiting also needs to be decremented

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right, thanks.

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

New changes are detected. LGTM label has been removed.

@MikeSpreitzer
Copy link
Member Author

/retest

Previously, a `decisionCancel` could overwrite a `decisionReject` or
`decisionExecute`, causing confusion.  Now a request gets exactly one
decision and there is no confusion.

Also added write-once to the promise package and refactored.
@MikeSpreitzer
Copy link
Member Author

The force-push to db4ba1c is a squash.

@k8s-ci-robot
Copy link
Contributor

@MikeSpreitzer: The following tests failed, say /retest to rerun all failed tests:

Test name Commit Details Rerun command
pull-kubernetes-kubemark-e2e-gce-big db4ba1c link /test pull-kubernetes-kubemark-e2e-gce-big
pull-kubernetes-e2e-gce db4ba1c link /test pull-kubernetes-e2e-gce

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

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. I understand the commands that are listed here.

@MikeSpreitzer
Copy link
Member Author

See #87362 instead of this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/apiserver cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. 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/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants