Commit Graph

460 Commits

Author SHA1 Message Date
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
Kubernetes Prow Robot
13cafd5cb0
Merge pull request #101480 from yuzhiquan/little-nit-for-kubelet
Fix some nit for kubelet
2021-05-24 21:49:05 -07:00
marosset
fd94032b21 Kubelet updates for Windows HostProcess Containers 2021-05-19 16:24:14 -07:00
yuzhiquan
bebca30309 comment should have function name as prefix 2021-04-28 15:26:46 +08:00
JunYang
01a4e4face Structured Logging migration: modify volume and container part logs of kubelet.
Signed-off-by: JunYang <yang.jun22@zte.com.cn>
2021-03-17 08:59:03 +08:00
Kubernetes Prow Robot
a4025a8462
Merge pull request #98986 from gjkim42/fix-runtime-assert
kubelet: Make the test fail if (*FakeRuntime).Assert fails
2021-03-04 18:34:33 -08:00
Benjamin Elder
56e092e382 hack/update-bazel.sh 2021-02-28 15:17:29 -08:00
Geonju Kim
fc4a29da2c kubelet: Make the test fail if (*FakeRuntime).Assert fails 2021-02-26 06:31:54 +09:00
Sergey Kanzhelev
4c9e96c238 Revert "Merge pull request #92817 from kmala/kubelet"
This reverts commit 88512be213, reversing
changes made to c3b888f647.
2021-01-12 22:27:22 +00:00
Sergey Kanzhelev
6c2556c5c4 The function shouldRecordEvent will panic when the value of input object is nil 2020-10-16 21:13:49 +00:00
Kubernetes Prow Robot
e6444e01ba
Merge pull request #94494 from SergeyKanzhelev/hostportConflicts
Allow to map the same container port to different host ports
2020-09-22 12:23:40 -07:00
Kubernetes Prow Robot
6ac2930ef0
Merge pull request #94574 from auxten/pkg-kubelet-staticchecks
Fix pkg/kubelet static checks
2020-09-21 21:22:47 -07:00
Kubernetes Prow Robot
88512be213
Merge pull request #92817 from kmala/kubelet
Check for sandboxes before deleting the pod from apiserver
2020-09-10 07:27:45 -07:00
auxten
a9c1acc044 Fix staticchecks ST1005,S1002,S1008,S1039 in pkg/kubelet 2020-09-07 10:53:43 +08:00
Sergey Kanzhelev
1c379b1281 allow to map the same container port to different host ports 2020-09-03 22:21:18 +00:00
Kubernetes Prow Robot
274e33b691
Merge pull request #93581 from SergeyKanzhelev/nameOfPortMappingIsNotNeeded
Clean up in port mapping functionality
2020-08-27 16:06:11 -07:00
Kubernetes Prow Robot
6da73aa572
Merge pull request #93333 from loburm/fix-logrotate
Fix an issue when rotated logs of dead containers are not removed.
2020-08-20 03:27:23 -07:00
Sergey Kanzhelev
d20fd40884 remove legacy leftovers of portmapping functionality that was moved to CNI 2020-07-30 23:12:16 +00:00
Jordan Liggitt
124a5ddf72 Fix int->string casts 2020-07-24 16:23:12 -04:00
Marian Lobur
5d1b3e26af Fix an issue when rotated logs of dead containers are not removed. 2020-07-24 10:06:24 +02:00
Keerthan Reddy,Mala
851d778531 address review comments 2020-07-22 11:54:58 -07:00
Keerthan Reddy,Mala
90cc954eed add sandbox deletor to delete sandboxes on pod delete event 2020-07-22 11:54:58 -07:00
Keerthan Reddy,Mala
d4325f42fb Check for sandboxes before deleting the pod from apiserver 2020-07-22 11:54:56 -07:00
Sergey Kanzhelev
ee53488f19 fix golint issues in pkg/kubelet/container 2020-06-19 15:48:08 +00:00
Kubernetes Prow Robot
e50a46459b
Merge pull request #91303 from SergeyKanzhelev/fixLinterInKebeletContainer
Fix golint failures for kubelet/container
2020-06-09 14:48:18 -07:00
Kubernetes Prow Robot
99c50dfd3c
Merge pull request #85225 from DataDog/eric.mountain/cleanup_refmanager_master
Removes container RefManager
2020-05-28 16:37:15 -07:00
Jordan Liggitt
591e0043c8 Revert "Merge pull request 89667 from kmala/kubelet"
This reverts commit fa785a5706, reversing
changes made to cf13f8d994.
2020-05-21 13:30:14 -04:00
Sergey Kanzhelev
a4bfc732f7 minor correction in comments 2020-05-21 04:15:44 +00:00
Sergey Kanzhelev
4e94144d1e Fix golint failures for kubelet/container 2020-05-20 19:01:23 +00:00
Kubernetes Prow Robot
fa785a5706
Merge pull request #89667 from kmala/kubelet
Check for sandboxes before deleting the pod from apiserver
2020-05-19 23:40:18 -07:00
Kubernetes Prow Robot
f4112710f5
Merge pull request #90061 from marosset/runtimehandler-image-spec-annotations
Add annotations to CRI ImageSpec objects
2020-05-18 16:29:36 -07:00
Davanum Srinivas
07d88617e5
Run hack/update-vendor.sh
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2020-05-16 07:54:33 -04:00
Davanum Srinivas
442a69c3bd
switch over k/k to use klog v2
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2020-05-16 07:54:27 -04:00
marosset
90367729a3 Adding/updating kubelet/kuberuntime tests 2020-04-20 22:25:05 +00:00
marosset
03479e4d12 kubelet - adding pod annotations to various image calls to get runtime-handler info to CRI 2020-04-17 23:57:09 +00:00
Keerthan Reddy,Mala
70e2559aca use runtime sandbox status instead of calling cri 2020-04-13 14:36:34 -07:00
Shihang Zhang
b56da85a77 sync api/v1/pod/util with api/pod/util and remove DefaultContainers 2020-03-24 16:42:32 -07:00
Eric Mountain
22e0ee768b Removes container RefManager 2020-03-16 14:30:57 +01:00
Clayton Coleman
8722c834e5
kubelet: Never restart containers in deleting pods
When constructing the API status of a pod, if the pod is marked for
deletion no containers should be started. Previously, if a container
inside of a terminating pod failed to start due to a container
runtime error (that populates reasonCache) the reasonCache would
remain populated (it is only updated by syncPod for non-terminating
pods) and the delete action on the pod would be delayed until the
reasonCache entry expired due to other pods.

This dramatically reduces the amount of time the Kubelet waits to
delete pods that are terminating and encountered a container runtime
error.
2020-03-04 13:34:25 -05:00
mattjmcnaughton
92940fa80d
Remove recorder.PastEventf method
The `recorder.PastEventf` method wasn't actually working as advertised.
It was supposed to accept a timestamp, which would be used when
generating the event. However, as the
[source code](https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/client-go/tools/record/event.go#L316)
shows, this `timestamp` was never actually used.

In other words, `PastEventf` is identical to `Eventf`.

We have two options: one would be to fix `PastEventf` so that it works
as advertised. The other would be to delete `PastEventf` and only
support `Eventf`.

Ultimately, I could only find one use of `PastEventf` in the code base,
so I propose we just delete `PastEventf` and convert all uses to
`Eventf`.
2019-12-30 12:00:23 -05:00
Kubernetes Prow Robot
4e45328e65
Merge pull request #83123 from aramase/dualstack-downward-api
Dualstack downward api
2019-11-14 22:13:42 -08:00
Kubernetes Prow Robot
d3593c07de
Merge pull request #83057 from bclau/windows/containerd
Windows: Fixes termination-file mounting support for containerd
2019-11-13 17:27:36 -08:00
Claudiu Belu
d4d7f58362 Windows: Fixes termination-file mounting for containerd
If Containerd is used on Windows, then we can also mount individual
files into containers (e.g.: termination-log files), which was not
possible with Docker.

Checks if the container runtime is containerd, and if it is, then also
mount the termination-log file.
2019-11-12 23:33:55 -08:00
Anish Ramasekar
af4d18ccf9
add status.podIPs in downward api
add host file write for podIPs

update tests

remove import alias

update type check

update type check

remove import alias

update open api spec

add tests

update test

add tests

address review comments

update imports

remove todo and import alias
2019-10-25 09:18:49 -07:00
Niels van Oosterom
ef39312fa5 Fixed an issue where duplicate containerPorts where not allowed across different address families 2019-09-13 14:44:53 +02:00
Kubernetes Prow Robot
a3488b4cee
Merge pull request #81206 from tallclair/staticcheck-kubelet-push
Cleanup Kubelet static analysis issues
2019-08-22 15:09:43 -07:00
Di Xu
739cdc8a8c Omit nil or empty field when calculating hash value 2019-08-22 13:46:52 +08:00
Tim Allclair
a2c51674cf Cleanup more static check issues (S1*,ST*) 2019-08-21 10:40:21 -07:00
Tim Allclair
8a495cb5e4 Clean up error messages (ST1005) 2019-08-21 10:40:21 -07:00
Tim Allclair
6510d26b6a Fix misc static check issues 2019-08-21 10:40:21 -07:00