Commit Graph

931 Commits

Author SHA1 Message Date
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
Kubernetes Prow Robot
4dc3a42712 Merge pull request #97427 from klueska/upstream-fix-cpumanager-race
Fix bug in CPUManager with race on container map access
2021-01-05 11:46:28 -08:00
Kubernetes Prow Robot
b37e9a440e Merge pull request #97193 from JornShen/flaky_devicemanager_test
[flaky test] fix devicemanager TestDevicePluginReRegistrationProbeMode failed
2021-01-05 11:46:21 -08:00
Anthony ARNAUD
6013aaa370 use Lstat instead of Stat for unix socket on windows 2020-12-29 15:14:29 -05:00
Rajalakshmi-Girish
98948ad809 fixes the unit tests to be more tolerant with error messages 2020-12-24 04:47:46 +00:00
Kevin Klues
2fcbd2206d Fix bug in CPUManager with race on map acccess
Signed-off-by: Kevin Klues <kklues@nvidia.com>
2020-12-21 19:11:53 +00:00
Anthony ARNAUD
8bdc3d8970 Port deviceManager in windows container manager 2020-12-16 00:25:26 -05:00
jornshen
93606f8ba3 [flaky test] fix devicemanager TestDevicePluginReRegistrationProbeMode fail 2020-12-10 21:07:49 +08:00
Seth Jennings
ee60ee26e0 kubelet: remove periodic messages from log-level 2 2020-11-30 11:34:00 -06:00
fighterhit
0eaceb7eb5 Fix: kubelet return error when device plugin sets PreStartRequired true while creating pods with 0 resource 2020-11-21 22:44:27 +08:00
Alexey Perevalov
5e6aed4137 Fixes sigfault in case of empty TopologyInfo
Device plugin which implements v1beta interface can return nil in
Topology field

For example nvidia-gpu-deviceplugin
3520254b75/nvidia.go (L147)
Signed-off-by: Alexey Perevalov <alexey.perevalov@huawei.com>
2020-11-13 11:51:47 +03:00
Krzysztof Wiatrzyk
b7714918db Run ./update-all.sh
Signed-off-by: Krzysztof Wiatrzyk <k.wiatrzyk@samsung.com>
2020-11-12 12:25:55 +01:00
sw.han
7b0ccaa1e9 Add tests for getPodDeviceRequest() for devicemanager
Signed-off-by: Krzysztof Wiatrzyk <k.wiatrzyk@samsung.com>
2020-11-12 12:25:55 +01:00
sw.han
ba1e8abce7 Add tests for GetPodTopologyHints() for devicemanager
* Add additional test cases returned by getPodScopeTestCases()

Signed-off-by: Krzysztof Wiatrzyk <k.wiatrzyk@samsung.com>
2020-11-12 12:25:55 +01:00
sw.han
1c4a1ba6ae Update topology hints tests to use pod object for devicemanager
Pod object is more flexible to use and construct
* Update TestGetTopologyHints() to work according to new test cases
* Update topologyHintTestCase{} to include proper field

Signed-off-by: Krzysztof Wiatrzyk <k.wiatrzyk@samsung.com>
2020-11-12 12:25:55 +01:00
sw.han
7ad65bf22d Add tests for GetPodTopologyHints() for cpumanager
* Add tests for getPodRequestedCPU()

Signed-off-by: Krzysztof Wiatrzyk <k.wiatrzyk@samsung.com>
2020-11-12 12:25:55 +01:00
sw.han
35b1f28d0f Refactor topology hints tests for cpumanager
* Extract common tests cases that will be used for both GetTopologyHints()
and GetPodTopologyHints()
* Extract machineInfo as it will be used for both functions as well

Signed-off-by: Krzysztof Wiatrzyk <k.wiatrzyk@samsung.com>
2020-11-12 12:25:55 +01:00
Krzysztof Wiatrzyk
656a08afdf Move scope specific tests from topologymanager under particular scopes
Signed-off-by: Krzysztof Wiatrzyk <k.wiatrzyk@samsung.com>
2020-11-12 12:25:55 +01:00
Krzysztof Wiatrzyk
c786c9a533 Move common tests from topologymanager under scope
Signed-off-by: Krzysztof Wiatrzyk <k.wiatrzyk@samsung.com>
2020-11-12 12:25:55 +01:00