Commit Graph

51 Commits

Author SHA1 Message Date
vinay kulkarni
01b96e7704 Rename ContainerStatus.ResourcesAllocated to ContainerStatus.AllocatedResources 2023-03-10 14:49:26 +00:00
Chen Wang
7db339dba2 This commit contains the following:
1. Scheduler bug-fix + scheduler-focussed E2E tests
2. Add cgroup v2 support for in-place pod resize
3. Enable full E2E pod resize test for containerd>=1.6.9 and EventedPLEG related changes.

Co-Authored-By: Vinay Kulkarni <vskibum@gmail.com>
2023-02-24 18:21:21 +00:00
Vinay Kulkarni
f2bd94a0de In-place Pod Vertical Scaling - core implementation
1. Core Kubelet changes to implement In-place Pod Vertical Scaling.
2. E2E tests for In-place Pod Vertical Scaling.
3. Refactor kubelet code and add missing tests (Derek's kubelet review)
4. Add a new hash over container fields without Resources field to allow feature gate toggling without restarting containers not using the feature.
5. Fix corner-case where resize A->B->A gets ignored
6. Add cgroup v2 support to pod resize E2E test.
KEP: /enhancements/keps/sig-node/1287-in-place-update-pod-resources

Co-authored-by: Chen Wang <Chen.Wang1@ibm.com>
2023-02-24 18:21:21 +00:00
Patrick Ohly
bc6c7fa912 logging: fix names of keys
The stricter checking with the upcoming logcheck v0.4.1 pointed out these names
which don't comply with our recommendations in
https://github.com/kubernetes/community/blob/master/contributors/devel/sig-instrumentation/migration-to-structured-logging.md#name-arguments.
2023-01-23 14:24:29 +01:00
Claudiu Belu
b9bf3e5c49 Replaces path.Operation with filepath.Operation (kubelet)
The path module has a few different functions:
Clean, Split, Join, Ext, Dir, Base, IsAbs. These functions do not
take into account the OS-specific path separator, meaning that they
won't behave as intended on Windows.

For example, Dir is supposed to return all but the last element of the
path. For the path "C:\some\dir\somewhere", it is supposed to return
"C:\some\dir\", however, it returns ".".

Instead of these functions, the ones in filepath should be used instead.
2022-11-08 16:05:48 +00:00
David Ashpole
64af1adace
Second attempt: Plumb context to Kubelet CRI calls (#113591)
* plumb context from CRI calls through kubelet

* clean up extra timeouts

* try fixing incorrectly cancelled context
2022-11-05 06:02:13 -07:00
Antonio Ojea
9c2b333925 Revert "plumb context from CRI calls through kubelet"
This reverts commit f43b4f1b95.
2022-11-02 13:37:23 +00:00
David Ashpole
f43b4f1b95
plumb context from CRI calls through kubelet 2022-10-28 02:55:28 +00: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
127f33f63d
Merge pull request #111221 from inosato/remove-ioutil-from-kubelet
Remove ioutil in kubelet/kubeadm and its tests
2022-09-17 21:56:28 -07:00
Vinay Kulkarni
0ef263c3b0 CRI changes to support implementation of in-place pod resize.
KEP: /enhancements/keps/sig-node/1287-in-place-update-pod-resources
2022-08-02 15:08:25 -07:00
inosato
3b95d3b076 Remove ioutil in kubelet and its tests
Signed-off-by: inosato <si17_21@yahoo.co.jp>
2022-07-30 12:35:26 +09:00
DingShujie
fb3636da40 cpu manager policy set to none, no one remove container id from container map, lead memory leak 2022-03-30 23:25:05 +08:00
Sascha Grunert
de37b9d293
Make CRI v1 the default and allow a fallback to v1alpha2
This patch makes the CRI `v1` API the new project-wide default version.
To allow backwards compatibility, a fallback to `v1alpha2` has been added
as well. This fallback can either used by automatically determined by
the kubelet.

Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
2021-11-17 11:05:05 -08:00
Antonio Ojea
d126b14838 migrate nolint coments to golangci-lint 2021-11-17 13:58:53 +01:00
Kubernetes Prow Robot
c91f9bdc60
Merge pull request #104689 from cynepco3hahue/memory_manager_restricted_policy_fix
kubelet: memory manager: fix preferred topology hints calculation
2021-10-05 06:47:08 -07:00
KeZhang
a629ceeb58 Fix initContainersReusableMemory delete bug 2021-09-15 10:04:49 +08:00
Shiming Zhang
7706d3d281 pkg/kubelet/cm/memorymanager: Fix ErrorS key/value pair 2021-09-06 17:37:04 +08:00
Artyom Lukianov
9ea9798759 kubelet: memory manager: fix topology preferred topology hints calculation
Prevent starting pods with resources satisfied by a single NUMA node on multiple NUMA nodes.
The code returned before it updated the minimal amount of NUMA nodes that can satisfy the container
requests.

Signed-off-by: Artyom Lukianov <alukiano@redhat.com>
2021-08-31 17:46:59 +03:00
Artyom Lukianov
93a237abd8 memory manager: do not clean admitted pods from the state
Signed-off-by: Artyom Lukianov <alukiano@redhat.com>
2021-08-08 16:46:06 +03:00
Artyom Lukianov
bb6d5b1f95 memory manager: provide unittests for init containers re-use
- provide tests for static policy allocation, when init containers
requested memory bigger than the memory requested by app containers
- provide tests for static policy allocation, when init containers
requested memory smaller than the memory requested by app containers
- provide tests to verify that init containers removed from the state
file once the app container started

Signed-off-by: Artyom Lukianov <alukiano@redhat.com>
2021-07-05 20:52:25 +03:00
Artyom Lukianov
960da7895c memory manager: remove init containers once app container started
Remove init containers from the state file once the app container started,
it will release the memory allocated for the init container and can intense
the density of containers on the NUMA node in cases when the memory allocated
for init containers is bigger than the memory allocated for app containers.

Signed-off-by: Artyom Lukianov <alukiano@redhat.com>
2021-07-05 20:52:25 +03:00
Artyom Lukianov
b965502c49 memory manager: re-use the memory allocated for init containers
The idea that during allocation phase we will:

- during call to `Allocate` and `GetTopologyHints`  we will take into account the init containers reusable memory,
which means that we will re-use the memory and update container memory blocks accordingly.
For example for the pod with two init containers that requested: 1Gi and 2Gi,
and app container that requested 4Gi, we can re-use 2Gi of memory.

Signed-off-by: Artyom Lukianov <alukiano@redhat.com>
2021-07-05 20:52:25 +03:00
Artyom Lukianov
03830db82d Implement all necessary methods to provide memory manager data under pod resources metrics
Signed-off-by: Artyom Lukianov <alukiano@redhat.com>
2021-06-22 13:06:32 +03:00
kikimo
9d2135f703 reuse fake topology manager 2021-06-02 01:35:00 +08:00
aheng-ch
ff7b94fa5a fix removing pods from podTopologyHints mapping 2021-05-10 19:44:15 +08:00
Amim Knabben
b078a4ff7a Memory manager structured logging 2021-03-15 15:51:19 -04:00
Krzysztof Gibuła
e46b280f96 Replace klog with with testing.T logging in pkg/kubelet tests 2021-03-07 23:10:02 +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
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
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