k3s/test/e2e_node
Kubernetes Submit Queue a3f40dd8df
Merge pull request #60856 from jiayingz/race-fix
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

Fixes the races around devicemanager Allocate() and endpoint deletion.

There is a race in predicateAdmitHandler Admit() that getNodeAnyWayFunc()
could get Node with non-zero deviceplugin resource allocatable for a
non-existing endpoint. That race can happen when a device plugin fails,
but is more likely when kubelet restarts as with the current registration
model, there is a time gap between kubelet restart and device plugin
re-registration. During this time window, even though devicemanager could
have removed the resource initially during GetCapacity() call, Kubelet
may overwrite the device plugin resource capacity/allocatable with the
old value when node update from the API server comes in later. This
could cause a pod to be started without proper device runtime config set.

To solve this problem, introduce endpointStopGracePeriod. When a device
plugin fails, don't immediately remove the endpoint but set stopTime in
its endpoint. During kubelet restart, create endpoints with stopTime set
for any checkpointed registered resource. The endpoint is considered to be
in stopGracePeriod if its stoptime is set. This allows us to track what
resources should be handled by devicemanager during the time gap.
When an endpoint's stopGracePeriod expires, we remove the endpoint and
its resource. This allows the resource to be exported through other channels
(e.g., by directly updating node status through API server) if there is such
use case. Currently endpointStopGracePeriod is set as 5 minutes.

Given that an endpoint is no longer immediately removed upon disconnection,
mark all its devices unhealthy so that we can signal the resource allocatable
change to the scheduler to avoid scheduling more pods to the node.
When a device plugin endpoint is in stopGracePeriod, pods requesting the
corresponding resource will fail admission handler.

Tested:
Ran GPUDevicePlugin e2e_node test 100 times and all passed now.



**What this PR does / why we need it**:

**Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*:
Fixes https://github.com/kubernetes/kubernetes/issues/60176

**Special notes for your reviewer**:

**Release note**:

```release-note
Fixes the races around devicemanager Allocate() and endpoint deletion.
```
2018-03-12 02:50:13 -07:00
..
builder use node-e2e framework for testing cadvisor 2018-01-31 10:14:54 -08:00
conformance remove gcloud docker -- since it's deprecated 2018-02-28 00:24:27 -08:00
environment Autogenerated: hack/update-bazel.sh 2018-02-16 13:43:01 -08:00
jenkins fix all the typos across the project 2018-02-11 11:04:14 +08:00
perftype update BUILD files 2017-10-15 18:18:13 -07:00
remote expunge the word 'manifest' from Kubelet's config API 2018-02-23 11:44:06 -08:00
runner Autogenerated: hack/update-bazel.sh 2018-02-16 13:43:01 -08:00
services Merge pull request #60509 from verb/pid-e2e 2018-03-05 14:20:14 -08:00
system Autogenerated: hack/update-bazel.sh 2018-02-16 13:43:01 -08:00
BUILD Merge pull request #60509 from verb/pid-e2e 2018-03-05 14:20:14 -08:00
OWNERS Add balajismaniam, ConnorDoyle node-e2e approvers 2017-11-22 10:01:14 -08:00
README.md
apparmor_test.go fix all the typos across the project 2018-02-11 11:04:14 +08:00
benchmark_util.go use core client with explicit version globally 2017-10-27 15:48:32 +08:00
container.go remove a todo which is out of date 2018-02-07 09:31:15 +08:00
container_log_rotation_test.go Add node e2e test for log rotation. 2018-02-23 01:42:35 +00:00
container_manager_test.go Removed newlines from e2e log statements. 2018-02-17 22:25:38 -05:00
cpu_manager_test.go Remove unused variables (only assigned to) from test code. 2018-02-27 13:45:31 -08:00
critical_pod_test.go reopen #58913 Fix TODO move GetPauseImageNameForHostArch func 2018-01-31 15:06:32 +08:00
density_test.go Removed newlines from e2e log statements. 2018-02-17 22:25:38 -05:00
device_plugin.go I forgot the fact that the DevicePlugin test itself restarts Kubelet 2018-03-01 14:02:09 -08:00
doc.go
docker_test.go Add node-e2e test for ShareProcessNamespace 2018-02-28 09:15:56 +01:00
docker_util.go Skip log path tests when they are expected to fail. 2018-01-19 10:51:13 -08:00
dockershim_checkpoint_test.go fix all the typos across the project 2018-02-11 11:04:14 +08:00
dynamic_kubelet_config_test.go Rename ConfigOK to KubeletConfigOk 2018-02-14 19:36:52 -08:00
e2e_node_suite_test.go Add a few "+build linux" tags where appropriate. 2018-02-27 13:53:32 -08:00
eviction_test.go increase amount of memory filled by memory allocatable eviction test 2018-03-02 10:00:03 -08:00
framework.go Add [sig-node] to some unowned e2e_node tests 2017-11-27 11:35:44 -05:00
garbage_collector_test.go fix all the typos across the project 2018-02-11 11:04:14 +08:00
gke_environment_test.go Switch to k8s.gcr.io vanity domain 2018-02-07 21:14:19 -08:00
gpu_device_plugin.go Fixes the races around devicemanager Allocate() and endpoint deletion. 2018-03-09 17:00:57 -08:00
gpus.go use core client with explicit version globally 2017-10-27 15:48:32 +08:00
gubernator.sh cluster: move logging library to hack/ 2018-01-13 16:37:50 -08:00
hugepages_test.go Add node e2e to verify hugepages feature 2018-02-08 10:37:04 -05:00
image_id_test.go Switch to k8s.gcr.io vanity domain 2018-02-07 21:14:19 -08:00
image_list.go Merge pull request #57824 from thockin/gcr-vanity 2018-02-08 03:29:32 -08:00
kubelet_test.go Use framework.ConformanceIt for node e2e conformance tests 2017-11-17 17:28:20 +08:00
lifecycle_hook_test.go reopen #58913 Fix TODO move GetPauseImageNameForHostArch func 2018-01-31 15:06:32 +08:00
log_path_test.go Skip log path tests when they are expected to fail. 2018-01-19 10:51:13 -08:00
mirror_pod_test.go expunge the word 'manifest' from Kubelet's config API 2018-02-23 11:44:06 -08:00
node_container_manager_test.go Merge pull request #55898 from dashpole/fix_flaky_allocatable 2017-11-18 13:13:24 -08:00
node_problem_detector_linux.go fix all the typos across the project 2018-02-11 11:04:14 +08:00
pods_container_manager_test.go e2e-node:the value of bestEffortCgroup is wrong 2017-10-27 17:10:53 +08:00
resource_collector.go Benchmark non docker specific 2018-01-16 15:38:35 +08:00
resource_usage_test.go reopen #58913 Fix TODO move GetPauseImageNameForHostArch func 2018-01-31 15:06:32 +08:00
restart_test.go reopen #58913 Fix TODO move GetPauseImageNameForHostArch func 2018-01-31 15:06:32 +08:00
runtime_conformance_test.go Switch to k8s.gcr.io vanity domain 2018-02-07 21:14:19 -08:00
security_context_test.go Add node-e2e test for ShareProcessNamespace 2018-02-28 09:15:56 +01:00
simple_mount.go reopen #58913 Fix TODO move GetPauseImageNameForHostArch func 2018-01-31 15:06:32 +08:00
summary_test.go collect metrics on the /kubepods cgroup on-demand 2018-02-17 12:32:40 -08:00
util.go remove deprecated /proxy paths 2018-02-20 14:42:19 -08:00
volume_manager_test.go

README.md