Commit Graph

189 Commits

Author SHA1 Message Date
Paco Xu
0f49a1e36e fix panic in CRI stats of windows 2024-02-18 15:03:11 +08:00
Mark Rossetti
5ba3883be0
Adding unit test for makeWinContainerStats
Signed-off-by: Mark Rossetti <marosset@microsoft.com>
2024-02-12 09:56:58 -08:00
Mark Rossetti
5691a7899e
Fixing bug with windows criStatsProvider sometimes not reporting AvailableBytes correctly
Signed-off-by: Mark Rossetti <marosset@microsoft.com>
2024-01-18 10:13:49 -08:00
Kubernetes Prow Robot
e1576c8e43
Merge pull request #121924 from saschagrunert/leaky
Remove `leaky` package and move `PodInfraContainerName` to staging
2024-01-04 17:59:30 +01:00
Davanum Srinivas
d621e09a52
remove unused GetRawContainerInfo
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2023-12-15 05:56:22 -08:00
Davanum Srinivas
e2cf9692fc
Remove unused code in kubelet - take 1
spotted `DockerContainer` in types.go and pulling on whether we
really needed it found that a bunch of code is not really
required.

Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2023-12-14 13:31:38 -08:00
Sascha Grunert
140abfc010
Remove leaky package and move PodInfraContainerName to staging
The variable can be reused in other projects like cadvisor or container
runtimes later on to identify the pod infra container. The `leaky`
package itself is actually not needed any more.

Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
2023-11-16 14:34:22 +01:00
Kevin Hannon
26923b91e8 implementation of split disk kep 2023-11-01 14:46:33 -04:00
Kubernetes Prow Robot
92c4b3254f
Merge pull request #118432 from testwill/stats
chore: loop optimization
2023-10-26 06:25:25 +02:00
Kevin Hannon
8ae0d390d7 add container filesystem to CRI api
Co-authored-by: Mike Brown <brownwm@us.ibm.com>
2023-10-23 15:04:30 -04:00
Sascha Grunert
39dcad8a19
Populate CRI filesystem info error
Usually we just log the error but since it's used by the GC we now
populate it up the call stack.

Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
2023-10-16 13:09:04 +02:00
Kubernetes Prow Robot
95bd8b95a7
Merge pull request #100448 from saschagrunert/cri-stats-log
Do not error log CRI stats for not cached partitions
2023-10-14 23:49:12 +02:00
Christoph Mewes
79a7833ade fix typo Mininum => Minimum 2023-09-17 11:24:29 +02:00
Kubernetes Prow Robot
b27670dfbd
Merge pull request #118740 from saschagrunert/kubelet-label-types
Make kubelet label types public
2023-09-06 23:46:57 -07:00
Kubernetes Prow Robot
6b0e66abad
Merge pull request #116968 from mansikulkarni96/windowsStatsFromCRI
kubelet: Implement support for Windows podAndContainerStatsFromCRI
2023-07-18 11:07:10 -07:00
Itamar Holder
7d187f967b Unit tests: CRI swap stats
Signed-off-by: Itamar Holder <iholder@redhat.com>
2023-07-18 02:55:56 +03:00
Itamar Holder
59e3e3897e Add SwapStats to summary API through CRI
Signed-off-by: Itamar Holder <iholder@redhat.com>
2023-07-18 02:55:56 +03:00
Itamar Holder
87ff9c4525 Add swap statistics to CRI-API
Signed-off-by: Itamar Holder <iholder@redhat.com>
2023-07-18 02:55:53 +03:00
Itamar Holder
053d7ac61f Unit tests: cadvisor swap stats
Signed-off-by: Itamar Holder <iholder@redhat.com>
2023-07-18 02:40:02 +03:00
Itamar Holder
c74ee8045d Add SwapStats to summary API through cadvisor
Signed-off-by: Itamar Holder <iholder@redhat.com>
2023-07-18 02:40:02 +03:00
Sascha Grunert
a6554b9d5d
Make kubelet label types public
We use the label definitions in CRI-O, means we now make them public to
stop vendoring/copying this part of Kubernetes.

Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
2023-07-10 10:58:44 +02:00
guoguangwu
9378e580cf chore: loop optimization 2023-06-03 13:39:50 +08:00
Kubernetes Prow Robot
484645e817
Merge pull request #116659 from claudiubelu/skip-flaky-tests-2
unit tests: Skip flaky tests on Windows (part 2)
2023-05-23 20:04:48 -07:00
Clayton Coleman
166256f73e
kubelet: Reduce the interface pod.Manager consumers accept
Every component that uses a pod.Manager should use a stub interface
(like we do for podWorker) that explicitly describes what methods
they use. This will allow podWorker to implement the minimum set
of manager interfaces.
2023-05-12 12:57:27 -04:00
mansikulkarni96
7926656038
kubelet: Implement support for Windows podAndContainerStatsFromCRI
Part of kubernetes/enhancements#2371

Follow up to the initial work introducing CRI API fields for Windows
metrics collection #110754
Windows equivalent work for adding support for Windows
podAndContainerStatsFromCRI #103095, which will allow users to get
Windows pod and container stats only from CRI.

Signed-off-by: mansikulkarni96 <mankulka@redhat.com>
2023-05-01 01:02:44 -04:00
mansikulkarni96
14952cef5b
kubelet: Move Linux stats to a Linux specific file
This commit moves the Linux stats from CRI to a linux specific
file and adds unimplemented methods for platform other than
Linux and Windows.
2023-05-01 01:02:36 -04:00
Claudiu Belu
0979d55443 unit tests: Skip flaky tests on Windows (part 2)
Some of the unit tests are currently flaky on Windows. This commit
skips them until they are resolved.
2023-04-13 12:07:18 +00:00
Sascha Grunert
337f4e524a
Do not error log CRI stats for not cached partitions
We do not have any cached partitions available on Kubelet start with an
empty container storage in CRI-O. This means that the error log message
is not actually an error and more an information.

This means we now pre-filter those cases and do not `klog.ErrorS` any
more. This helps to avoid log spamming in huge clusters.

Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
2023-03-02 10:10:00 +01:00
Madhav Jivrajani
5e1f440d0a *: Fix linter warnings
Adapt to newly improved linters in golangci-lint v1.51.1

Signed-off-by: Madhav Jivrajani <madhav.jiv@gmail.com>
2023-02-07 13:01:41 +05:30
Claudiu Belu
ec753fcb55 unittests: Fixes unit tests for Windows (part 6)
Currently, there are some unit tests that are failing on Windows due to
various reasons:

- On Windows, consecutive time.Now() calls may return the same timestamp, which would cause
  the TestFreeSpaceRemoveByLeastRecentlyUsed test to flake.
- tests in kuberuntime_container_windows_test.go fail on Nodes that have fewer than 3 CPUs,
  expecting the CPU max set to be more than 100% of available CPUs, which is not possible.
- calls in summary_windows_test.go are missing context.
- filterTerminatedContainerInfoAndAssembleByPodCgroupKey will filter and group container
  information by the Pod cgroup key, if it exists. However, we don't have cgroups on Windows,
  thus we can't make the same assertions.
2023-01-31 11:49:26 +00:00
Jurj Andrei George
4df989d719 Skip failing Windows unit tests
As discussed during the SIG Testing meeting on January 10, 2023, failing
Windows unit tests are now skipped.
These changes should be reverted when the unit tests wil get fixed.
Mentioned SIG Testing meeting:
https://docs.google.com/document/d/1z8MQpr_jTwhmjLMUaqQyBk1EYG_Y_3D4y4YdMJ7V1Kk/edit#heading=h.qwblxf2uhgoo
2023-01-18 14:18:41 +02: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
Mengjiao Liu
2940484a9a Fix stats for podAndContainerStatsFromCRI 2022-11-07 10:41:45 +08: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
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
Peter Hunt~
d6ffca04c9 kubelet/stats: drop makePodStorageStats errors to V(6)
and by doing so, fix a bug where the stats providers report a directory is not found after a pod's storage is removed

Signed-off-by: Peter Hunt <pehunt@redhat.com>
2022-08-16 16:54:29 -04:00
Peter Hunt
6d9264247d kubelet/stats: deduplicate makePodStorageStats
Signed-off-by: Peter Hunt <pehunt@redhat.com>
2022-08-16 16:54:29 -04:00
Paco Xu
e073b0fd65 Disable AcceleratorUsage Metrics: ga 2022-07-30 12:31:43 +08: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
Kubernetes Prow Robot
1c1efde70d
Merge pull request #109639 from Abirdcfly/fixduplicateimport
cleanup: remove all duplicate import
2022-07-18 16:55:23 -07:00
Abirdcfly
00b9ead02c cleanup: remove duplicate import
Signed-off-by: Abirdcfly <fp544037857@gmail.com>
2022-07-14 11:25:19 +08:00
JunYang
cafc5d1c82 filter out terminated containers in cadvisor_stats_provider 2022-07-06 19:21:27 +08:00
Zihong Zheng
9e8d8286ca
Revert "filter out terminated containers in cadvisor_stats_provider" 2022-06-15 16:09:37 -07:00
Kubernetes Prow Robot
6dc592e347
Merge pull request #108787 from 249043822/cadvisor_stat_provider_filter_0
filter out terminated containers in cadvisor_stats_provider
2022-05-20 16:50:00 -07:00
ZhangKe10140699
f69fb544fa filter out terminated containers in cadvisor_stats_provider 2022-03-22 16:36:46 +08:00
Peter Hunt
0b7629d2cc kubelet/stats: add unit test for when container logs are found
Signed-off-by: Peter Hunt <pehunt@redhat.com>
2022-02-15 16:34:54 -05:00
Peter Hunt
1c3357db76 kubelet/stats: take container log stats into account when checking ephemeral stats
this commit updates checkEphemeralStorage to be able to add container log stats, if applicable.

It also updates the old check when container log stats aren't found to be more accurate.
Specifically, this check previously worked because of a fluke programming accident:

according to this block in pkg/kubelet/stats/helper.go:113
```
if result.Rootfs != nil {
    rootfsUsage := *cfs.BaseUsageBytes
    result.Rootfs.UsedBytes = &rootfsUsage
}
```

BaseUsageBytes should be the value added, not TotalUsageBytes. However, since in this case
one also needs to account for the calculated log size, which is TotalUsageBytes - BaseUsageBytes
using TotalUsageBytes value accidentally worked.

Updating the case to use the correct value AND log offset fixes this accident and makes
the behavior more in line with what happens when calculating ephemeral storage.

Signed-off-by: Peter Hunt <pehunt@redhat.com>
2022-02-15 16:30:25 -05:00
Peter Hunt
ab0f274a6f kubelet/stats: update cadvisor stats provider with new log location
in https://github.com/kubernetes/kubernetes/pull/74441,
the namespace and name were added to the pod log location.

However, cAdvisor stats provider wasn't correspondingly updated.

since CRI-O uses cAdvisor stats provider by default, despite being a CRI implementation,
eviction with ephemeral storage and container logs doesn't work as expected, until now!

Signed-off-by: Peter Hunt <pehunt@redhat.com>
2022-02-15 16:04:16 -05:00