k3s/pkg
Kubernetes Submit Queue ce5c41ab0f Merge pull request #52363 from balajismaniam/fix-cpuman-restartpol-never-bug
Automatic merge from submit-queue (batch tested with PRs 52442, 52247, 46542, 52363, 51781)

Make CPU manager release CPUs when Pod enters completed phase. 

**What this PR does / why we need it**: When CPU manager is enabled, this PR releases allocated CPUs when container is not running and is non-restartable. 

**Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes #52351

**Special notes for your reviewer**:
This bug is only reproduced for pods with `restartPolicy` = `Never` or `OnFailure`.  The following output is from a 4 CPU node. This bug can be reproduced as long >= half the cores are requested. 

pod1.yaml:
```
apiVersion: v1
kind: Pod
metadata:
  name: test-pod1
spec:
  containers:
  - image: ubuntu
    command: ["/bin/bash"]
    args: ["-c", "sleep 5"]
    name: test-container1
    resources:
      requests:
        cpu: 2
        memory: 100Mi
      limits:
        cpu: 2
        memory: 100Mi
  restartPolicy: "Never"
```

pod2.yaml:
```
apiVersion: v1
kind: Pod
metadata:
  name: test-pod2
spec:
  containers:
  - image: ubuntu
    command: ["/bin/bash"]
    args: ["-c", "sleep 5"]
    name: test-container1
    resources:
      requests:
        cpu: 2
        memory: 100Mi
      limits:
        cpu: 2
        memory: 100Mi
  restartPolicy: "Never"
```
Run a local Kubernetes cluster with CPU manager enabled. 
```sh
KUBELET_FLAGS='--feature-gates=CPUManager=true --cpu-manager-policy=static --cpu-manager-reconcile-period=1s --kube-reserved=cpu=500m' ./hack/local-up-cluster.sh
```
_Before:_
Create `test-pod1` using pod1.yaml. 
```
./cluster/kubectl.sh create -f pod1.yaml
```
Wait for the pod to complete and wait another 90 seconds (give enough time for GC to kick-in). 

Create `test-pod2` using pod2.yaml. 
```
./cluster/kubectl.sh create -f pod2.yaml
```

Get all pods in the cluster. 
```
./cluster/kubectl.sh get pods -a
NAME        READY     STATUS                                         RESTARTS   AGE
test-pod1   0/1       Completed                                      0          1m
test-pod2   0/1       not enough cpus available to satisfy request   0          9s
```

_After:_
Create `test-pod1` using pod1.yaml. 
```
./cluster/kubectl.sh create -f pod1.yaml
```
Wait for the pod to complete and wait another 90 seconds (give enough time for GC to kick-in). 

Create `test-pod2` using pod2.yaml. 
```
./cluster/kubectl.sh create -f pod2.yaml
```

Get all pods in the cluster. 
```
./cluster/kubectl.sh get pods -a
NAME        READY     STATUS      RESTARTS   AGE
test-pod1   0/1       Completed    0          1m
test-pod2   0/1       Completed    0          9s
```
2017-09-15 00:11:14 -07:00
..
api Merge pull request #51601 from caesarxuchao/minor-test-fix 2017-09-13 09:30:01 -07:00
apimachinery/tests Use buildozer to delete licenses() rules except under third_party/ 2017-08-11 09:32:39 -07:00
apis '*' is valid for allowed seccomp profiles 2017-09-11 11:47:03 -07:00
auth generated 2017-09-01 19:11:19 +08:00
bootstrap/api Add extra group constants and validation to `pkg/bootstrap/api`. 2017-08-25 16:04:53 -05:00
capabilities Merge pull request #49853 from duan-yue/capabilities 2017-08-12 02:35:57 -07:00
client Disable default paging in list watches 2017-09-06 23:10:59 -04:00
cloudprovider Merge pull request #52169 from dims/remove-links-to-specific-cloud-providers 2017-09-12 08:46:12 -07:00
controller Merge pull request #46542 from derekwaynecarr/quota-ignore-pod-whose-node-lost 2017-09-15 00:11:10 -07:00
credentialprovider Use buildozer to delete licenses() rules except under third_party/ 2017-08-11 09:32:39 -07:00
features Merge pull request #51943 from CaoShuFeng/feature_gate 2017-09-06 06:54:30 -07:00
fieldpath Use buildozer to delete licenses() rules except under third_party/ 2017-08-11 09:32:39 -07:00
generated German Translation 2017-09-07 19:41:24 +02:00
hyperkube Remove kubectl's dependence on schema file in pkg/api/validation. 2017-08-16 16:38:28 -07:00
kubeapiserver bazel 2017-09-06 10:21:01 -07:00
kubectl Workaround go-junit-report bug for TestApps 2017-09-13 07:28:36 -07:00
kubelet Merge pull request #52363 from balajismaniam/fix-cpuman-restartpol-never-bug 2017-09-15 00:11:14 -07:00
kubemark Revert "Remove deprecated and experimental fields from KubeletConfiguration" 2017-09-02 16:30:56 +02:00
master Prevent enabling alpha APIs by default 2017-09-12 09:48:03 -04:00
printers Move consumers of autoscaling/v2alpha1 to v2beta1 2017-09-05 17:49:30 -04:00
probe Use buildozer to delete licenses() rules except under third_party/ 2017-08-11 09:32:39 -07:00
proxy Merge pull request #51682 from m1093782566/ipvs-rsync-iptables 2017-09-03 15:48:31 -07:00
quota Ignore pods for quota that exceed deletion grace period 2017-09-11 13:31:52 -04:00
registry Allow watch cache to be disabled per type 2017-09-08 13:42:28 -04:00
routes Use buildozer to delete licenses() rules except under third_party/ 2017-08-11 09:32:39 -07:00
security Merge pull request #51408 from feiskyer/magic 2017-08-31 21:09:17 -07:00
securitycontext Use buildozer to delete licenses() rules except under third_party/ 2017-08-11 09:32:39 -07:00
serviceaccount Merge pull request #50876 from enj/enj/f/owners_reviewer 2017-08-18 05:42:07 -07:00
ssh update cadvisor, docker, and runc godeps 2017-09-05 12:38:57 -07:00
util Merge pull request #51252 from andyzhangx/azuredisk-windows 2017-09-12 17:43:13 -07:00
version Use buildozer to delete licenses() rules except under third_party/ 2017-08-11 09:32:39 -07:00
volume Merge pull request #51387 from alrs/fix-storageos-swallowed-err 2017-09-13 11:10:24 -07:00
watch Remove BUILD reference to removed files 2017-08-16 11:22:37 -07:00
BUILD Remove BUILD reference to removed files 2017-08-16 11:22:37 -07:00
OWNERS