kubernetes/test/e2e_node
Clayton Coleman 6b9a381185
kubelet: Force deleted pods can fail to move out of terminating
If a CRI error occurs during the terminating phase after a pod is
force deleted (API or static) then the housekeeping loop will not
deliver updates to the pod worker which prevents the pod's state
machine from progressing. The pod will remain in the terminating
phase but no further attempts to terminate or cleanup will occur
until the kubelet is restarted.

The pod worker now maintains a store of the pods state that it is
attempting to reconcile and uses that to resync unknown pods when
SyncKnownPods() is invoked, so that failures in sync methods for
unknown pods no longer hang forever.

The pod worker's store tracks desired updates and the last update
applied on podSyncStatuses. Each goroutine now synchronizes to
acquire the next work item, context, and whether the pod can start.
This synchronization moves the pending update to the stored last
update, which will ensure third parties accessing pod worker state
don't see updates before the pod worker begins synchronizing them.

As a consequence, the update channel becomes a simple notifier
(struct{}) so that SyncKnownPods can coordinate with the pod worker
to create a synthetic pending update for unknown pods (i.e. no one
besides the pod worker has data about those pods). Otherwise the
pending update info would be hidden inside the channel.

In order to properly track pending updates, we have to be very
careful not to mix RunningPods (which are calculated from the
container runtime and are missing all spec info) and config-
sourced pods. Update the pod worker to avoid using ToAPIPod()
and instead require the pod worker to directly use
update.Options.Pod or update.Options.RunningPod for the
correct methods. Add a new SyncTerminatingRuntimePod to prevent
accidental invocations of runtime only pod data.

Finally, fix SyncKnownPods to replay the last valid update for
undesired pods which drives the pod state machine towards
termination, and alter HandlePodCleanups to:

- terminate runtime pods that aren't known to the pod worker
- launch admitted pods that aren't known to the pod worker

Any started pods receive a replay until they reach the finished
state, and then are removed from the pod worker. When a desired
pod is detected as not being in the worker, the usual cause is
that the pod was deleted and recreated with the same UID (almost
always a static pod since API UID reuse is statistically
unlikely). This simplifies the previous restartable pod support.
We are careful to filter for active pods (those not already
terminal or those which have been previously rejected by
admission). We also force a refresh of the runtime cache to
ensure we don't see an older version of the state.

Future changes will allow other components that need to view the
pod worker's actual state (not the desired state the podManager
represents) to retrieve that info from the pod worker.

Several bugs in pod lifecycle have been undetectable at runtime
because the kubelet does not clearly describe the number of pods
in use. To better report, add the following metrics:

  kubelet_desired_pods: Pods the pod manager sees
  kubelet_active_pods: "Admitted" pods that gate new pods
  kubelet_mirror_pods: Mirror pods the kubelet is tracking
  kubelet_working_pods: Breakdown of pods from the last sync in
    each phase, orphaned state, and static or not
  kubelet_restarted_pods_total: A counter for pods that saw a
    CREATE before the previous pod with the same UID was finished
  kubelet_orphaned_runtime_pods_total: A counter for pods detected
    at runtime that were not known to the kubelet. Will be
    populated at Kubelet startup and should never be incremented
    after.

Add a metric check to our e2e tests that verifies the values are
captured correctly during a serial test, and then verify them in
detail in unit tests.

Adds 23 series to the kubelet /metrics endpoint.
2023-03-08 22:03:51 -06:00
..
builder update ginkgo from v1 to v2 and gomega to 1.19.0 2022-07-08 10:44:46 +08:00
conformance stop using deprecated klog flags 2022-09-04 21:02:43 +02:00
environment Merge pull request #109753 from matthyx/109577 2022-05-13 07:33:49 -07:00
gcp e2e: accept context from Ginkgo 2022-12-10 19:50:18 +01:00
jenkins Remove generated file rules in make 2022-10-04 08:50:30 -07:00
kubeletconfig io/ioutil has already been deprecated in golang 1.16, so replace all ioutil with io and os 2022-02-03 05:32:12 +08:00
perf/workloads e2e: use error wrapping with %w 2023-02-06 15:39:13 +01:00
perftype hack/update-bazel.sh 2021-02-28 15:17:29 -08:00
plugins/gcp-credential-provider Update test to validate against v1 kubelet APIs 2022-10-03 17:57:25 +00:00
remote test: Add node e2e test to verify static pod termination 2023-03-03 10:00:48 -06:00
runner test: Add some default flags ginkgo flags for node e2e 2023-02-28 00:24:40 -08:00
services e2e: use error wrapping with %w 2023-02-06 15:39:13 +01:00
system hack/update-bazel.sh 2021-02-28 15:17:29 -08:00
testing-manifests e2e: node: remove kubevirt device plugin 2023-02-22 14:04:22 +01:00
apparmor_test.go e2e: use error wrapping with %w 2023-02-06 15:39:13 +01:00
benchmark_util.go e2e: adapt to moved code 2022-10-06 08:19:47 +02:00
checkpoint_container.go Extend checkpoint e2e test to check for results 2023-01-23 18:07:35 +00:00
container_log_rotation_test.go e2e: use Ginkgo context 2022-12-16 20:14:04 +01:00
container_manager_test.go e2e: use error wrapping with %w 2023-02-06 15:39:13 +01:00
cpu_manager_metrics_test.go node: e2e: cpumgr: Rename: s/getCPUManagerMetrics/getKubeletMetrics 2023-01-19 14:18:05 +00:00
cpu_manager_test.go cpuset: Delete 'builder' methods 2023-01-06 23:32:51 +00:00
critical_pod_test.go e2e: use Ginkgo context 2022-12-16 20:14:04 +01:00
density_test.go e2e: use Ginkgo context 2022-12-16 20:14:04 +01:00
device_manager_test.go e2e: use Ginkgo context 2022-12-16 20:14:04 +01:00
device_plugin_test.go e2e: node: unify sample device plugin utilities 2023-02-22 14:04:55 +01:00
doc.go fix golint issues in test/e2e_node 2019-11-26 16:26:55 +08:00
e2e_node_suite_test.go e2e: use error wrapping with %w 2023-02-06 15:39:13 +01:00
eviction_test.go test: fix ginkgolinter issues 2023-02-22 19:36:05 +01:00
framework.go update ginkgo from v1 to v2 and gomega to 1.19.0 2022-07-08 10:44:46 +08:00
garbage_collector_test.go e2e: use Ginkgo context 2022-12-16 20:14:04 +01:00
gubernator.sh
hugepages_test.go e2e: use Ginkgo context 2022-12-16 20:14:04 +01:00
image_credential_provider.go e2e: use Ginkgo context 2022-12-16 20:14:04 +01:00
image_id_test.go e2e: use Ginkgo context 2022-12-16 20:14:04 +01:00
image_list.go e2e: node: unify sample device plugin utilities 2023-02-22 14:04:55 +01:00
lock_contention_linux_test.go e2e: use Ginkgo context 2022-12-16 20:14:04 +01:00
log_path_test.go e2e: use Ginkgo context 2022-12-16 20:14:04 +01:00
memory_manager_test.go e2e: use error wrapping with %w 2023-02-06 15:39:13 +01:00
mirror_pod_grace_period_test.go kubelet: Force deleted pods can fail to move out of terminating 2023-03-08 22:03:51 -06:00
mirror_pod_test.go kubelet: Force deleted pods can fail to move out of terminating 2023-03-08 22:03:51 -06:00
node_container_manager_test.go e2e: use Ginkgo context 2022-12-16 20:14:04 +01:00
node_perf_test.go e2e: use Ginkgo context 2022-12-16 20:14:04 +01:00
node_problem_detector_linux.go e2e: replace WaitForPodToDisappear with WaitForPodNotFoundInNamespace 2023-02-06 15:39:12 +01:00
node_shutdown_linux_test.go e2e: use Ginkgo context 2022-12-16 20:14:04 +01:00
numa_alignment.go cpuset: Make 'ToSlice*' methods look like 'set' methods 2023-01-06 23:32:51 +00:00
oomkiller_test.go Fix the flaky OOMKiller test by sleep at start 2023-02-27 08:15:46 +01:00
os_label_rename_test.go Remove cgo dependency 2023-02-13 11:16:39 -05:00
OWNERS Remove ehashman from sig-node roles 2022-11-01 12:16:43 -07:00
pids_test.go e2e: use Ginkgo context 2022-12-16 20:14:04 +01:00
pod_conditions_test.go e2e: use Ginkgo context 2022-12-16 20:14:04 +01:00
pod_hostnamefqdn_test.go e2e: use Ginkgo context 2022-12-16 20:14:04 +01:00
podresources_test.go e2e: node: podresources: fix restart wait 2023-02-22 14:04:55 +01:00
pods_container_manager_test.go e2e: use Ginkgo context 2022-12-16 20:14:04 +01:00
quota_lsci_test.go e2e: use Ginkgo context 2022-12-16 20:14:04 +01:00
README.md Removed broken link to Analytics 2020-08-13 16:03:37 -04:00
resource_collector.go test: Add e2e to verify static pod termination 2023-03-03 10:00:48 -06:00
resource_metrics_test.go e2e: use Ginkgo context 2022-12-16 20:14:04 +01:00
resource_usage_test.go e2e: use Ginkgo context 2022-12-16 20:14:04 +01:00
restart_test.go e2e: use Ginkgo context 2022-12-16 20:14:04 +01:00
runtime_conformance_test.go e2e: use error wrapping with %w 2023-02-06 15:39:13 +01:00
runtimeclass_test.go e2e node: Update runtime class handler skip logic 2023-01-24 14:43:24 -08:00
seccompdefault_test.go e2e: use Ginkgo context 2022-12-16 20:14:04 +01:00
security_context_test.go e2e: use Ginkgo context 2022-12-16 20:14:04 +01:00
summary_test.go e2e: use Ginkgo context 2022-12-16 20:14:04 +01:00
system_node_critical_test.go e2e: use Ginkgo context 2022-12-16 20:14:04 +01:00
topology_manager_metrics_test.go node: topology-mgr: e2e: changes to validate admission latency metrics 2023-02-15 13:59:56 +00:00
topology_manager_test.go test: Move waitForAllContainerRemoval() into node e2e util 2023-02-03 23:04:35 -08:00
unknown_pods_test.go test: Add e2e node test to check for unknown pods 2023-02-03 23:04:45 -08:00
util_sampledevice.go node: device-mgr: sample device plugin: manifest to avoid registration 2023-03-01 10:01:34 +00:00
util_sriov_linux.go e2e: TM: add option to fail instead of skip 2021-09-13 13:23:36 +02:00
util_sriov_unsupported.go e2e: TM: add option to fail instead of skip 2021-09-13 13:23:36 +02:00
util_sriov.go e2e: TM: add option to fail instead of skip 2021-09-13 13:23:36 +02:00
util_xfs_linux.go generated: Run hack/update-gofmt.sh 2021-08-24 15:47:49 -04:00
util_xfs_unsupported.go generated: Run hack/update-gofmt.sh 2021-08-24 15:47:49 -04:00
util.go test: Add e2e to verify static pod termination 2023-03-03 10:00:48 -06:00
utils_linux.go generated: Run hack/update-gofmt.sh 2021-08-24 15:47:49 -04:00
utils_unsupported.go generated: Run hack/update-gofmt.sh 2021-08-24 15:47:49 -04:00
volume_manager_test.go e2e: use Ginkgo context 2022-12-16 20:14:04 +01:00