Commit Graph

79 Commits

Author SHA1 Message Date
Mark Rossetti
569eb41f23 fixing k8s.io/kubernetes/pkg/kubelet/cm/memorymanager unit tests on Windows
Signed-off-by: Mark Rossetti <marosset@microsoft.com>
2025-02-12 15:27:58 -08:00
Kubernetes Prow Robot
e094e5e89c Merge pull request #129684 from swatisehgal/mm-mgr-logs-improvements
Memory Manager logging improvements
2025-02-07 03:49:55 -08:00
Swati Sehgal
ecd67e2537 node: memory-mgr: Adhere to the message style guidelines
Ensure that the log messages adhere to the message style guildelines
as captured [here](https://github.com/kubernetes/community/blob/master/contributors/devel/sig-instrumentation/logging.md#message-style-guidelines).

Signed-off-by: Swati Sehgal <swsehgal@redhat.com>
2025-02-06 18:53:08 +00:00
Swati Sehgal
a10b3c3555 node: memory-mgr: Add logs when memory allocation is skipped due to QoS
Signed-off-by: Swati Sehgal <swsehgal@redhat.com>
2025-02-06 16:42:19 +00:00
Swati Sehgal
6240febf4c node:memory-mgr: Add logs on the happy path
We have reasonable amount of logs when things go wrong.
While debugging, it can be useful to have logs to indicate that
things have gone as expected especially when it comes to
important events like successful startup of memory manager
and successful allocation of resources.

Signed-off-by: Swati Sehgal <swsehgal@redhat.com>
2025-02-06 16:41:34 +00:00
Swati Sehgal
ee7f2616c6 node: memory-mgr: Update klog.Infof(..., err) to klog.ErrorS(err,...)
Signed-off-by: Swati Sehgal <swsehgal@redhat.com>
2025-02-06 16:41:02 +00:00
Swati Sehgal
07d83acce5 node: memory-mgr: Update log levels and add logs to capture state update
Signed-off-by: Swati Sehgal <swsehgal@redhat.com>
2025-02-06 16:41:02 +00:00
Swati Sehgal
34fd61a3ef node: memory-mgr: Add metadata to logs
Ensure that whereever possible, we provide sufficient metadata
inclusing pod name and UID to allow filtering by pod name or its
UID.

Signed-off-by: Swati Sehgal <swsehgal@redhat.com>
2025-02-06 16:40:56 +00:00
vivzbansal
d1fac494f4 resolve merge conflicts 2025-01-27 19:42:13 +00:00
Swati Sehgal
1714fbfa75 node: memory-mgr: Change ErrorS(nil, ...) to InfoS
Ensure consistency across resource managers and update
ErrorS(nil, ...) to InfoS.

Signed-off-by: Swati Sehgal <swsehgal@redhat.com>
2025-01-16 08:32:42 +00:00
Kubernetes Prow Robot
210f129bb0 Merge pull request #128676 from vivzbansal/sidecar-3
Refactor: Move IsRestartableInitContainer to common utility package
2024-11-08 02:21:50 +00:00
Mark Rossetti
3c9380c449 Memory manager support for Windows nodes (#128560) 2024-11-07 23:32:49 +00:00
vivzbansal
763e810fb5 refactor code to add sidecar container support in IPPR 2024-11-07 21:20:48 +00:00
Kubernetes Prow Robot
3036d107a0 Merge pull request #127074 from Tal-or/mm_fix_checkpoint_file_comparison
memorymanager: fix checkpoint file comparison
2024-11-04 02:13:27 +00:00
Talor Itzhak
d64f34eb2c memorymanager: areMemoryStatesEqual helper
perform the memoryStates comparison in helper function

Signed-off-by: Talor Itzhak <titzhak@redhat.com>
2024-10-29 14:22:04 +02:00
Talor Itzhak
7476f46d71 memorymanager: fix checkpoint file comparison
For a resource within a group, such as memory,
we should validate the total `Free` and total `Reserved` size of the expected `machineState` and state restored from checkpoint file after kubelet start.
If total `Free` and total `Reserved` are equal, the restored state is valid.

The old comparison however was done by reflection.

There're times when the memory accounting is equals
but the allocations across the NUMA nodes are varies.

In such cases we still need to consider the states as equals.

Signed-off-by: Talor Itzhak <titzhak@redhat.com>
2024-10-29 12:10:27 +02:00
holder
6709317ae2 chore: optimize code logic
(cherry picked from commit 91a9a195ac0fe0e31301dc60af0ea868fc4756ff)
2024-10-29 12:08:28 +02:00
holder
6d7a1226d5 update the test case name
(cherry picked from commit de033352079c7d87417f88f073d6b7891e51e590)
2024-10-29 12:08:23 +02:00
holder
39726b119f fix: fix state validate error after memorymanager with static policy start
(cherry picked from commit b91951f847d0b159c9d8ef32688cc96489ac1884)
2024-10-29 12:08:16 +02:00
likakuli
212c4c4851 feat: revert #103979 for it's duplicated
Signed-off-by: likakuli <1154584512@qq.com>
2024-10-23 11:18:42 +02:00
Matthieu MOREL
f777addb05 fix: use ErrorContains(t, err instead of Contains(t, err.Error()
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2024-09-26 22:22:20 +02:00
Talor Itzhak
c019114e41 memorymanager:unit-tests for isAffinityViolatingNUMAAllocations function
Signed-off-by: Talor Itzhak <titzhak@redhat.com>
2024-07-11 17:05:23 +03:00
Talor Itzhak
37399c8d4f memorymanager: avoid violating NUMA node memory allocation rule
According to https://kubernetes.io/blog/2021/08/11/kubernetes-1-22-feature-memory-manager-moves-to-beta/#single-vs-cross-numa-node-allocation
and to the design introduce in the memory manager KEP: https://github.com/kubernetes/enhancements/tree/master/keps/sig-node/1769-memory-manager
the NUMA node can not have both single and cross NUMA node allocations.

There're cases when the chosen affinity hint does not align with the
rule above but the pod get admitted anyway.

The implications are incosistent admission/rejection behaviors from memory manager side.

In order to fix the issue, we should validate that the affinity hint
that has been chosen is not violating the above rule.

Signed-off-by: Talor Itzhak <titzhak@redhat.com>
2024-07-11 17:04:42 +03:00
Talor Itzhak
ddd60de3f3 memorymanager:metrics: add metrics
As part of the memory manager GA graduation effort, we should add
metrics in order to iprove observability.

The metrics also mentioned in the PR https://github.com/kubernetes/enhancements/pull/4251 (which was not merged yet)

Signed-off-by: Talor Itzhak <titzhak@redhat.com>
2023-11-12 09:34:55 +02:00
Kubernetes Prow Robot
960431407c Merge pull request #120715 from gjkim42/do-not-reuse-memory-of-restartable-init-containers
Don't reuse memory of a restartable init container
2023-11-01 01:50:45 +01:00
Gunju Kim
a0610a97b3 pkg/kubelet/cm: Remove deprecated sets.String and sets.Int
This removes deprecated sets.String and sets.Int
- replace sets.String with sets.Set[string]
- replace sets.Int with sets.Set[int]
- replace sets.NewString with sets.New[string]
- replace sets.NewInt with sets.New[int]
- replace sets.(OLD).List with sets.List(NEW)
2023-09-27 22:02:15 +09:00
Gunju Kim
b4e5b868a8 Don't reuse memory of a restartable init container 2023-09-17 14:49:15 +09:00
Yoon Park
934516791c Swap assert.Equal parameters oders to follow convention 2023-04-05 22:01:40 +09:00
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