Commit Graph

72 Commits

Author SHA1 Message Date
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
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
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
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
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
Sergey Kanzhelev
e8ae653c1d disable collecting of accelerator metrics and exposing it for containerd 2021-04-30 22:16:34 +00:00
Krzysztof Gibuła
7097d4f8e2 Migrate pkg/kubelet/stats to structured logging 2021-03-01 18:52:34 +01:00
Kubernetes Prow Robot
ac101cbdda
Merge pull request #97042 from joelsmith/eviction
Measure/compute used ephemeral storage in stats provider, not eviction manager
2020-12-14 08:47:30 -08:00
Derek Carr
acb43c7c4a Rework hostfs metrics
Ephemeral storage usage should be calculated by the metrics code,
not the eviction code.
2020-12-03 13:04:25 -07:00
ruiwen-zhao
36b4ccdb7c Add AcceleratorStats to cri_stats_provider 2020-11-30 19:30:02 +00:00
Qiutong Song
a59a6b984f fix CPU time of pod stats with cs.CPU.Time
Signed-off-by: Qiutong Song <songqt01@gmail.com>
2020-11-03 09:29:18 +00:00
Marek Siarkowicz
7d309e0104 Move Kubelet Summary API to staging repo 2020-09-22 18:23:28 +02:00
kadisi
a75323c76b fix unexpected append mutations about pkg/kubelet package
Signed-off-by: kadisi <iamkadisi@163.com>
Co-authored-by: Dr. Stefan Schimanski <stefan.schimanski@gmail.com>
2020-06-03 13:36:57 +08:00
Davanum Srinivas
442a69c3bd
switch over k/k to use klog v2
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2020-05-16 07:54:27 -04:00
tangcong
2b984b3e3a fix kubelet stats staticcheck error 2020-04-21 07:16:58 +08:00
louisgong
e56d40d048 remove unused param 2020-03-24 09:25:04 +08:00
louisgong
0efb70c0a2 eviction by process number 2020-03-24 09:25:04 +08:00
Kubernetes Prow Robot
ac97b2d65e
Merge pull request #83507 from lyft/support-resetting-cpuacct
Prevent returning invalid usageNanoCores value when cpuacct is reset in a live container
2020-02-09 08:45:53 -08:00
Kubernetes Prow Robot
a931227952
Merge pull request #83504 from lyft/remove-all-terminated-containers
cri_stats_provider: do not consider exited containers when calculating cpu usage
2019-12-16 17:53:39 -08:00
yuxiaobo
81e9f21f83 Correct spelling mistakes
Signed-off-by: yuxiaobo <yuxiaobogo@163.com>
2019-11-06 20:25:19 +08:00
Ashley Kasim
7d4f555449 correctly handle resetting cpuacct in a live container 2019-11-04 13:06:43 -08:00
Ashley Kasim
3be31530d5 cri_stats_provider: do not consider exited containers when calculating cpu usage 2019-10-04 09:07:53 -07:00
Paul Fisher
f798cee51e pkg/kubelet: fix uint64 overflow when elapsed UsageCoreNanoSeconds exceeds 18446744073 2019-09-03 15:54:26 -07:00
Tim Allclair
6510d26b6a Fix misc static check issues 2019-08-21 10:40:21 -07:00
Lantao Liu
11cd4242f6 Remove terminated pod from summary api.
Signed-off-by: Lantao Liu <lantaol@google.com>
2019-05-03 18:34:54 -07:00
Davanum Srinivas
33081c1f07
New staging repository for cri-api
Change-Id: I2160b0b0ec4b9870a2d4452b428e395bbe12afbb
2019-03-26 18:21:04 -04:00
Lantao Liu
0ac651bfc3 Include pod logs in the pod ephemeral storage.
Signed-off-by: Lantao Liu <lantaol@google.com>
2019-03-08 16:42:14 -08:00
Lantao Liu
f14c6c95d6 New pod log directory /var/log/pods/NAMESPACE_NAME_UID.
Signed-off-by: Lantao Liu <lantaol@google.com>
2019-03-08 16:42:14 -08:00
Pengfei Ni
84a7f48cf7 Add network stats for Windows containers 2019-03-07 09:54:50 +08:00
Yu-Ju Hong
191666d6a3 Fix computing of cpu nano core usage
CRI runtimes do not supply cpu nano core usage as it is not part of CRI
stats. However, there are upstream components that still rely on such
stats to function. The previous fix was faulty because the multiple
callers could compete and update the stats, causing
inconsistent/incoherent metrics. This change, instead, creates a
separate call for updating the usage, and rely on eviction manager,
which runs periodically, to trigger the updates. The caveat is that if
eviction manager is completley turned off, no one would compute the
usage.
2019-03-05 09:25:40 -08:00
Kubernetes Prow Robot
4f01eb528e
Merge pull request #74336 from littleroad/exited_container
cri_stats_provider: Implement removeTerminatedContainer correctly
2019-02-28 19:12:07 -08:00
Lu Fengqi
3f8eda37ce cri_stats_provider: overload nil as 0 for exited containers stats
Always report 0 cpu/memory usage for exited containers to make
metrics-server work as expect.

Signed-off-by: Lu Fengqi <lufq.fnst@cn.fujitsu.com>
2019-02-28 10:41:15 +08:00
Lantao Liu
f9b8d27cef Lower the log level for non-exist cadvisor stats.
For exited container, it is quite normal that cri stats
are returned, but there is no corresponding cadvisor stats.
2019-02-26 16:43:42 -08:00
Pengfei Ni
2449b0997c Revert "Add network stats for Windows containers"
This reverts commit 9cf38de44b.
2019-02-15 12:20:23 +08:00
Pengfei Ni
01fbca29cb Kubelet: add usageNanoCores from CRI stats provider 2019-02-07 22:31:30 +08:00