Commit Graph

10282 Commits

Author SHA1 Message Date
Francesco Romani
a6b928d90c kubelet: cpumgr: internal variable trivial rename
CPUManager is going GA, thus it makes little sense
to keep the names of the internal configuration
variables `Experimental*`.

Trivial rename only.

Signed-off-by: Francesco Romani <fromani@redhat.com>
2022-11-02 18:41:42 +01:00
Francesco Romani
5e12338a22 node: cpumgr: address golint complains
Add docstrings and trivial fixes.

Signed-off-by: Francesco Romani <fromani@redhat.com>
2022-11-02 18:41:42 +01:00
Francesco Romani
ff44dc1932 cpumanager: the FG is locked to default (ON)
hence we can remove the if() guards, the feature
is always available.

Signed-off-by: Francesco Romani <fromani@redhat.com>
2022-11-02 18:41:41 +01:00
Antonio Ojea
9c2b333925 Revert "plumb context from CRI calls through kubelet"
This reverts commit f43b4f1b95.
2022-11-02 13:37:23 +00:00
Kubernetes Prow Robot
5899432f92
Merge pull request #113481 from rphillips/fixes/77063
kubelet: fix pod log line corruption when using timestamps and long lines
2022-11-01 19:59:50 -07:00
Kubernetes Prow Robot
9bbd0fbdb2
Merge pull request #113476 from marosset/hpc-to-stable
Promoting WindowsHostProcessContainers to stable
2022-11-01 19:59:43 -07:00
Kubernetes Prow Robot
7b84436168
Merge pull request #113408 from dashpole/kubelet_context
Plumb context to Kubelet CRI calls
2022-11-01 19:59:08 -07:00
Kubernetes Prow Robot
2452a95bd4
Merge pull request #112796 from SataQiu/clean-kubelet-20220930
kubelet: remove the unused constant AnnotationInvalidReason since sysctl annotations are deprecated and migrated to fields
2022-11-01 14:56:45 -07:00
Mark Rossetti
498d065cc5
Promoting WindowsHostProcessContainers to stable
Signed-off-by: Mark Rossetti <marosset@microsoft.com>
2022-11-01 14:06:25 -07:00
Kubernetes Prow Robot
9b72f20156
Merge pull request #112373 from loktev-d/k8s_109717
Add unit tests for active_deadline.go
2022-11-01 12:54:44 -07:00
Kubernetes Prow Robot
1a41cb8985
Merge pull request #113021 from rphillips/fixes/112936
kubelet: fix nil crash in allocateRemainingFrom
2022-11-01 10:46:45 -07:00
Kubernetes Prow Robot
e6060f2780
Merge pull request #111220 from giuseppe/drop-superfluous-function
kubelet: remove superfluous function
2022-11-01 09:34:45 -07:00
Ryan Phillips
ddae396ce3 kubelet: fix pod log line corruption when using timestamps and long lines 2022-11-01 09:22:30 -05:00
Kubernetes Prow Robot
2d14d50b31
Merge pull request #113406 from jsafrane/fix-selinux-check-of-mounted
Fix SELinux check of mounted volumes
2022-11-01 04:14:45 -07:00
Kubernetes Prow Robot
4c657e5014
Merge pull request #110403 from claudiubelu/unittests-3
unittests: Fixes unit tests for Windows (part 3)
2022-10-31 15:52:44 -07:00
Kubernetes Prow Robot
f892ab1bd7
Merge pull request #113405 from jsafrane/reduce-log-noise-on-selinux
Reduce log noise on SELinux mount mismatch
2022-10-31 13:14:56 -07:00
Jan Safranek
d37808faae Report error on a pod startup on SELinux mismatch
When a volume is already mounted with an unexpected SELinux label,
kubelet must unmount it first and then mount it back with the expected one.
Report an error to user, just in case the unmount takes too long.

In therory, this error should not happen too often, because two Pods with
different SELinux label will not enter Desired State of World, see
dsw.AddPodToVolume. It can happen when DSW and ASW SELinux labels only when
a volume has been deleted from DSW (= Pod was deleted) or a volume was
reconstructed after kubelet restart. In both cases, volume manager should
unmount the volume quickly.
2022-10-31 13:59:23 +01:00
Jan Safranek
805482413a Fix SELinux check of mounted volumes
In PodExistsInVolume with volumeObj.seLinuxMountContext != nil we know that
the volume has been previously mounted with a given SELinuxMountContext.

Either it has been mounted by this kubelet and we know it's correct or it
was by a previous instance of kubelet and the context has been
reconstructed from the filesystem. In both cases, the actual context is
correct, regardless if the volume plugin or PV access mode supports SELinux
mounts.
2022-10-31 13:39:48 +01:00
Kubernetes Prow Robot
d0e86111ef
Merge pull request #112855 from fromanirh/cpumanager-metrics
node: metrics: cpumanager: add metrics about pinning
2022-10-31 03:12:56 -07:00
Kubernetes Prow Robot
9702161caa
Merge pull request #112597 from mythi/grpc-authority
grpc: set localhost Authority to unix client calls
2022-10-31 03:12:45 -07:00
David Ashpole
f43b4f1b95
plumb context from CRI calls through kubelet 2022-10-28 02:55:28 +00:00
Jan Safranek
a910d83070 Reduce log noise on SELinux mount mismatch
The Desired State of World can require a different SELinux mount context than
is in the Actual State of World and it's perfectly OK. For example when
user changes SELinux context of Pods or when the context is reconstructed
after kubelet restart.

Don't spam log and don't report errors to the user as event - reconciler
will do the right thing and unmount the old volume (with wrong context) and
mount a new one in the next reconciliation. It's not an error, it's
expected workflow.
2022-10-27 18:00:42 +02:00
Kubernetes Prow Robot
ab4907d2f4
Merge pull request #112913 from Garrybest/pr_cpumanager
fix GetAllocatableCPUs in cpumanager
2022-10-27 07:20:33 -07:00
Francesco Romani
47d3299781 node: metrics: cpumanager: add pinning metrics
In order to improve the observability of the cpumanager,
add and populate metrics to track if the combination of
the kubelet configuration and podspec would trigger
exclusive core allocation and pinning.

We should avoid leaking any node/machine specific information
(e.g. core ids, even though this is admittedly an extreme example);
tracking these metrics seems to be a good first step, because
it allows us to get feedback without exposing details.

Signed-off-by: Francesco Romani <fromani@redhat.com>
2022-10-27 14:40:40 +02:00
Garrybest
95eb5670cf add GetAllocatableCPUs test in cpumanager
Signed-off-by: Garrybest <garrybest@foxmail.com>
2022-10-27 19:57:12 +08:00
Garrybest
d446f5f90e fix GetAllocatableCPUs in cpumanager
Signed-off-by: Garrybest <garrybest@foxmail.com>
2022-10-27 19:57:06 +08:00
Kubernetes Prow Robot
244c035b87
Merge pull request #110263 from claudiubelu/unittests
unittests: Fixes unit tests for Windows
2022-10-25 14:50:34 -07:00
Claudiu Belu
6f2eeed2e8 unittests: Fixes unit tests for Windows
Currently, there are some unit tests that are failing on Windows due to
various reasons:

- config options not supported on Windows.
- files not closed, which means that they cannot be removed / renamed.
- paths not properly joined (filepath.Join should be used).
- time.Now() is not as precise on Windows, which means that 2
  consecutive calls may return the same timestamp.
- different error messages on Windows.
- files have \r\n line endings on Windows.
- /tmp directory being used, which might not exist on Windows. Instead,
  the OS-specific Temp directory should be used.
- the default value for Kubelet's EvictionHard field was containing
  OS-specific fields. This is now moved, the field is now set during
  Kubelet's initialization, after the config file is read.
2022-10-25 23:46:56 +03:00
Kubernetes Prow Robot
6a709cf07b
Merge pull request #113194 from saltbo/refa-replace-ioutil
Replace the ioutil by the os and io for the pkg/util
2022-10-23 18:08:24 -07:00
saltbo
6f878d92fb
fix: update the fsstore_test.go
Signed-off-by: saltbo <saltbo@foxmail.com>
2022-10-23 21:51:48 +08:00
Kubernetes Prow Robot
a497c56c33
Merge pull request #113030 from Richabanker/kubelet-metrics-slis
add metrics/slis to kubelet health checks
2022-10-21 10:35:52 -07:00
Claudiu Belu
9f95b7b18c unittests: Fixes unit tests for Windows (part 3)
Currently, there are some unit tests that are failing on Windows due to
various reasons:

- paths not properly joined (filepath.Join should be used).
- Proxy Mode IPVS not supported on Windows.
- DeadlineExceeded can occur when trying to read data from an UDP
  socket. This can be used to detect whether the port was closed or not.
- In Windows, with long file name support enabled, file names can have
  up to 32,767 characters. In this case, the error
  windows.ERROR_FILENAME_EXCED_RANGE will be encountered instead.
- files not closed, which means that they cannot be removed / renamed.
- time.Now() is not as precise on Windows, which means that 2
  consecutive calls may return the same timestamp.
- path.Base() will return the same path. filepath.Base() should be used
  instead.
- path.Join() will always join the paths with a / instead of the OS
  specific separator. filepath.Join() should be used instead.
2022-10-21 19:25:48 +03:00
Kubernetes Prow Robot
9bcb81e13f
Merge pull request #113175 from liggitt/pr_normalize_probes_lifecycle_handlers
Record event and metric for lifecycle fallback to http
2022-10-20 02:31:08 -07:00
Kubernetes Prow Robot
ad26b315f2
Merge pull request #86139 from jasimmons/pr_normalize_probes_lifecycle_handlers
Normalize HTTP  lifecycle handlers with HTTP probers
2022-10-19 17:44:56 -07:00
Kubernetes Prow Robot
45636684a4
Merge pull request #112897 from fromanirh/podresources-metrics-e2e-tests
register podresources metrics
2022-10-19 13:57:18 -07:00
Jordan Liggitt
a5d785fae8
Record metric for lifecycle fallback to http 2022-10-19 14:45:25 -04:00
Jordan Liggitt
122b43037e
Record event for lifecycle fallback to http 2022-10-19 14:11:36 -04:00
Kubernetes Prow Robot
bf14677914
Merge pull request #112546 from oscr/the-the
grammar: replace all occurrences of "the the" with "the"
2022-10-19 10:03:02 -07:00
Billie Cleek
dfaaa144ab fallback to http when lifecycle handler request should have been https 2022-10-19 09:51:52 -07:00
Jason Simmons
5a6acf85fa Align lifecycle handlers and probes
Align the behavior of HTTP-based lifecycle handlers and HTTP-based
probers, converging on the probers implementation. This fixes multiple
deficiencies in the current implementation of lifecycle handlers
surrounding what functionality is available.

The functionality is gated by the features.ConsistentHTTPGetHandlers feature gate.
2022-10-19 09:51:52 -07:00
Richa Banker
047f6a736b add metrics/slis to kubelet health checks 2022-10-18 14:06:20 -07:00
Kubernetes Prow Robot
2522420937
Merge pull request #111601 from claudiubelu/skip-unittests
unit tests: Skip Windows-unrelated tests on Windows
2022-10-18 11:29:30 -07:00
Kubernetes Prow Robot
23721935d3
Merge pull request #113129 from chaunceyjiang/pr_remove_redundant_conversion
Remove redundant type conversion
2022-10-18 10:23:19 -07:00
Kubernetes Prow Robot
843ad71cac
Merge pull request #113041 from saschagrunert/kubelet-pods-creation-time
Sort kubelet pods by their creation time
2022-10-18 09:17:19 -07:00
Claudiu Belu
af77381e01 unit tests: Skip Windows-unrelated tests on Windows
Some of the unit tests cannot pass on Windows due to various reasons:

- fsnotify does not have a Windows implementation.
- Proxy Mode IPVS not supported on Windows.
- Seccomp not supported on Windows.
- VolumeMode=Block is not supported on Windows.
- iSCSI volumes are mounted differently on Windows, and iscsiadm is a
  Linux utility.
2022-10-18 12:43:07 +03:00
chaunceyjiang
d2b372e029 Remove redundant type conversion
Signed-off-by: chaunceyjiang <chaunceyjiang@gmail.com>
2022-10-18 14:37:40 +08:00
Kubernetes Prow Robot
6f579d3ceb
Merge pull request #111616 from ndixita/credential-api-ga
Move the Kubelet Credential Provider feature to GA and Update the Credential Provider API to GA
2022-10-15 07:53:09 -07:00
Oscar Utbult
e4f776f230 grammar: replace all occurrences of "the the" with "the" 2022-10-14 09:03:14 +02:00
Sascha Grunert
b296f82c69
Sort kubelet pods by their creation time
There is a corner case when blocking Pod termination via a lifecycle
preStop hook, for example by using this StateFulSet:

```yaml
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: web
spec:
  selector:
    matchLabels:
      app: ubi
  serviceName: "ubi"
  replicas: 1
  template:
    metadata:
      labels:
        app: ubi
    spec:
      terminationGracePeriodSeconds: 1000
      containers:
      - name: ubi
        image: ubuntu:22.04
        command: ['sh', '-c', 'echo The app is running! && sleep 360000']
        ports:
        - containerPort: 80
          name: web
        lifecycle:
          preStop:
            exec:
              command:
              - /bin/sh
              - -c
              - 'echo aaa; trap : TERM INT; sleep infinity & wait'
```

After creation, downscaling, forced deletion and upscaling of the
replica like this:

```
> kubectl apply -f sts.yml
> kubectl scale sts web --replicas=0
> kubectl delete pod web-0 --grace-period=0 --force
> kubectl scale sts web --replicas=1
```

We will end up having two pods running by the container runtime, while
the API only reports one:

```
> kubectl get pods
NAME    READY   STATUS    RESTARTS   AGE
web-0   1/1     Running   0          92s
```

```
> sudo crictl pods
POD ID              CREATED              STATE     NAME     NAMESPACE     ATTEMPT     RUNTIME
e05bb7dbb7e44       12 minutes ago       Ready     web-0    default       0           (default)
d90088614c73b       12 minutes ago       Ready     web-0    default       0           (default)
```

When now running `kubectl exec -it web-0 -- ps -ef`, there is a random chance that we hit the wrong
container reporting the lifecycle command `/bin/sh -c echo aaa; trap : TERM INT; sleep infinity & wait`.

This is caused by the container lookup via its name (and no podUID) at:
02109414e8/pkg/kubelet/kubelet_pods.go (L1905-L1914)

And more specifiy by the conversion of the pod result map to a slice in `GetPods`:
02109414e8/pkg/kubelet/kuberuntime/kuberuntime_manager.go (L407-L411)

We now solve that unexpected behavior by tracking the creation time of
the pod and sorting the result based on that. This will cause to always
match the most recently created pod.

Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
2022-10-13 16:32:44 +02:00
Paco Xu
2ce7a81169 fsnotify: use event.Has instead of "event.Op&h == h" 2022-10-13 13:42:26 +08:00