Files
Davanum Srinivas f451aa0762 kubelet: depend on github.com/google/cadvisor/lib
Migrate the kubelet (and the kube-proxy conntrack helper) off the full github.com/google/cadvisor module onto the lean github.com/google/cadvisor/lib: repoint info/v1+info/v2 type usage to lib/model and the manager/fs/cache/etc. consumers to lib/*; regenerate the cadvisor.Interface mocks; keep the kubelet-pinned cAdvisor global flags via lib/cadvisorflags.

go.mod: require + replace github.com/google/cadvisor/lib (=> the dims/cadvisor/lib fork for now, until lib is tagged) and drop the full github.com/google/cadvisor module entirely; keep github.com/containerd/containerd/api at v1.11.0 (matching upstream master); add github.com/google/cadvisor to unwanted-dependencies.json unwantedModules so the full module cannot be re-vendored.

test/e2e_node: the one remaining consumer of the full module -- the node-e2e ResourceCollector, which used the v2 HTTP client (client/v2) + v2 API types (info/v2) -- now scrapes the standalone cAdvisor pod's /api/v2.1/stats directly over HTTP+JSON, so test/e2e_node depends on no cAdvisor package. No change to the kubelet's stats surfaces.
2026-06-20 17:27:16 -04:00

60 lines
2.6 KiB
Go

// Copyright 2026 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package model
// Types in this file are the additions over info/v1 that the model needs to be
// the single canonical, kubelet-facing type set (design §6). The rest of model/
// is seeded verbatim from info/v1 so the eventual consumer repoint is mechanical.
// CpuInstStats is instantaneous (rate) CPU usage. On Linux it is derived by
// expose/library from two cumulative ContainerStats samples; on Windows winstats
// supplies it directly from perf counters — hence an optional field, not a pure
// read-time projection. (Shape adapted from info/v2.)
type CpuInstStats struct {
Usage CpuInstUsage `json:"usage"`
}
type CpuInstUsage struct {
// Total CPU usage. Units: nanocores per second.
Total uint64 `json:"total"`
// Per CPU/core usage. Units: nanocores per second.
PerCpu []uint64 `json:"per_cpu_usage,omitempty"`
// Time spent in user space. Units: nanocores per second.
User uint64 `json:"user"`
// Time spent in kernel space. Units: nanocores per second.
System uint64 `json:"system"`
}
// Container is the per-container envelope the library returns to embedders
// (mirrors info/v2.ContainerInfo). It carries the identity the kubelet's
// ContainerLabelsFunc keys pod lookup on (Name/Aliases/Namespace), plus the spec
// and a time-ordered window of samples from the cache.
type Container struct {
Name string `json:"name"`
Aliases []string `json:"aliases,omitempty"`
Namespace string `json:"namespace,omitempty"`
Spec ContainerSpec `json:"spec,omitempty"`
Stats []*ContainerStats `json:"stats,omitempty"`
}
// FilesystemSummary is the per-container filesystem rollup expose/library projects
// from the per-device ContainerStats.Filesystem, reproducing today's single-fs /
// skip-multi-device v2 shape by default (design §6.1 caveat). Library-owned.
type FilesystemSummary struct {
TotalUsageBytes *uint64 `json:"totalUsageBytes,omitempty"`
BaseUsageBytes *uint64 `json:"baseUsageBytes,omitempty"`
InodeUsage *uint64 `json:"inodeUsage,omitempty"`
}