Commit Graph

29 Commits

Author SHA1 Message Date
Patrick Ohly
961819a4d0 dependencies: update klog v2.90.1
This improves performance of the text formatting and ktesting.

Because ktesting no longer buffers messages by default, one unit
test needs to ask for that explicitly.
2023-03-01 19:03:50 +01:00
Michal Wozniak
c803892bd8 Enable the feature into beta 2022-11-09 09:02:40 +01:00
Michal Wozniak
52cd6755eb Add pod disruption conditions for kubelet initiated failures 2022-11-07 11:23:22 +01:00
Patrick Ohly
7f55a0bae0 kubelet: avoid manipulating global logger during unit test
The code as it stands now works, but it is still complicated and previous
versions had race
conditions (https://github.com/kubernetes/kubernetes/issues/108040). Now the
test works without modifying global state. The individual test cases could run
in parallel, this just isn't done because they complete quickly already (2
seconds).
2022-06-24 11:27:40 +02:00
Patrick Ohly
65385fec20 kubelet: convert node shutdown manager to contextual logging
This will make output checking easier (done in a separate commit). kubelet
itself still uses the global logger.
2022-06-24 11:20:34 +02:00
Kubernetes Prow Robot
d796dd7d0f
Merge pull request #108193 from utkarsh348/myfeature
Fixed race condition in test manager shutdown
2022-03-27 05:55:21 -07:00
Hemant Kumar
13b34d9c77 Use tempdir for shutdown tests 2022-03-24 11:58:49 -04:00
utkarsh348
eaee96efd3 Fixed race condition test manager shutdown 2022-02-18 11:20:02 +05:30
calvin
d9ab5e18d3 fix: data race when hijack klog
Signed-off-by: calvin <wen.chen@daocloud.io>
2022-01-24 15:01:49 +08:00
haoyun
92fa957dd1 feat: use clock instead
Signed-off-by: haoyun <yun.hao@daocloud.io>
2021-12-10 13:59:12 +08:00
Shiming Zhang
545313bdc7 Implement graceful shutdown based on Pod priority 2021-11-17 11:47:12 +08:00
Shiming Zhang
b468c24e85 Refactor to use structure to pass parameters 2021-10-15 11:16:21 +08:00
Ryan Phillips
e2e938066d kubelet: add probe termination to graceful shutdowns 2021-09-22 14:13:25 -05:00
Kubernetes Prow Robot
7c71e06cd1
Merge pull request #104959 from calvin0327/issue-test-dataRace
fix the test issue of node shutdown manager
2021-09-21 11:56:30 -07:00
calvin0327
db82e282fc fix the test issue of data race to node shutdown manager 2021-09-13 18:12:19 +08:00
wojtekt
53ce79a18a Migrate to k8s.io/utils/clock in pkg/kubelet 2021-09-10 12:20:09 +02:00
Stephen Augustus
481cf6fbe7
generated: Run hack/update-gofmt.sh
Signed-off-by: Stephen Augustus <foo@auggie.dev>
2021-08-24 15:47:49 -04:00
Kubernetes Prow Robot
8dbc33d649
Merge pull request #101081 from rphillips/add_graceful_shutdown_event
kubelet: add graceful shutdown events
2021-08-17 22:08:08 -07:00
Kubernetes Prow Robot
a6c2cd7d18
Merge pull request #103291 from wzshiming/fix/nodeshutdown-restart
Fix Data Race in nodeshutdown restart
2021-07-09 08:43:14 -07:00
Clayton Coleman
3eadd1a9ea
Keep pod worker running until pod is truly complete
A number of race conditions exist when pods are terminated early in
their lifecycle because components in the kubelet need to know "no
running containers" or "containers can't be started from now on" but
were relying on outdated state.

Only the pod worker knows whether containers are being started for
a given pod, which is required to know when a pod is "terminated"
(no running containers, none coming). Move that responsibility and
podKiller function into the pod workers, and have everything that
was killing the pod go into the UpdatePod loop. Split syncPod into
three phases - setup, terminate containers, and cleanup pod - and
have transitions between those methods be visible to other
components. After this change, to kill a pod you tell the pod worker
to UpdatePod({UpdateType: SyncPodKill, Pod: pod}).

Several places in the kubelet were incorrect about whether they
were handling terminating (should stop running, might have
containers) or terminated (no running containers) pods. The pod worker
exposes methods that allow other loops to know when to set up or tear
down resources based on the state of the pod - these methods remove
the possibility of race conditions by ensuring a single component is
responsible for knowing each pod's allowed state and other components
simply delegate to checking whether they are in the window by UID.

Removing containers now no longer blocks final pod deletion in the
API server and are handled as background cleanup. Node shutdown
no longer marks pods as failed as they can be restarted in the
next step.

See https://docs.google.com/document/d/1Pic5TPntdJnYfIpBeZndDelM-AbS4FN9H2GTLFhoJ04/edit# for details
2021-07-06 15:55:22 -04:00
Shiming Zhang
212ce7c287 Shorten test time 2021-06-30 09:48:26 +08:00
Shiming Zhang
a42c066af7 Fix Data Race in nodeshutdown restart 2021-06-29 16:23:45 +08:00
Ryan Phillips
d9be5abc37 kubelet: add shutdown events 2021-06-23 16:44:19 -05:00
Kubernetes Prow Robot
62fdaabe82
Merge pull request #102635 from charlesxsh/fix-linux-test
fix a potential deadlock in graceful node shutdown unit tests
2021-06-21 16:27:45 -07:00
Shihao Xia
a2a4b50bc1 fixed deadlock 2021-06-03 18:03:17 -04:00
Shiming Zhang
202a012093 Add restart unit test 2021-05-23 00:47:36 +08:00
David Porter
893f5fd4f0 Promote kubelet graceful node shutdown to beta
- Change the feature gate from alpha to beta and enable it by default

- Update a few of the unit tests due to feature gate being enabled by
  default

- Small refactor in `nodeshutdown_manager` which adds `featureEnabled`
  function (which checks that feature gate and that
  `kubeletConfig.ShutdownGracePeriod > 0`).

- Use `featureEnabled()` to exit early from shutdown manager in the case
  that the feature is disabled

- Update kubelet config defaulting to be explicit that
  `ShutdownGracePeriod` and `ShutdownGracePeriodCriticalPods` default to
  zero and update the godoc comments.

- Update defaults and add featureGate tag in api config godoc.

With this feature now in beta and the feature gate enabled by default,
to enable graceful shutdown all that will be required is to configure
`ShutdownGracePeriod` and `ShutdownGracePeriodCriticalPods` in the
kubelet config. If not configured, they will be defaulted to zero, and
graceful shutdown will effectively be disabled.
2021-03-05 15:21:37 -08:00
wzshiming
d9df265af0 Sync node status during kubelet node shutdown 2021-01-21 11:01:13 +08:00
David Porter
16f71c6d47 Implement shutdown manager in kubelet
Implements KEP 2000, Graceful Node Shutdown:
https://github.com/kubernetes/enhancements/tree/master/keps/sig-node/2000-graceful-node-shutdown

* Add new FeatureGate `GracefulNodeShutdown` to control
enabling/disabling the feature
* Add two new KubeletConfiguration options
  * `ShutdownGracePeriod` and `ShutdownGracePeriodCriticalPods`
* Add new package, `nodeshutdown` that implements the Node shutdown
manager
  * The node shutdown manager uses the systemd inhibit package, to
  create an system inhibitor, monitor for node shutdown events, and
  gracefully terminate pods upon a node shutdown.
2020-11-12 21:47:55 +00:00