kubernetes/pkg/kubelet/kuberuntime
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
..
logs Migrate pkg/kubelet/kuberuntime to structured logging 2021-03-17 01:53:44 +01:00
convert_test.go kubelet - adding pod annotations to various image calls to get runtime-handler info to CRI 2020-04-17 23:57:09 +00:00
convert.go Make toKubeContainerImageSpec deterministic 2020-07-31 14:41:11 -04:00
doc.go
fake_kuberuntime_manager.go Keep pod worker running until pod is truly complete 2021-07-06 15:55:22 -04:00
helpers_linux_test.go update import of generic featuregate code from k8s.io/apiserver/pkg/util/feature -> k8s.io/component-base/featuregate 2019-05-08 10:01:50 -04:00
helpers_linux.go fix #73264 cpuPeriod was not reset, but used as it is if alpha gate is disabled 2019-02-01 16:45:43 +01:00
helpers_test.go Add SeccompDefault feature 2021-06-23 10:22:57 +02:00
helpers_unsupported.go Adding Windows CPU limit tests 2020-02-24 19:46:39 +00:00
helpers.go Add SeccompDefault feature 2021-06-23 10:22:57 +02:00
instrumented_services_test.go test(kuberuntime): deflake TestRecordOperation 2020-09-05 13:36:26 +08:00
instrumented_services.go remove deprecated metrics of kubelet 2020-01-10 16:46:52 +08:00
kuberuntime_container_linux_test.go Add namespace targeting to the kubelet 2020-01-30 15:31:43 +01:00
kuberuntime_container_linux.go Migrate pkg/kubelet/kuberuntime to structured logging 2021-03-17 01:53:44 +01:00
kuberuntime_container_test.go check log directory for restartCount 2021-03-15 15:33:29 -05:00
kuberuntime_container_unsupported.go Add namespace targeting to the kubelet 2020-01-30 15:31:43 +01:00
kuberuntime_container_windows.go Kubelet updates for Windows HostProcess Containers 2021-05-19 16:24:14 -07:00
kuberuntime_container.go Merge pull request #101480 from yuzhiquan/little-nit-for-kubelet 2021-05-24 21:49:05 -07:00
kuberuntime_gc_test.go Keep pod worker running until pod is truly complete 2021-07-06 15:55:22 -04:00
kuberuntime_gc.go Keep pod worker running until pod is truly complete 2021-07-06 15:55:22 -04:00
kuberuntime_image_test.go Merge pull request #90061 from marosset/runtimehandler-image-spec-annotations 2020-05-18 16:29:36 -07:00
kuberuntime_image.go Migrate pkg/kubelet/kuberuntime to structured logging 2021-03-17 01:53:44 +01:00
kuberuntime_logs.go
kuberuntime_manager_test.go Keep pod worker running until pod is truly complete 2021-07-06 15:55:22 -04:00
kuberuntime_manager.go Keep pod worker running until pod is truly complete 2021-07-06 15:55:22 -04:00
kuberuntime_sandbox_test.go Kubelet updates for Windows HostProcess Containers 2021-05-19 16:24:14 -07:00
kuberuntime_sandbox.go Kubelet updates for Windows HostProcess Containers 2021-05-19 16:24:14 -07:00
labels_test.go Remove container type from kubelet runtime labels 2018-12-21 15:47:47 +01:00
labels.go Kubelet updates for Windows HostProcess Containers 2021-05-19 16:24:14 -07:00
legacy_test.go fix golint failures - /pkg/kubelet/images 2018-09-17 10:52:25 +08:00
legacy.go Remove unhealthy symlink only for dead containers 2020-04-21 12:30:51 -07:00
security_context_others_test.go fix windows container root validate 2020-07-24 19:59:58 +08:00
security_context_others.go Enhance the prompt information of verifyRunAsNonRoot, add pod, container information 2020-09-22 08:10:54 +08:00
security_context_windows_test.go fix windows container root validate 2020-07-24 19:59:58 +08:00
security_context_windows.go Migrate pkg/kubelet/kuberuntime to structured logging 2021-03-17 01:53:44 +01:00
security_context.go Add SeccompDefault feature 2021-06-23 10:22:57 +02:00