Commit Graph

114705 Commits

Author SHA1 Message Date
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
Clayton Coleman
8d4004bbc7
wait: Update tests to reference the constant error
The structure of the error is changing, and we don't guarantee
reflect.DeepEqual(...) will remain true for ErrWaitTimeout currently.
2023-03-13 12:06:06 -06:00
Kubernetes Prow Robot
087868a436
Merge pull request #116476 from smarterclayton/context_wait_2
wait: Split the wait package up into individual files to make refactors easier
2023-03-13 10:39:00 -07:00
Kubernetes Prow Robot
3106a5c553
Merge pull request #116301 from andyzhangx/remove-azuredisk-code
Remove Azure disk in-tree storage plugin
2023-03-13 10:38:48 -07:00
Kubernetes Prow Robot
3b1fc60d80
Merge pull request #116523 from pacoxu/CSIStorageCapacity-v1beta1-remove
Remove storage.k8s.io/v1beta1 API version of CSIStorageCapacity
2023-03-13 09:28:50 -07:00
Kubernetes Prow Robot
a0b1bee7c5
Merge pull request #115840 from atosatto/remove-taint-manager-cli
Remove enable-taint-manager and pod-eviction-timeout CLI flags
2023-03-13 08:13:10 -07:00
Kubernetes Prow Robot
492a08c916
Merge pull request #113525 from 249043822/br-context-logging-deployment
deployment controller: use contextual logging
2023-03-13 08:13:02 -07:00
Kubernetes Prow Robot
34537c1a1d
Merge pull request #110864 from claudiubelu/adds-unittests
unittests: Adds winstats unittests
2023-03-13 08:12:50 -07:00
Kubernetes Prow Robot
ab5100893a
Merge pull request #116533 from ameukam/remove-gcs-retention-action
Stop clear non-existant retention policy rule
2023-03-13 07:02:56 -07:00
Kubernetes Prow Robot
9c5eebaf3f
Merge pull request #115879 from mtardy/scdeny-warning
`SecurityContextDeny` admission plugin: add warning on creation
2023-03-13 07:02:48 -07:00
Kubernetes Prow Robot
85524e7da6
Merge pull request #116518 from tzneal/refactor-remote-runner
test: refactor remote test running
2023-03-13 05:56:59 -07:00
Kubernetes Prow Robot
4a7ba05691
Merge pull request #116510 from flant/whoami-beta
Promote whoami kubectl command
2023-03-13 05:56:47 -07:00
Claudiu Belu
e3edf13486 unittests: Adds winstats unittests
The module pkg/kubelet/winstats has almost no coverage for Windows. This
commit adds unit tests to cover the mentioned module.
2023-03-13 12:08:15 +00:00
Saza
d34b0275a3
dynamic resource allocation: add timeouts for communiction with plugin (#114844)
* add timeouts for communication with dra plugin

* move timeout constant to k8s.io/kubernetes/pkg/kubelet/cm/util

* move settings of timeout to pkg/kubelet/plugin/dra/plugin/client.go

* remove timeout constant
2023-03-13 04:34:56 -07:00
Kubernetes Prow Robot
185cd95b9c
Merge pull request #113443 from yangjunmyfm192085/namespace-contextual-logging
namespace controller: use contextual logging
2023-03-13 04:34:44 -07:00
ZhangKe10140699
66bda6c092 deployment controller: use contextual logging 2023-03-13 19:00:44 +08:00
Arnaud Meukam
033f4b1772
Stop clear non-existant retention policy rule
This command is now not necessary and create some noise on the trail
logs.
See: https://github.com/kubernetes/k8s.io/pull/4902

Signed-off-by: Arnaud Meukam <ameukam@gmail.com>
2023-03-13 11:35:10 +01:00
mtardy
36a2156033 Add a SecurityContextDeny feature gate disabled by default
Put plugin registration behind the feature gate.
2023-03-13 10:18:08 +01:00
John Kwiatkoski
69465d2949
Adding test coverage for NewPodContainerManager() (#110220) 2023-03-13 02:08:44 -07:00
Paco Xu
49032c394c The storage.k8s.io/v1beta1 API version of CSIStorageCapacity will no longer be served in v1.27. 2023-03-13 15:06:04 +08:00
JunYang
f5bd8c86d4 namespace controller: use contextual logging 2023-03-13 14:59:17 +08:00
Kubernetes Prow Robot
ca7804fe13
Merge pull request #115909 from sding3/integration-test-for-debug-profiles-general-baseline
add integration tests for debug profiles general & baseline
2023-03-12 22:32:41 -07:00
Kubernetes Prow Robot
16bc942a6b
Merge pull request #113464 from mengjiao-liu/contextual-logging-controller-bootstrap
Migrate `pkg/controller/bootstrap` to contextual logging
2023-03-12 20:12:42 -07:00
Todd Neal
23f71f0eba refactor remote test running 2023-03-12 21:26:01 -05:00
Mengjiao Liu
e56f3e0781 Migrate pkg/controller/bootstrap to contextual logging 2023-03-13 10:18:40 +08:00
Kubernetes Prow Robot
3c6e419cc3
Merge pull request #116450 from vinaykul/restart-free-pod-vertical-scaling-api
Rename ContainerStatus.ResourcesAllocated to ContainerStatus.AllocatedResources
2023-03-12 16:06:40 -07:00
Kubernetes Prow Robot
a32050e6cb
Merge pull request #116201 from sanposhiho/metric-scheduling-gate
add(scheduler): implement "plugin_execution_duration_seconds" metric in PreEnqueue
2023-03-12 13:52:40 -07:00
Kubernetes Prow Robot
3710d93d14
Merge pull request #115976 from ii/pending_eligible_endpoints
Create pending_eligible_endpoints.yaml and move endpoints from ineligible_endpoints.yaml
2023-03-12 12:20:51 -07:00
Kubernetes Prow Robot
a4a0fd44d8
Merge pull request #115912 from moshe010/dra-checkpoint
kubelet DRA: Add checkpointing mechanism in the DRA Manager
2023-03-12 12:20:40 -07:00
Kubernetes Prow Robot
e413e6a59c
Merge pull request #116312 from sanposhiho/move-label
cleanup(scheduler): move metric labels to metrics package
2023-03-12 10:48:40 -07:00
Kubernetes Prow Robot
f944743953
Merge pull request #116509 from cpanato/distroless-ip
Update distroless-iptables and setcap images
2023-03-12 08:44:39 -07:00
cpanato
609ae51395
Updated setcap to use released image registry.k8s.io/build-image/setcap:bullseye-v1.4.2
Signed-off-by: cpanato <ctadeu@gmail.com>
2023-03-12 15:26:56 +01:00
cpanato
7b0b87e057
Updated distroless iptables to use released image registry.k8s.io/build-image/distroless-iptables:v0.2.2
Signed-off-by: cpanato <ctadeu@gmail.com>
2023-03-12 15:26:15 +01:00
m.nabokikh
c2cadd2b60 Promote whoami kubectl command
Signed-off-by: m.nabokikh <maksim.nabokikh@flant.com>
2023-03-12 15:24:31 +01:00
Moshe Levi
2c79af0d63 kubelet dra: add unit tests for checkpoint
Signed-off-by: Moshe Levi <moshele@nvidia.com>
2023-03-12 09:13:19 +02:00
Kensei Nakada
639007b28e cleanup(scheduler): move metric labels to metrics package 2023-03-12 05:10:29 +00:00
Kensei Nakada
6697467062 add(scheduler): implement "plugin_execution_duration_seconds" metric in PreEnqueue 2023-03-12 04:45:52 +00:00
Kubernetes Prow Robot
ead7d66ee1
Merge pull request #116500 from dims/revert-linx-arm-workaround
Revert "Disable unified build and static init optimization for tests"
2023-03-11 13:04:40 -08:00
Kubernetes Prow Robot
cc3855e0cf
Merge pull request #116170 from aojea/watch_instead_poll_system_namespaces
Watch instead poll system namespaces
2023-03-11 11:24:39 -08:00
Davanum Srinivas
320cb6d9ef
Revert "Disable unified build and static init optimization for tests"
This reverts commit e20d77bb79.

Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2023-03-11 14:09:16 -05:00
Kubernetes Prow Robot
bb6c6fad2c
Merge pull request #115742 from dims/drop-32-bit-platforms
Drop 32 bit linux/arm platform
2023-03-11 06:12:40 -08:00
andyzhangx
c2b2a7622f revert azuredisk test removal change
revert

revert vendor changes

revert

revert

fix
2023-03-11 07:10:05 +00:00
Kubernetes Prow Robot
c6f3007071
Merge pull request #115967 from harche/evented_pleg_metrics
Graduate Evented PLEG to Beta
2023-03-10 17:34:40 -08:00
Kubernetes Prow Robot
0804a86ce6
Merge pull request #116286 from thockin/logging_int_cmp
bash: compare numbers numerically, not lexically
2023-03-10 16:30:39 -08:00
Kubernetes Prow Robot
71b596e0d6
Merge pull request #116426 from SergeyKanzhelev/twoMoreLifecycleChecks
Three more lifecycle checks to demonstrate various validation techniques for containers lifecycle checks
2023-03-10 15:22:51 -08:00
Kubernetes Prow Robot
5452109c9d
Merge pull request #114227 from saschagrunert/kube-aggregator-static
Link `kube-aggregator` binary statically
2023-03-10 15:22:39 -08:00
Kubernetes Prow Robot
36b29b38bb
Merge pull request #116436 from wojtek-t/fix_watch_cache_2
Fix incorrect watch events when watch is initialized simultanously with reinitializing watchcache
2023-03-10 12:41:19 -08:00
Kubernetes Prow Robot
1f2d49972c
Merge pull request #116424 from jsafrane/add-selinux-metric-test
Add e2e tests for SELinux metrics
2023-03-10 12:41:06 -08:00
Kubernetes Prow Robot
0010333bdd
Merge pull request #116161 from danielvegamyhre/mutable-scheduling-directives
Mutable pod scheduling directives
2023-03-10 12:40:58 -08:00
Kubernetes Prow Robot
94e30facdb
Merge pull request #114497 from dgrisonnet/pod-logs-metrics
Remove redundant subsystem in kube-apiserver pod logs metrics name
2023-03-10 12:40:41 -08:00