mirror of https://github.com/k3s-io/k3s
6843ca5731
Automatic merge from submit-queue (batch tested with PRs 50103, 49677, 49449, 43586, 48969) Do not try to run preStopHook when the gracePeriod is 0 **What this PR does / why we need it**: 1. Sometimes when the user force deletes a POD with no gracePeriod, its possible that kubelet attempts to execute the preStopHook which will certainly fail. This PR prevents this inavitable PreStopHook failure. ``` kubectl delete --force --grace-period=0 po/<pod-name> ``` 2. This also adds UT for LifeCycle Hooks ``` time go test --cover -v --run "Hook" ./pkg/kubelet/kuberuntime/ . . . --- PASS: TestLifeCycleHook (0.00s) --- PASS: TestLifeCycleHook/PreStop-CMDExec (0.00s) --- PASS: TestLifeCycleHook/PreStop-HTTPGet (0.00s) --- PASS: TestLifeCycleHook/PreStop-NoTimeToRun (0.00s) --- PASS: TestLifeCycleHook/PostStart-CmdExe (0.00s) PASS coverage: 15.3% of statements ok k8s.io/kubernetes/pkg/kubelet/kuberuntime 0.429s ``` **Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes # **Special notes for your reviewer**: **Release note**: ``` Do not try to run preStopHook when the gracePeriod is 0 ``` |
||
---|---|---|
.. | ||
BUILD | ||
doc.go | ||
fake_kuberuntime_manager.go | ||
helpers.go | ||
helpers_test.go | ||
instrumented_services.go | ||
instrumented_services_test.go | ||
kuberuntime_container.go | ||
kuberuntime_container_test.go | ||
kuberuntime_gc.go | ||
kuberuntime_gc_test.go | ||
kuberuntime_image.go | ||
kuberuntime_image_test.go | ||
kuberuntime_logs.go | ||
kuberuntime_logs_test.go | ||
kuberuntime_manager.go | ||
kuberuntime_manager_test.go | ||
kuberuntime_sandbox.go | ||
kuberuntime_sandbox_test.go | ||
labels.go | ||
labels_test.go | ||
legacy.go | ||
legacy_test.go | ||
security_context.go | ||
security_context_test.go |