Production-Grade Container Scheduling and Management
Go to file
Clayton Coleman 133dd61578
wait: Deprecate legacy Poll methods for new context aware methods
The Poll* methods predate context in Go, and the current implementation
will return ErrWaitTimeout even if the context is cancelled, which
prevents callers who are using Poll* from handling that error directly
(for instance, if you want to cancel a function in a controlled fashion
but still report cleanup errors to logs, you want to know the difference
between 'didn't cancel', 'cancelled cleanly', and 'hit an error).

This commit adds two new methods that reflect how modern Go uses
context in polling while preserving all Kubernetes-specific behavior:

	PollUntilContextCancel
	PollUntilContextTimeout

These methods can be used for infinite polling (normal context),
timed polling (deadline context), and cancellable poll (cancel context).
All other Poll/Wait methods are marked as deprecated for removal in
the future. The ErrWaitTimeout error will no longer be returned from the
Poll* methods, but will continue to be returned from ExponentialBackoff*.
Users updating to use these new methods are responsible for converting
their error handling as appropriate. A convenience helper
`Interrupted(err) bool` has been added that should be used instead of
checking `err == ErrWaitTimeout`. In a future release ErrWaitTimeout will
be made private to prevent incorrect use. The helper can be used with all
polling methods since context cancellation and deadline are semantically
equivalent to ErrWaitTimeout. A new `ErrorInterrupted(cause error)` method
should be used instead of returning ErrWaitTimeout in custom code.

The convenience method PollUntilContextTimeout is added because deadline
context creation is verbose and the cancel function must be called to
properly cleanup the context - many of the current poll users would see
code sizes increase. To reduce the overall method surface area, the
distinction between PollImmediate and Poll has been reduced to a single
boolean on PollUntilContextCancel so we do not need multiple helper methods.

The existing methods were not altered because ecosystem callers have been
observed to use ErrWaitTimeout to mean "any error that my condition func
did not return" which prevents cancellation errors from being returned
from the existing methods. Callers must make a deliberate migration.

Callers migrating to `PollWithContextCancel` should:

1. Pass a context with a deadline or timeout if they were previously using
	`Poll*Until*` and check `err` for `context.DeadlineExceeded` instead of
	`ErrWaitTimeout` (more specific) or use `Interrupted(err)` for a generic
	check.
2. Callers that were waiting forever or for context cancellation should
	ensure they are checking `context.Canceled` instead of `ErrWaitTimeout`
	to detect when the poll was stopped early.

Callers of `ExponentialBackoffWithContext` should use `Interrupted(err)`
instead of directly checking `err == ErrWaitTimeout`. No other changes are
needed.

Code that returns `ErrWaitTimeout` should instead define a local cause
and return `wait.ErrorInterrupted(cause)`, which will be recognized by
`wait.Interrupted()`. If nil is passed the previous message will be used
but clients are highly recommended to use typed checks vs message checks.

As a consequence of this change the new methods are more efficient - Poll
uses one less goroutine.
2023-03-14 13:14:11 -06:00
.github
api Merge pull request #115840 from atosatto/remove-taint-manager-cli 2023-03-13 08:13:10 -07:00
build refactor remote test running 2023-03-12 21:26:01 -05:00
CHANGELOG Fix up after rebasing on top of dedup pod resource req calculation PR 2023-03-10 15:21:56 +00:00
cluster Stop clear non-existant retention policy rule 2023-03-13 11:35:10 +01:00
cmd Merge pull request #116301 from andyzhangx/remove-azuredisk-code 2023-03-13 10:38:48 -07:00
docs
hack Revert "Disable unified build and static init optimization for tests" 2023-03-11 14:09:16 -05:00
LICENSES Cleanup vendor/ 2023-03-07 10:27:15 -05:00
logo
pkg Merge pull request #116301 from andyzhangx/remove-azuredisk-code 2023-03-13 10:38:48 -07:00
plugin Merge pull request #115879 from mtardy/scdeny-warning 2023-03-13 07:02:48 -07:00
staging wait: Deprecate legacy Poll methods for new context aware methods 2023-03-14 13:14:11 -06:00
test Merge pull request #115840 from atosatto/remove-taint-manager-cli 2023-03-13 08:13:10 -07:00
third_party
vendor revert azuredisk test removal change 2023-03-11 07:10:05 +00:00
.generated_files
.gitattributes
.gitignore
.go-version [go] Bump images, dependencies and versions to go 1.20.2 2023-03-09 09:57:45 +01:00
CHANGELOG.md
code-of-conduct.md
CONTRIBUTING.md
go.mod Update kube-openapi to 15aac26d736a 2023-03-09 11:29:40 -08:00
go.sum Update kube-openapi to 15aac26d736a 2023-03-09 11:29:40 -08:00
LICENSE
Makefile
OWNERS
OWNERS_ALIASES
README.md
SECURITY_CONTACTS
SUPPORT.md

Kubernetes (K8s)

CII Best Practices


Kubernetes, also known as K8s, is an open source system for managing containerized applications across multiple hosts. It provides basic mechanisms for deployment, maintenance, and scaling of applications.

Kubernetes builds upon a decade and a half of experience at Google running production workloads at scale using a system called Borg, combined with best-of-breed ideas and practices from the community.

Kubernetes is hosted by the Cloud Native Computing Foundation (CNCF). If your company wants to help shape the evolution of technologies that are container-packaged, dynamically scheduled, and microservices-oriented, consider joining the CNCF. For details about who's involved and how Kubernetes plays a role, read the CNCF announcement.


To start using K8s

See our documentation on kubernetes.io.

Try our interactive tutorial.

Take a free course on Scalable Microservices with Kubernetes.

To use Kubernetes code as a library in other applications, see the list of published components. Use of the k8s.io/kubernetes module or k8s.io/kubernetes/... packages as libraries is not supported.

To start developing K8s

The community repository hosts all information about building Kubernetes from source, how to contribute code and documentation, who to contact about what, etc.

If you want to build Kubernetes right away there are two options:

You have a working Go environment.
mkdir -p $GOPATH/src/k8s.io
cd $GOPATH/src/k8s.io
git clone https://github.com/kubernetes/kubernetes
cd kubernetes
make
You have a working Docker environment.
git clone https://github.com/kubernetes/kubernetes
cd kubernetes
make quick-release

For the full story, head over to the developer's documentation.

Support

If you need support, start with the troubleshooting guide, and work your way through the process that we've outlined.

That said, if you have questions, reach out to us one way or another.

Community Meetings

The Calendar has the list of all the meetings in Kubernetes community in a single location.

Adopters

The User Case Studies website has real-world use cases of organizations across industries that are deploying/migrating to Kubernetes.

Governance

Kubernetes project is governed by a framework of principles, values, policies and processes to help our community and constituents towards our shared goals.

The Kubernetes Community is the launching point for learning about how we organize ourselves.

The Kubernetes Steering community repo is used by the Kubernetes Steering Committee, which oversees governance of the Kubernetes project.

Roadmap

The Kubernetes Enhancements repo provides information about Kubernetes releases, as well as feature tracking and backlogs.