Commit Graph

1099 Commits

Author SHA1 Message Date
Kubernetes Prow Robot
413ff6751b Merge pull request #98365 from odinuge/cgroup-v2-systemd
Fix cgroup handling for systemd with cgroup v2
2021-03-04 14:40:34 -08:00
Kubernetes Prow Robot
ef44d39be0 Merge pull request #99464 from Nordix/master-fix
Number of sockets is assumed to be same as NUMA nodes in kubelet
2021-03-03 14:41:21 -08:00
Jakub Guzik
85d69cde82 Migrate pkg/kubelet/cm/cpumanager/state to structured logging
Signed-off-by: Jakub Guzik <jakubmguzik@gmail.com>
2021-03-03 01:18:37 +01:00
Artyom Lukianov
95b2777204 memory manager: specify the container cpuset.memory during the creation
Set the container cpuset.memory during the creation and avoid an additional
call to the resources update of the container.

Signed-off-by: Artyom Lukianov <alukiano@redhat.com>
2021-03-02 17:01:46 +02:00
Benjamin Elder
56e092e382 hack/update-bazel.sh 2021-02-28 15:17:29 -08:00
Hanamantagoud
549b615439 Number of sockets is assumed to be same as NUMA nodes 2021-02-26 16:22:50 +05:30
Kubernetes Prow Robot
5a382b2d83 Merge pull request #96594 from b10s/fix-getcgroupsubsystemsv1
Fix the getCgroupSubsystemsV1() which uses only the latest record
2021-02-17 01:25:06 -08:00
Nikhita Raghunath
c3c45b9b8c *: move balajismaniam to emeritus_approvers 2021-02-16 10:55:47 +05:30
Odin Ugedal
124de526cb Fix cgroup handling for systemd with cgroup v2
This fixes issues where kubelet enforces qos and nodeAllocatable on the
worng hierarchy. Kublet will now create the files

/sys/fs/cgroup/kubepods/{burstable,besteffort,}/pod-xyz

when running with systemd as the driver, making it impossible to enforce
the limits on nodeAllocatable.
2021-02-12 10:44:38 +01:00
Kubernetes Prow Robot
d819199065 Merge pull request #97888 from pacoxu/fix/97565
check containerd as well as docker-containerd
2021-02-09 23:46:59 -08:00
Artyom Lukianov
102124464a memory manager: improve the reserved memory validation logic
We will have two layers of the validation.

- the first part of the validation logic will be implemented under the
`ValidateKubeletConfiguration` method
- the second one that requires knowledge about machine topology and
node allocatable resources will be implemented under the memory manager.

Signed-off-by: Artyom Lukianov <alukiano@redhat.com>
2021-02-09 01:10:02 +02:00
Artyom Lukianov
932134034c memory manager: update API constant to have camel case format
Signed-off-by: Artyom Lukianov <alukiano@redhat.com>
2021-02-09 01:10:02 +02:00
Artyom Lukianov
e8ea461bfd memory manager: update all relevant part of code to use []MemoryReservation
Signed-off-by: Artyom Lukianov <alukiano@redhat.com>
2021-02-09 01:10:01 +02:00
Artyom Lukianov
7561a0f96e memory manager: provide new flag var to parse reserved-memory parameter
The new flag will parse the `--reserved-memory` flag straight forward
to the []kubeletconfig.MemoryReservation variable instead of parsing
it to the middle map representation.

It gives us possibility to get rid of a lot of unneeded code and use the single
presentation for the reserved-memory.

Signed-off-by: Artyom Lukianov <alukiano@redhat.com>
2021-02-09 01:10:01 +02:00
Artyom Lukianov
0fa5dd5532 memory manager: move the fakeTopologyManagerWithHint
Move the fakeTopologyManagerWithHint and all related methods
from the topology manager package to the memory manager static policy unittests.

Signed-off-by: Artyom Lukianov <alukiano@redhat.com>
2021-02-09 01:10:01 +02:00
Artyom Lukianov
d0089db2ec memory manager: remove unused variable under stateCheckpoint 2021-02-09 01:10:01 +02:00
Artyom Lukianov
ff2a110920 memory manager: provide the new type to contain resources for each NUMA node
Signed-off-by: Artyom Lukianov <alukiano@redhat.com>
2021-02-09 01:10:00 +02:00
Artyom Lukianov
a015e4163f memory manager: rename state structs and fields
The commit rename state structs and some fields under these structs.

- NodeMap -> NUMANodeMap
- NodeState -> NUMANodeState
- NUMANodeState.Nodes -> NUMANodesState.Cells

Signed-off-by: Artyom Lukianov <alukiano@redhat.com>
2021-02-09 01:10:00 +02:00
Artyom Lukianov
aa63e5aed2 memory manager: provide an additional validation for reserved memory
Calculate the total amount of reserved memory only for NUMA nodes
that are existing under the machine.

Signed-off-by: Artyom Lukianov <alukiano@redhat.com>
2021-02-09 01:10:00 +02:00
Artyom Lukianov
24be74e759 memory manager: update bazel files
Signed-off-by: Artyom Lukianov <alukiano@redhat.com>
2021-02-09 01:09:59 +02:00
Artyom Lukianov
f7845ed4e9 memory manager: provide memory manager static policy unittests
Signed-off-by: Artyom Lukianov <alukiano@redhat.com>
2021-02-09 01:09:59 +02:00
Krzysztof Wiatrzyk
d7175a831c memory manager: adding Memory Manager component unit tests
Signed-off-by: Krzysztof Wiatrzyk <k.wiatrzyk@samsung.com>
2021-02-09 01:09:59 +02:00
Pawel Rapacz
18c8a821e0 memory manager: implement GetPodTopologyHints method
It will return memory and hugepages hints for the whole pod.

Signed-off-by: Pawel Rapacz <p.rapacz@partner.samsung.com>
2021-02-09 01:09:59 +02:00
Artyom Lukianov
abb94bec51 memory manager: implement the memory manager static policy
- The `Allocate` method will try to allocate the memory according to the affinity hints
  saved under the `TopologyManager` store. If the store does not have any hints for the memory
  it will call `getDefaultHint` to get the default hint. If the affinity does not satisfy
  the memory request, it will call `extendTopologyManagerHint` to extend the topology hint to
  satisfy the memory request. Once it has the preferred hint, it will allocate the memory and
  update the the memory manager state accordingly.

- The `RemoveContainer` will release the allocated memory and update the memory manager state accordingly.

- The `GetTopologyHints` method will try to re-generate topology hints when the container already presents
  under the memory manager state. If it does not present it will call `calculateHints` to get topology hints.
  The `calculateHints` uses an approach similar to the one used under the CPU manager:
  1. If the container memory request can be satisfied by the single NUMA node, it will not allocate the memory from
     more than one NUMA node and it will set only single NUMA hints as the preferred one.
     It can affect the density, but it gives us guarantees regarding the NUMA alignment.
  2. The NUMA node used in the multi NUMA assignment can not be used in the single NUMA assignment.
     And the NUMA node used in the single NUMA assignment can not be used in the multi NUMA assignment.
  3. Only hints with NUMA node that have enough memory will be returned.

Signed-off-by: Artyom Lukianov <alukiano@redhat.com>
2021-02-09 01:09:59 +02:00
Artyom Lukianov
afb1ae3458 memory manager: add fake memory manager
The fake memory manager needed for the unittesting.

Signed-off-by: Artyom Lukianov <alukiano@redhat.com>
2021-02-09 01:09:59 +02:00
Cezary Zukowski
4a64102918 memory manager: validate reserved-memory against Node Allocatable
Reserved memory of all kinds (and over all
NUMA nodes) must be equal to the values determined
by Node Allocatable feature.

Signed-off-by: Cezary Zukowski <c.zukowski@samsung.com>
2021-02-09 00:54:58 +02:00
Artyom Lukianov
9ae499ae46 memory manager: pass memory manager flags to the container manager
Pass memory manager flags to the container manager and call all relevant memory manager
methods under the container manager.

Signed-off-by: Byonggon Chun <bg.chun@samsung.com>
2021-02-09 00:54:58 +02:00
Artyom Lukianov
95f81372e2 memory manager: implement the manager interface methods
The commit adds implementation for methods:
- Start
- AddContainer
- Allocate
- RemoveContainer
- State
- GetTopologyHints

Signed-off-by: Artyom Lukianov <alukiano@redhat.com>
2021-02-09 00:54:58 +02:00
Artyom Lukianov
d0caec90e2 memory manager: add the policy interface
The commit also adds two policy skeletons:
- none
- static

Signed-off-by: Artyom Lukianov <alukiano@redhat.com>
2021-02-09 00:54:58 +02:00
Artyom Lukianov
86df524948 memory manager: provide unittest for the state package
The commit includes tests to verify the functionallity:
- to restore state from the file
- to store the state to the file
- to clean the state from old data

Signed-off-by: Artyom Lukianov <alukiano@redhat.com>
2021-02-09 00:54:58 +02:00
Artyom Lukianov
48ca6e53e6 memory manager: provide and use the checkpoint manager
The checkpoint manager provides a way to save the memory manager
`MemoryTable` both under the memory and under the state file.

Saving the `MemoryTable` under the state file can be useful when kubelet
restarted and you want to restore memory allocations for running containers.
Also, it provides a way to monitor memory allocations done by the memory manager,
and in the future, the state file content can be exposed under the pod metrics.

Signed-off-by: Artyom Lukianov <alukiano@redhat.com>
2021-02-09 00:54:58 +02:00
Artyom Lukianov
4c75be0604 memory manager: provide the skeleton for the memory manager
Provide memory manager struct and methods that should be implemented.

Signed-off-by: Artyom Lukianov <alukiano@redhat.com>
2021-02-09 00:54:58 +02:00
Ryan Phillips
f918e11e3a register all pending pod deletions and check for kill
do not delete the cgroup from a pod when it is being killed
2021-02-04 11:45:42 -06:00
Kubernetes Prow Robot
e6e079aac3 Merge pull request #97748 from heqg/collides-state
Fix variable 'state' collides with imported package name
2021-01-28 17:51:40 -08:00
Kubernetes Prow Robot
889cf714c1 Merge pull request #95111 from choury/patch-2
make podTopologyHints protected by lock
2021-01-26 04:18:34 -08:00
choury
fe089a2d12 make podTopologyHints protected by lock
It crashed kubelet by "concurrent map read and map write"
2021-01-26 10:36:05 +08:00
Kubernetes Prow Robot
06a7e2bacf Merge pull request #96781 from fighterhit/fix-kukelet-device-plugin-bug
Fix: kubelet return error when device plugin sets PreStartRequired true while creating pods with 0 resource
2021-01-25 17:59:00 -08:00
pacoxu
89c42bd3d5 check containerd as process name instead of docker-containerd
Signed-off-by: pacoxu <paco.xu@daocloud.io>
2021-01-23 10:55:18 +08:00
b10s
de60340e51 Improve the getCgroupSubsystemsV1() which uses random record per subsystem
returned by libcontainercgroups.GetCgroupMounts().

Example array from GetCgroupMounts():
```
[
        {
                Mountpoint: "/sys/fs/cgroup/systemd",
                Root: "/",
                Subsystems: []string len: 1, cap: 1, ["systemd"],},
        {
                Mountpoint: "/sys/fs/cgroup/cpu,cpuacct",
                Root: "/",
                Subsystems: []string len: 2, cap: 2, ["cpu","cpuacct"],},
        {
                Mountpoint: "/sys/fs/cgroup/systemd/some/path",
                Root: "/some/path",
                Subsystems: []string len: 1, cap: 1, ["systemd"],},
]
```
becames a map:
```
[
        "memory": "/sys/fs/cgroup/memory/kubepods",
        "systemd": "/sys/fs/cgroup/systemd/some/path",
]
```
which seems to be wrong.

Using shortest path of mountpoint per subsystem would be more reliable.

reference issue: https://github.com/kubernetes/kubernetes/issues/95488
2021-01-22 22:21:46 +09:00
Artyom Lukianov
38dc7509f8 cpu manager: specify the container CPU set during the creation
We can set the container cpuset.cpus diring the creation and it
will not need to call to update resources after the container creation.

Additional side effect of the change, that the runc process that responsible
to create the container will run with the same CPU affinity because the
runc runs on the cpuset provided in the config.json arg.

It will allow to prevent undesirable interupts on isolated CPUs.

Signed-off-by: Artyom Lukianov <alukiano@redhat.com>
2021-01-20 17:53:33 +02:00
Artyom Lukianov
60678a24ca Update CPU manager GetCPUs method to return pointer to CPUSet 2021-01-20 13:21:57 +02:00
Artyom Lukianov
69db36b958 Provide additional methods under the CPUSet
- ToSliceInt64 returns sorted slice of cores IDs in int64 format
- ToSliceNoSortInt64 returns slice of cores IDs in int64 format

Signed-off-by: Artyom Lukianov <alukiano@redhat.com>
2021-01-20 13:21:57 +02:00
fighterhit
16c6b99fcd del unused value 2021-01-13 12:43:54 +08:00
fighterhit
24dd9b1f04 add a test to demonstrate PR#96781 2021-01-13 11:27:30 +08:00
Kubernetes Prow Robot
04b6b7c12b Merge pull request #97787 from heqg/expect-policy_static_test
fix typo of [expect] in pkg/kubelet/../policy_static_test.go
2021-01-07 00:53:45 -08:00
he.qingguo
d9368f53ad fix typo of [expect] in pkg/kubelet/../policy_static_test.go
Signed-off-by: he.qingguo <he.qingguo@zte.com.cn>
2021-01-07 12:20:03 +08:00
Kubernetes Prow Robot
e456b45a2a Merge pull request #97749 from heqg/errorf-wrap
The code in TestNonePolicyName does not need to wrap, so fix it.
2021-01-06 12:02:04 -08:00
he.qingguo
8826d12bb0 The code in TestNonePolicyName does not need to wrap, so fix it.
Signed-off-by: he.qingguo <he.qingguo@zte.com.cn>
2021-01-06 10:48:30 +08:00
he.qingguo
8249cd611d Fix variable 'state' collides with imported package name
Signed-off-by: he.qingguo <he.qingguo@zte.com.cn>
2021-01-06 10:31:47 +08:00
Kubernetes Prow Robot
10c1c3acf6 Merge pull request #96906 from Rajalakshmi-Girish/issue-96853
Fixes the unit tests to be more tolerant with error messages
2021-01-05 17:09:51 -08:00