Commit Graph

161 Commits

Author SHA1 Message Date
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
Ciprian Hacman
0819451ea6 Clean up logic for deprecated flag --container-runtime in kubelet
Signed-off-by: Ciprian Hacman <ciprian@hakman.dev>
2022-02-10 13:26:59 +02:00
Kubernetes Prow Robot
518a3c2f70
Merge pull request #107108 from linxiulei/fix_pid
Read number of running processes from /proc/loadavg.
2022-02-10 01:15:47 -08:00
Eric Lin
fea15977c8 Consider threads-max when deciding MaxPID.
Fixes kubernetes#107111
2022-01-17 21:51:59 +00:00
Eric Lin
5fdf24baca Read number of running processes from /proc/loadavg.
Fallback to using sysinfo syscall if failed.

Fix kubernetes#107107
2022-01-11 21:33:53 +00:00
Davanum Srinivas
9405e9b55e
Check in OWNERS modified by update-yamlfmt.sh
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2021-12-09 21:31:26 -05: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
James Sturtevant
ab2e58c416 Get networks stats directly 2021-11-10 12:43:56 -08:00
James Sturtevant
c39945c116 Add unit tests to existing code 2021-11-10 11:50:04 -08:00
Peter Hunt
6b3f8e5662 kubelet: fallback to partial CRI stats if full fails
This is partially to allow the kube alpha tests to pass until CRI implementations have support, but also to handle this error situation a bit more elegantly

Signed-off-by: Peter Hunt <pehunt@redhat.com>
2021-10-29 09:40:20 -04:00
Peter Hunt
feb5f5e0ed kubelet: use helper function to check for nil fields in sandbox stats
Signed-off-by: Peter Hunt <pehunt@redhat.com>
2021-10-29 09:40:20 -04:00
Peter Hunt
85e8a4bf73 kubelet stats: use UsageNanoCores if available
Signed-off-by: Peter Hunt <pehunt@redhat.com>
2021-10-29 09:40:20 -04:00
Peter Hunt
ffdb4b9c4a kubelet: slightly move around some cri stats functions
to reduce duplication and add clarity

Signed-off-by: Peter Hunt <pehunt@redhat.com>
2021-10-29 09:40:20 -04:00
Peter Hunt
d2c436700e kubelet stats: add support for podAndContainerStatsFromCRI
This commit adds an initial implementation of translating from the new CRI fields
to the /stats/summary PodStats object

Signed-off-by: Peter Hunt <pehunt@redhat.com>
2021-10-29 09:40:20 -04:00
Peter Hunt
7866287ba1 kubelet stats: wire up podAndContainerStatsFromCRI feature gate
though it is currently unused

Signed-off-by: Peter Hunt <pehunt@redhat.com>
2021-10-29 09:40:20 -04:00
Kubernetes Prow Robot
cab54856f1
Merge pull request #104933 from vikramcse/automate_mockery
conversion of tests from mockery to mockgen
2021-09-30 18:33:21 -07:00
vikram Jadhav
0de4397490 mockery to mockgen conversion 2021-09-25 16:15:08 +00:00
Kubernetes Prow Robot
44d4d007bf
Merge pull request #103424 from 249043822/br-cadvisor-perf
Optimize kubelet stats provider for perfomace bottleneck
2021-09-21 11:56:18 -07:00
Kubernetes Prow Robot
2f6b9166d7
Merge pull request #104039 from YanzhaoLi/extract-containerdid-from-various-cgrouppath
Get containerID from systemd-style cgroupPath in cri_stats_provider
2021-08-25 17:05:22 -07:00
Stephen Augustus
481cf6fbe7
generated: Run hack/update-gofmt.sh
Signed-off-by: Stephen Augustus <foo@auggie.dev>
2021-08-24 15:47:49 -04:00
YanzhaoLi
545d898584 Extract containerID from systemd-style cgroupPath in cri_stats_provider
And fix test to generate UUID without dash
2021-08-11 19:03:56 -07:00
KeZhang
1467065352 Optimize kubelet stats provider for perfomace bottleneck 2021-07-14 11:11:12 +08:00
Kubernetes Prow Robot
3e588be763
Merge pull request #101712 from SergeyKanzhelev/disableAcceleratorUsageMetricsOnContainerd
disable collecting of accelerator metrics in cAdvisor
2021-05-17 13:39:51 -07:00
Joel Smith
1e0ca5bdc7 Fix log spam for du failure on pod etc-hosts metrics 2021-05-03 08:29:56 -06:00
Sergey Kanzhelev
e8ae653c1d disable collecting of accelerator metrics and exposing it for containerd 2021-04-30 22:16:34 +00:00
Niekvdplas
fec272a7b2 Fixed several spelling mistakes 2021-03-30 23:02:09 +02:00
James Sturtevant
c9eff4e906 Get filesystem stats for files on Windows 2021-03-08 12:50:23 -08:00
Kubernetes Prow Robot
930ca85613
Merge pull request #99607 from krzysiekg/structured_logging_pkg_kubelet_stats
Migrate pkg/kubelet/stats to structured logging
2021-03-04 00:28:38 -08:00