Merge pull request #57054 from dims/use_cadvisor_constant_cri_endpoint

Automatic merge from submit-queue (batch tested with PRs 56529, 57054). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

kubelet should use the value of the cri container runtime endpoint fr…

…om cadvisor



**What this PR does / why we need it**:
To make cri container runtime endpoint consistent, kubelet (currently using "/var/run/crio.sock" ) should use value of CrioSocket exactly as defined in cadvisor.

**Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*:
Fixes #57005

**Special notes for your reviewer**:

**Release note**:

```release-note
Use the same value for cri container runtime endpoint as defined in cadivsor/crio
```
This commit is contained in:
Kubernetes Submit Queue 2017-12-12 14:04:14 -08:00 committed by GitHub
commit 7320a45fc2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View File

@ -43,7 +43,7 @@ func (i *imageFsInfoProvider) ImageFsInfoLabel() (string, error) {
// 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
if i.runtimeEndpoint == "/var/run/crio.sock" {
if i.runtimeEndpoint == CrioSocket {
return cadvisorfs.LabelCrioImages, nil
}
}

View File

@ -29,6 +29,12 @@ import (
kubetypes "k8s.io/kubernetes/pkg/kubelet/types"
)
const (
// Please keep this in sync with the one in:
// github.com/google/cadvisor/container/crio/client.go
CrioSocket = "/var/run/crio/crio.sock"
)
func CapacityFromMachineInfo(info *cadvisorapi.MachineInfo) v1.ResourceList {
c := v1.ResourceList{
v1.ResourceCPU: *resource.NewMilliQuantity(
@ -71,5 +77,5 @@ func EphemeralStorageCapacityFromFsInfo(info cadvisorapi2.FsInfo) v1.ResourceLis
func UsingLegacyCadvisorStats(runtime, runtimeEndpoint string) bool {
return runtime == kubetypes.RktContainerRuntime ||
(runtime == kubetypes.DockerContainerRuntime && goruntime.GOOS == "linux") ||
runtimeEndpoint == "/var/run/crio.sock"
runtimeEndpoint == CrioSocket
}