k3s/pkg/kubelet/kuberuntime
Kubernetes Submit Queue 6843ca5731 Merge pull request #49449 from dhilipkumars/PreStopFix
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
```
2017-08-03 16:43:37 -07:00
..
BUILD Do not try run preStop hook when the gracePeriod is 0 2017-08-03 07:57:21 +05:30
doc.go cmd/kubelet 2016-11-23 15:53:09 -08:00
fake_kuberuntime_manager.go run hack/update-all 2017-06-22 11:31:03 -07:00
helpers.go run hack/update-all 2017-06-22 11:31:03 -07:00
helpers_test.go run hack/update-all 2017-06-22 11:31:03 -07:00
instrumented_services.go Update CRI references 2017-06-09 10:16:40 +08:00
instrumented_services_test.go Improving test coverage for kubelet/kuberuntime. 2017-06-01 09:43:15 +02:00
kuberuntime_container.go Do not try run preStop hook when the gracePeriod is 0 2017-08-03 07:57:21 +05:30
kuberuntime_container_test.go Do not try run preStop hook when the gracePeriod is 0 2017-08-03 07:57:21 +05:30
kuberuntime_gc.go Update CRI references 2017-06-09 10:16:40 +08:00
kuberuntime_gc_test.go run root-rewrite-v1-..., compile 2017-06-22 10:25:57 -07:00
kuberuntime_image.go run hack/update-all 2017-06-22 11:31:03 -07:00
kuberuntime_image_test.go run hack/update-all 2017-06-22 11:31:03 -07:00
kuberuntime_logs.go run root-rewrite-v1-..., compile 2017-06-22 10:25:57 -07:00
kuberuntime_logs_test.go run hack/update-all 2017-06-22 11:31:03 -07:00
kuberuntime_manager.go Merge pull request #48584 from yiqinguo/yiqinguo_eventtype 2017-07-24 13:52:36 -07:00
kuberuntime_manager_test.go run hack/update-all 2017-06-22 11:31:03 -07:00
kuberuntime_sandbox.go run hack/update-all 2017-06-22 11:31:03 -07:00
kuberuntime_sandbox_test.go run hack/update-all 2017-06-22 11:31:03 -07:00
labels.go run hack/update-all 2017-06-22 11:31:03 -07:00
labels_test.go run hack/update-all 2017-06-22 11:31:03 -07:00
legacy.go Move legacy log symlink to kuberuntime 2017-05-05 11:48:08 -07:00
legacy_test.go Move legacy log symlink to kuberuntime 2017-05-05 11:48:08 -07:00
security_context.go allowPrivilegeEscalation: modify api types & add functionality 2017-07-24 12:52:41 -04:00
security_context_test.go run hack/update-all 2017-06-22 11:31:03 -07:00