Skip to content

Commit

Permalink
use container stats from cadvisor for cri-dockerd
Browse files Browse the repository at this point in the history
  • Loading branch information
kinarashah committed Feb 13, 2023
1 parent 5c1d2d4 commit de0f3e6
Show file tree
Hide file tree
Showing 251 changed files with 31,329 additions and 3 deletions.
4 changes: 4 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ require (
github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a // indirect
github.com/auth0/go-jwt-middleware v1.0.1 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/blang/semver v3.5.1+incompatible // indirect
github.com/boltdb/bolt v1.3.1 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/chai2010/gettext-go v0.0.0-20160711120539-c6fed771bfd5 // indirect
Expand All @@ -159,6 +160,8 @@ require (
github.com/coreos/go-semver v0.3.0 // indirect
github.com/cyphar/filepath-securejoin v0.2.3 // indirect
github.com/daviddengcn/go-colortext v0.0.0-20160507010035-511bcaf42ccd // indirect
github.com/docker/docker v20.10.12+incompatible // indirect
github.com/docker/go-connections v0.4.0 // indirect
github.com/dustin/go-humanize v1.0.0 // indirect
github.com/euank/go-kmsg-parser v2.0.0+incompatible // indirect
github.com/exponent-io/jsonpath v0.0.0-20151013193312-d6023ce2651d // indirect
Expand Down Expand Up @@ -209,6 +212,7 @@ require (
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f // indirect
github.com/nxadm/tail v1.4.4 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.0.2 // indirect
github.com/opencontainers/runtime-spec v1.0.3-0.20210326190908-1c3f411f0417 // indirect
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
github.com/pquerna/cachecontrol v0.0.0-20171018203845-0dec1b30a021 // indirect
Expand Down
1 change: 1 addition & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ github.com/mohae/deepcopy v0.0.0-20170603005431-491d3605edfb h1:e+l77LJOEqXTIQih
github.com/mohae/deepcopy v0.0.0-20170603005431-491d3605edfb/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8=
github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 h1:n6/2gBQ3RWajuToeY6ZtZTIKv2v7ThUy5KKusIT0yc0=
github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00/go.mod h1:Pm3mSP3c5uWn86xMLZ5Sa7JB9GsEZySvHYXCTK4E9q4=
github.com/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A=
github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc=
github.com/mrunalp/fileutils v0.5.0 h1:NKzVxiH7eSk+OQ4M+ZYW1K6h27RUV3MI6NUTsHhU6Z4=
github.com/mrunalp/fileutils v0.5.0/go.mod h1:M1WthSahJixYnrXQl/DFQuteStB1weuxD2QJNHXfbSQ=
Expand Down
1 change: 1 addition & 0 deletions pkg/kubelet/cadvisor/cadvisor_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
// Register supported container handlers.
_ "github.com/google/cadvisor/container/containerd/install"
_ "github.com/google/cadvisor/container/crio/install"
_ "github.com/google/cadvisor/container/docker/install"
_ "github.com/google/cadvisor/container/systemd/install"

"github.com/google/cadvisor/cache/memory"
Expand Down
6 changes: 6 additions & 0 deletions pkg/kubelet/cadvisor/helpers_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ type imageFsInfoProvider struct {
// ImageFsInfoLabel returns the image fs label for the configured runtime.
// For remote runtimes, it handles additional runtimes natively understood by cAdvisor.
func (i *imageFsInfoProvider) ImageFsInfoLabel() (string, error) {
// This is a temporary workaround to get stats for cri-dockerd from cadvisor
// and should be removed. Related to https://github.com/Mirantis/cri-dockerd/issues/135
if i.runtimeEndpoint == "unix://"+CriDockerdSocketv124 || i.runtimeEndpoint == CriDockerdSocketv123 ||
i.runtimeEndpoint == CriDockerdSocketv124 || i.runtimeEndpoint == "unix://"+CriDockerdSocketv123 {
return cadvisorfs.LabelDockerImages, nil
}
// This is a temporary workaround to get stats for cri-o from cadvisor
// and should be removed.
// Related to https://github.com/kubernetes/kubernetes/issues/51798
Expand Down
9 changes: 7 additions & 2 deletions pkg/kubelet/cadvisor/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ const (
// CrioSocket is the path to the CRI-O socket.
// Please keep this in sync with the one in:
// github.com/google/cadvisor/tree/master/container/crio/client.go
CrioSocket = "/var/run/crio/crio.sock"
CrioSocket = "/var/run/crio/crio.sock"
CriDockerdSocketv123 = "/var/run/dockershim.sock"
CriDockerdSocketv124 = "/var/run/cri-dockerd.sock"
)

// CapacityFromMachineInfo returns the capacity of the resources from the machine info.
Expand Down Expand Up @@ -68,6 +70,9 @@ func EphemeralStorageCapacityFromFsInfo(info cadvisorapi2.FsInfo) v1.ResourceLis
// TODO: cri-o relies on cadvisor as a temporary workaround. The code should
// be removed. Related issue:
// https://github.com/kubernetes/kubernetes/issues/51798
// Related issue for cri-dockerd: https://github.com/Mirantis/cri-dockerd/issues/135
func UsingLegacyCadvisorStats(runtimeEndpoint string) bool {
return runtimeEndpoint == CrioSocket || runtimeEndpoint == "unix://"+CrioSocket
return runtimeEndpoint == CrioSocket || runtimeEndpoint == "unix://"+CrioSocket ||
runtimeEndpoint == CriDockerdSocketv123 || runtimeEndpoint == "unix://"+CriDockerdSocketv124 ||
runtimeEndpoint == CriDockerdSocketv124
}
4 changes: 3 additions & 1 deletion pkg/kubelet/kubelet.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,9 @@ func PreInitRuntimeService(kubeCfg *kubeletconfiginternal.KubeletConfiguration,
}

kubeDeps.useLegacyCadvisorStats = cadvisor.UsingLegacyCadvisorStats(remoteRuntimeEndpoint)

if kubeDeps.useLegacyCadvisorStats {
klog.InfoS("using legacy cadvisor stats for remote runtime endpoint %s", remoteRuntimeEndpoint)
}
return nil
}

Expand Down
21 changes: 21 additions & 0 deletions vendor/github.com/blang/semver/.travis.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions vendor/github.com/blang/semver/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

194 changes: 194 additions & 0 deletions vendor/github.com/blang/semver/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions vendor/github.com/blang/semver/json.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions vendor/github.com/blang/semver/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit de0f3e6

Please sign in to comment.