Remove leaky package and move PodInfraContainerName to staging
				
					
				
			The variable can be reused in other projects like cadvisor or container runtimes later on to identify the pod infra container. The `leaky` package itself is actually not needed any more. Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
This commit is contained in:
		@@ -1,25 +0,0 @@
 | 
				
			|||||||
/*
 | 
					 | 
				
			||||||
Copyright 2015 The Kubernetes Authors.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
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 leaky holds bits of kubelet that should be internal but have leaked
 | 
					 | 
				
			||||||
// out through bad abstractions.  TODO: delete all of this.
 | 
					 | 
				
			||||||
package leaky
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
const (
 | 
					 | 
				
			||||||
	// PodInfraContainerName is used in a few places outside of Kubelet, such as indexing
 | 
					 | 
				
			||||||
	// into the container info.
 | 
					 | 
				
			||||||
	PodInfraContainerName = "POD"
 | 
					 | 
				
			||||||
)
 | 
					 | 
				
			||||||
@@ -35,7 +35,6 @@ import (
 | 
				
			|||||||
	"k8s.io/kubernetes/pkg/kubelet/cadvisor"
 | 
						"k8s.io/kubernetes/pkg/kubelet/cadvisor"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/kubelet/cm"
 | 
						"k8s.io/kubernetes/pkg/kubelet/cm"
 | 
				
			||||||
	kubecontainer "k8s.io/kubernetes/pkg/kubelet/container"
 | 
						kubecontainer "k8s.io/kubernetes/pkg/kubelet/container"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/kubelet/leaky"
 | 
					 | 
				
			||||||
	"k8s.io/kubernetes/pkg/kubelet/server/stats"
 | 
						"k8s.io/kubernetes/pkg/kubelet/server/stats"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/kubelet/status"
 | 
						"k8s.io/kubernetes/pkg/kubelet/status"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
@@ -123,7 +122,7 @@ func (p *cadvisorStatsProvider) ListPodStats(_ context.Context) ([]statsapi.PodS
 | 
				
			|||||||
		// Update the PodStats entry with the stats from the container by
 | 
							// Update the PodStats entry with the stats from the container by
 | 
				
			||||||
		// adding it to podStats.Containers.
 | 
							// adding it to podStats.Containers.
 | 
				
			||||||
		containerName := kubetypes.GetContainerName(cinfo.Spec.Labels)
 | 
							containerName := kubetypes.GetContainerName(cinfo.Spec.Labels)
 | 
				
			||||||
		if containerName == leaky.PodInfraContainerName {
 | 
							if containerName == kubetypes.PodInfraContainerName {
 | 
				
			||||||
			// Special case for infrastructure container which is hidden from
 | 
								// Special case for infrastructure container which is hidden from
 | 
				
			||||||
			// the user and has network stats.
 | 
								// the user and has network stats.
 | 
				
			||||||
			podStats.Network = cadvisorInfoToNetworkStats(&cinfo)
 | 
								podStats.Network = cadvisorInfoToNetworkStats(&cinfo)
 | 
				
			||||||
@@ -211,7 +210,7 @@ func (p *cadvisorStatsProvider) ListPodCPUAndMemoryStats(_ context.Context) ([]s
 | 
				
			|||||||
		// Update the PodStats entry with the stats from the container by
 | 
							// Update the PodStats entry with the stats from the container by
 | 
				
			||||||
		// adding it to podStats.Containers.
 | 
							// adding it to podStats.Containers.
 | 
				
			||||||
		containerName := kubetypes.GetContainerName(cinfo.Spec.Labels)
 | 
							containerName := kubetypes.GetContainerName(cinfo.Spec.Labels)
 | 
				
			||||||
		if containerName == leaky.PodInfraContainerName {
 | 
							if containerName == kubetypes.PodInfraContainerName {
 | 
				
			||||||
			// Special case for infrastructure container which is hidden from
 | 
								// Special case for infrastructure container which is hidden from
 | 
				
			||||||
			// the user and has network stats.
 | 
								// the user and has network stats.
 | 
				
			||||||
			podStats.StartTime = metav1.NewTime(cinfo.Spec.CreationTime)
 | 
								podStats.StartTime = metav1.NewTime(cinfo.Spec.CreationTime)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -32,12 +32,12 @@ import (
 | 
				
			|||||||
	featuregatetesting "k8s.io/component-base/featuregate/testing"
 | 
						featuregatetesting "k8s.io/component-base/featuregate/testing"
 | 
				
			||||||
	runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1"
 | 
						runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1"
 | 
				
			||||||
	statsapi "k8s.io/kubelet/pkg/apis/stats/v1alpha1"
 | 
						statsapi "k8s.io/kubelet/pkg/apis/stats/v1alpha1"
 | 
				
			||||||
 | 
						kubelettypes "k8s.io/kubelet/pkg/types"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/features"
 | 
						"k8s.io/kubernetes/pkg/features"
 | 
				
			||||||
	cadvisortest "k8s.io/kubernetes/pkg/kubelet/cadvisor/testing"
 | 
						cadvisortest "k8s.io/kubernetes/pkg/kubelet/cadvisor/testing"
 | 
				
			||||||
	kubecontainer "k8s.io/kubernetes/pkg/kubelet/container"
 | 
						kubecontainer "k8s.io/kubernetes/pkg/kubelet/container"
 | 
				
			||||||
	containertest "k8s.io/kubernetes/pkg/kubelet/container/testing"
 | 
						containertest "k8s.io/kubernetes/pkg/kubelet/container/testing"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/kubelet/kuberuntime"
 | 
						"k8s.io/kubernetes/pkg/kubelet/kuberuntime"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/kubelet/leaky"
 | 
					 | 
				
			||||||
	serverstats "k8s.io/kubernetes/pkg/kubelet/server/stats"
 | 
						serverstats "k8s.io/kubernetes/pkg/kubelet/server/stats"
 | 
				
			||||||
	statustest "k8s.io/kubernetes/pkg/kubelet/status/testing"
 | 
						statustest "k8s.io/kubernetes/pkg/kubelet/status/testing"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/volume"
 | 
						"k8s.io/kubernetes/pkg/volume"
 | 
				
			||||||
@@ -64,23 +64,23 @@ func TestFilterTerminatedContainerInfoAndAssembleByPodCgroupKey(t *testing.T) {
 | 
				
			|||||||
		// ContainerInfo with past creation time and no CPU/memory usage for
 | 
							// ContainerInfo with past creation time and no CPU/memory usage for
 | 
				
			||||||
		// simulating uncleaned cgroups of already terminated containers, which
 | 
							// simulating uncleaned cgroups of already terminated containers, which
 | 
				
			||||||
		// should not be shown in the results.
 | 
							// should not be shown in the results.
 | 
				
			||||||
		"/pod0-i-terminated-1":  getTerminatedContainerInfo(seedPastPod0Infra, pName0, namespace, leaky.PodInfraContainerName),
 | 
							"/pod0-i-terminated-1":  getTerminatedContainerInfo(seedPastPod0Infra, pName0, namespace, kubelettypes.PodInfraContainerName),
 | 
				
			||||||
		"/pod0-c0-terminated-1": getTerminatedContainerInfo(seedPastPod0Container0, pName0, namespace, cName00),
 | 
							"/pod0-c0-terminated-1": getTerminatedContainerInfo(seedPastPod0Container0, pName0, namespace, cName00),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		// Same as above but uses the same creation time as the latest
 | 
							// Same as above but uses the same creation time as the latest
 | 
				
			||||||
		// containers. They are terminated containers, so they should not be in
 | 
							// containers. They are terminated containers, so they should not be in
 | 
				
			||||||
		// the results.
 | 
							// the results.
 | 
				
			||||||
		"/pod0-i-terminated-2":  getTerminatedContainerInfo(seedPod0Infra, pName0, namespace, leaky.PodInfraContainerName),
 | 
							"/pod0-i-terminated-2":  getTerminatedContainerInfo(seedPod0Infra, pName0, namespace, kubelettypes.PodInfraContainerName),
 | 
				
			||||||
		"/pod0-c0-terminated-2": getTerminatedContainerInfo(seedPod0Container0, pName0, namespace, cName00),
 | 
							"/pod0-c0-terminated-2": getTerminatedContainerInfo(seedPod0Container0, pName0, namespace, cName00),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		// The latest containers, which should be in the results.
 | 
							// The latest containers, which should be in the results.
 | 
				
			||||||
		"/pod0-i":  getTestContainerInfo(seedPod0Infra, pName0, namespace, leaky.PodInfraContainerName),
 | 
							"/pod0-i":  getTestContainerInfo(seedPod0Infra, pName0, namespace, kubelettypes.PodInfraContainerName),
 | 
				
			||||||
		"/pod0-c0": getTestContainerInfo(seedPod0Container0, pName0, namespace, cName00),
 | 
							"/pod0-c0": getTestContainerInfo(seedPod0Container0, pName0, namespace, cName00),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		"/pod1-i.slice":  getTestContainerInfo(seedPod0Infra, pName1, namespace, leaky.PodInfraContainerName),
 | 
							"/pod1-i.slice":  getTestContainerInfo(seedPod0Infra, pName1, namespace, kubelettypes.PodInfraContainerName),
 | 
				
			||||||
		"/pod1-c1.slice": getTestContainerInfo(seedPod0Container0, pName1, namespace, cName11),
 | 
							"/pod1-c1.slice": getTestContainerInfo(seedPod0Container0, pName1, namespace, cName11),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		"/pod2-i-terminated-1": getTerminatedContainerInfo(seedPastPod0Infra, pName2, namespace, leaky.PodInfraContainerName),
 | 
							"/pod2-i-terminated-1": getTerminatedContainerInfo(seedPastPod0Infra, pName2, namespace, kubelettypes.PodInfraContainerName),
 | 
				
			||||||
		// ContainerInfo with past creation time and no CPU/memory usage for
 | 
							// ContainerInfo with past creation time and no CPU/memory usage for
 | 
				
			||||||
		// simulating uncleaned cgroups of already terminated containers, which
 | 
							// simulating uncleaned cgroups of already terminated containers, which
 | 
				
			||||||
		// should not be shown in the results.
 | 
							// should not be shown in the results.
 | 
				
			||||||
@@ -174,19 +174,19 @@ func TestCadvisorListPodStats(t *testing.T) {
 | 
				
			|||||||
		"/kubelet":       getTestContainerInfo(seedKubelet, "", "", ""),
 | 
							"/kubelet":       getTestContainerInfo(seedKubelet, "", "", ""),
 | 
				
			||||||
		"/system":        getTestContainerInfo(seedMisc, "", "", ""),
 | 
							"/system":        getTestContainerInfo(seedMisc, "", "", ""),
 | 
				
			||||||
		// Pod0 - Namespace0
 | 
							// Pod0 - Namespace0
 | 
				
			||||||
		"/pod0-i":  getTestContainerInfo(seedPod0Infra, pName0, namespace0, leaky.PodInfraContainerName),
 | 
							"/pod0-i":  getTestContainerInfo(seedPod0Infra, pName0, namespace0, kubelettypes.PodInfraContainerName),
 | 
				
			||||||
		"/pod0-c0": getTestContainerInfo(seedPod0Container0, pName0, namespace0, cName00),
 | 
							"/pod0-c0": getTestContainerInfo(seedPod0Container0, pName0, namespace0, cName00),
 | 
				
			||||||
		"/pod0-c1": getTestContainerInfo(seedPod0Container1, pName0, namespace0, cName01),
 | 
							"/pod0-c1": getTestContainerInfo(seedPod0Container1, pName0, namespace0, cName01),
 | 
				
			||||||
		// Pod1 - Namespace0
 | 
							// Pod1 - Namespace0
 | 
				
			||||||
		"/pod1-i":  getTestContainerInfo(seedPod1Infra, pName1, namespace0, leaky.PodInfraContainerName),
 | 
							"/pod1-i":  getTestContainerInfo(seedPod1Infra, pName1, namespace0, kubelettypes.PodInfraContainerName),
 | 
				
			||||||
		"/pod1-c0": getTestContainerInfo(seedPod1Container, pName1, namespace0, cName10),
 | 
							"/pod1-c0": getTestContainerInfo(seedPod1Container, pName1, namespace0, cName10),
 | 
				
			||||||
		// Pod2 - Namespace2
 | 
							// Pod2 - Namespace2
 | 
				
			||||||
		"/pod2-i":                        getTestContainerInfo(seedPod2Infra, pName2, namespace2, leaky.PodInfraContainerName),
 | 
							"/pod2-i":                        getTestContainerInfo(seedPod2Infra, pName2, namespace2, kubelettypes.PodInfraContainerName),
 | 
				
			||||||
		"/pod2-c0":                       getTestContainerInfo(seedPod2Container, pName2, namespace2, cName20),
 | 
							"/pod2-c0":                       getTestContainerInfo(seedPod2Container, pName2, namespace2, cName20),
 | 
				
			||||||
		"/kubepods/burstable/podUIDpod0": getTestContainerInfo(seedPod0Infra, pName0, namespace0, leaky.PodInfraContainerName),
 | 
							"/kubepods/burstable/podUIDpod0": getTestContainerInfo(seedPod0Infra, pName0, namespace0, kubelettypes.PodInfraContainerName),
 | 
				
			||||||
		"/kubepods/podUIDpod1":           getTestContainerInfo(seedPod1Infra, pName1, namespace0, leaky.PodInfraContainerName),
 | 
							"/kubepods/podUIDpod1":           getTestContainerInfo(seedPod1Infra, pName1, namespace0, kubelettypes.PodInfraContainerName),
 | 
				
			||||||
		// Pod3 - Namespace0
 | 
							// Pod3 - Namespace0
 | 
				
			||||||
		"/pod3-i":       getTestContainerInfo(seedPod3Infra, pName3, namespace0, leaky.PodInfraContainerName),
 | 
							"/pod3-i":       getTestContainerInfo(seedPod3Infra, pName3, namespace0, kubelettypes.PodInfraContainerName),
 | 
				
			||||||
		"/pod3-c0-init": getTestContainerInfo(seedPod3Container0, pName3, namespace0, cName30),
 | 
							"/pod3-c0-init": getTestContainerInfo(seedPod3Container0, pName3, namespace0, cName30),
 | 
				
			||||||
		"/pod3-c1":      getTestContainerInfo(seedPod3Container1, pName3, namespace0, cName31),
 | 
							"/pod3-c1":      getTestContainerInfo(seedPod3Container1, pName3, namespace0, cName31),
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -401,17 +401,17 @@ func TestCadvisorListPodCPUAndMemoryStats(t *testing.T) {
 | 
				
			|||||||
		"/kubelet":       getTestContainerInfo(seedKubelet, "", "", ""),
 | 
							"/kubelet":       getTestContainerInfo(seedKubelet, "", "", ""),
 | 
				
			||||||
		"/system":        getTestContainerInfo(seedMisc, "", "", ""),
 | 
							"/system":        getTestContainerInfo(seedMisc, "", "", ""),
 | 
				
			||||||
		// Pod0 - Namespace0
 | 
							// Pod0 - Namespace0
 | 
				
			||||||
		"/pod0-i":  getTestContainerInfo(seedPod0Infra, pName0, namespace0, leaky.PodInfraContainerName),
 | 
							"/pod0-i":  getTestContainerInfo(seedPod0Infra, pName0, namespace0, kubelettypes.PodInfraContainerName),
 | 
				
			||||||
		"/pod0-c0": getTestContainerInfo(seedPod0Container0, pName0, namespace0, cName00),
 | 
							"/pod0-c0": getTestContainerInfo(seedPod0Container0, pName0, namespace0, cName00),
 | 
				
			||||||
		"/pod0-c1": getTestContainerInfo(seedPod0Container1, pName0, namespace0, cName01),
 | 
							"/pod0-c1": getTestContainerInfo(seedPod0Container1, pName0, namespace0, cName01),
 | 
				
			||||||
		// Pod1 - Namespace0
 | 
							// Pod1 - Namespace0
 | 
				
			||||||
		"/pod1-i":  getTestContainerInfo(seedPod1Infra, pName1, namespace0, leaky.PodInfraContainerName),
 | 
							"/pod1-i":  getTestContainerInfo(seedPod1Infra, pName1, namespace0, kubelettypes.PodInfraContainerName),
 | 
				
			||||||
		"/pod1-c0": getTestContainerInfo(seedPod1Container, pName1, namespace0, cName10),
 | 
							"/pod1-c0": getTestContainerInfo(seedPod1Container, pName1, namespace0, cName10),
 | 
				
			||||||
		// Pod2 - Namespace2
 | 
							// Pod2 - Namespace2
 | 
				
			||||||
		"/pod2-i":                        getTestContainerInfo(seedPod2Infra, pName2, namespace2, leaky.PodInfraContainerName),
 | 
							"/pod2-i":                        getTestContainerInfo(seedPod2Infra, pName2, namespace2, kubelettypes.PodInfraContainerName),
 | 
				
			||||||
		"/pod2-c0":                       getTestContainerInfo(seedPod2Container, pName2, namespace2, cName20),
 | 
							"/pod2-c0":                       getTestContainerInfo(seedPod2Container, pName2, namespace2, cName20),
 | 
				
			||||||
		"/kubepods/burstable/podUIDpod0": getTestContainerInfo(seedPod0Infra, pName0, namespace0, leaky.PodInfraContainerName),
 | 
							"/kubepods/burstable/podUIDpod0": getTestContainerInfo(seedPod0Infra, pName0, namespace0, kubelettypes.PodInfraContainerName),
 | 
				
			||||||
		"/kubepods/podUIDpod1":           getTestContainerInfo(seedPod1Infra, pName1, namespace0, leaky.PodInfraContainerName),
 | 
							"/kubepods/podUIDpod1":           getTestContainerInfo(seedPod1Infra, pName1, namespace0, kubelettypes.PodInfraContainerName),
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// memory limit overrides for each container (used to test available bytes if a memory limit is known)
 | 
						// memory limit overrides for each container (used to test available bytes if a memory limit is known)
 | 
				
			||||||
@@ -698,7 +698,7 @@ func TestCadvisorListPodStatsWhenContainerLogFound(t *testing.T) {
 | 
				
			|||||||
		"/kubelet":       getTestContainerInfo(seedKubelet, "", "", ""),
 | 
							"/kubelet":       getTestContainerInfo(seedKubelet, "", "", ""),
 | 
				
			||||||
		"/system":        getTestContainerInfo(seedMisc, "", "", ""),
 | 
							"/system":        getTestContainerInfo(seedMisc, "", "", ""),
 | 
				
			||||||
		// Pod0 - Namespace0
 | 
							// Pod0 - Namespace0
 | 
				
			||||||
		"/pod0-i":  getTestContainerInfo(seedPod0Infra, pName0, namespace0, leaky.PodInfraContainerName),
 | 
							"/pod0-i":  getTestContainerInfo(seedPod0Infra, pName0, namespace0, kubelettypes.PodInfraContainerName),
 | 
				
			||||||
		"/pod0-c0": getTestContainerInfo(seedPod0Container0, pName0, namespace0, cName00),
 | 
							"/pod0-c0": getTestContainerInfo(seedPod0Container0, pName0, namespace0, cName00),
 | 
				
			||||||
		"/pod0-c1": getTestContainerInfo(seedPod0Container1, pName0, namespace0, cName01),
 | 
							"/pod0-c1": getTestContainerInfo(seedPod0Container1, pName0, namespace0, cName01),
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -37,11 +37,11 @@ import (
 | 
				
			|||||||
	runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1"
 | 
						runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1"
 | 
				
			||||||
	critest "k8s.io/cri-api/pkg/apis/testing"
 | 
						critest "k8s.io/cri-api/pkg/apis/testing"
 | 
				
			||||||
	statsapi "k8s.io/kubelet/pkg/apis/stats/v1alpha1"
 | 
						statsapi "k8s.io/kubelet/pkg/apis/stats/v1alpha1"
 | 
				
			||||||
 | 
						kubelettypes "k8s.io/kubelet/pkg/types"
 | 
				
			||||||
	cadvisortest "k8s.io/kubernetes/pkg/kubelet/cadvisor/testing"
 | 
						cadvisortest "k8s.io/kubernetes/pkg/kubelet/cadvisor/testing"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/kubelet/cm"
 | 
						"k8s.io/kubernetes/pkg/kubelet/cm"
 | 
				
			||||||
	kubecontainertest "k8s.io/kubernetes/pkg/kubelet/container/testing"
 | 
						kubecontainertest "k8s.io/kubernetes/pkg/kubelet/container/testing"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/kubelet/kuberuntime"
 | 
						"k8s.io/kubernetes/pkg/kubelet/kuberuntime"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/kubelet/leaky"
 | 
					 | 
				
			||||||
	kubepodtest "k8s.io/kubernetes/pkg/kubelet/pod/testing"
 | 
						kubepodtest "k8s.io/kubernetes/pkg/kubelet/pod/testing"
 | 
				
			||||||
	serverstats "k8s.io/kubernetes/pkg/kubelet/server/stats"
 | 
						serverstats "k8s.io/kubernetes/pkg/kubelet/server/stats"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/volume"
 | 
						"k8s.io/kubernetes/pkg/volume"
 | 
				
			||||||
@@ -162,14 +162,14 @@ func TestCRIListPodStats(t *testing.T) {
 | 
				
			|||||||
		"/":                           getTestContainerInfo(seedRoot, "", "", ""),
 | 
							"/":                           getTestContainerInfo(seedRoot, "", "", ""),
 | 
				
			||||||
		"/kubelet":                    getTestContainerInfo(seedKubelet, "", "", ""),
 | 
							"/kubelet":                    getTestContainerInfo(seedKubelet, "", "", ""),
 | 
				
			||||||
		"/system":                     getTestContainerInfo(seedMisc, "", "", ""),
 | 
							"/system":                     getTestContainerInfo(seedMisc, "", "", ""),
 | 
				
			||||||
		sandbox0.PodSandboxStatus.Id:  getTestContainerInfo(seedSandbox0, pName0, sandbox0.PodSandboxStatus.Metadata.Namespace, leaky.PodInfraContainerName),
 | 
							sandbox0.PodSandboxStatus.Id:  getTestContainerInfo(seedSandbox0, pName0, sandbox0.PodSandboxStatus.Metadata.Namespace, kubelettypes.PodInfraContainerName),
 | 
				
			||||||
		sandbox0Cgroup:                getTestContainerInfo(seedSandbox0, "", "", ""),
 | 
							sandbox0Cgroup:                getTestContainerInfo(seedSandbox0, "", "", ""),
 | 
				
			||||||
		container0.ContainerStatus.Id: getTestContainerInfo(seedContainer0, pName0, sandbox0.PodSandboxStatus.Metadata.Namespace, cName0),
 | 
							container0.ContainerStatus.Id: getTestContainerInfo(seedContainer0, pName0, sandbox0.PodSandboxStatus.Metadata.Namespace, cName0),
 | 
				
			||||||
		container1.ContainerStatus.Id: getTestContainerInfo(seedContainer1, pName0, sandbox0.PodSandboxStatus.Metadata.Namespace, cName1),
 | 
							container1.ContainerStatus.Id: getTestContainerInfo(seedContainer1, pName0, sandbox0.PodSandboxStatus.Metadata.Namespace, cName1),
 | 
				
			||||||
		sandbox1.PodSandboxStatus.Id:  getTestContainerInfo(seedSandbox1, pName1, sandbox1.PodSandboxStatus.Metadata.Namespace, leaky.PodInfraContainerName),
 | 
							sandbox1.PodSandboxStatus.Id:  getTestContainerInfo(seedSandbox1, pName1, sandbox1.PodSandboxStatus.Metadata.Namespace, kubelettypes.PodInfraContainerName),
 | 
				
			||||||
		sandbox1Cgroup:                getTestContainerInfo(seedSandbox1, "", "", ""),
 | 
							sandbox1Cgroup:                getTestContainerInfo(seedSandbox1, "", "", ""),
 | 
				
			||||||
		container2.ContainerStatus.Id: getTestContainerInfo(seedContainer2, pName1, sandbox1.PodSandboxStatus.Metadata.Namespace, cName2),
 | 
							container2.ContainerStatus.Id: getTestContainerInfo(seedContainer2, pName1, sandbox1.PodSandboxStatus.Metadata.Namespace, cName2),
 | 
				
			||||||
		sandbox2.PodSandboxStatus.Id:  getTestContainerInfo(seedSandbox2, pName2, sandbox2.PodSandboxStatus.Metadata.Namespace, leaky.PodInfraContainerName),
 | 
							sandbox2.PodSandboxStatus.Id:  getTestContainerInfo(seedSandbox2, pName2, sandbox2.PodSandboxStatus.Metadata.Namespace, kubelettypes.PodInfraContainerName),
 | 
				
			||||||
		sandbox2Cgroup:                getTestContainerInfo(seedSandbox2, "", "", ""),
 | 
							sandbox2Cgroup:                getTestContainerInfo(seedSandbox2, "", "", ""),
 | 
				
			||||||
		container4.ContainerStatus.Id: getTestContainerInfo(seedContainer3, pName2, sandbox2.PodSandboxStatus.Metadata.Namespace, cName3),
 | 
							container4.ContainerStatus.Id: getTestContainerInfo(seedContainer3, pName2, sandbox2.PodSandboxStatus.Metadata.Namespace, cName3),
 | 
				
			||||||
		sandbox3Cgroup:                getTestContainerInfo(seedSandbox3, "", "", ""),
 | 
							sandbox3Cgroup:                getTestContainerInfo(seedSandbox3, "", "", ""),
 | 
				
			||||||
@@ -381,7 +381,7 @@ func TestListPodStatsStrictlyFromCRI(t *testing.T) {
 | 
				
			|||||||
		"/":                           getTestContainerInfo(seedRoot, "", "", ""),
 | 
							"/":                           getTestContainerInfo(seedRoot, "", "", ""),
 | 
				
			||||||
		"/kubelet":                    getTestContainerInfo(seedKubelet, "", "", ""),
 | 
							"/kubelet":                    getTestContainerInfo(seedKubelet, "", "", ""),
 | 
				
			||||||
		"/system":                     getTestContainerInfo(seedMisc, "", "", ""),
 | 
							"/system":                     getTestContainerInfo(seedMisc, "", "", ""),
 | 
				
			||||||
		sandbox0.PodSandboxStatus.Id:  getTestContainerInfo(seedSandbox0, pName0, sandbox0.PodSandboxStatus.Metadata.Namespace, leaky.PodInfraContainerName),
 | 
							sandbox0.PodSandboxStatus.Id:  getTestContainerInfo(seedSandbox0, pName0, sandbox0.PodSandboxStatus.Metadata.Namespace, kubelettypes.PodInfraContainerName),
 | 
				
			||||||
		sandbox0Cgroup:                getTestContainerInfo(seedSandbox0, "", "", ""),
 | 
							sandbox0Cgroup:                getTestContainerInfo(seedSandbox0, "", "", ""),
 | 
				
			||||||
		container0.ContainerStatus.Id: getTestContainerInfo(seedContainer0, pName0, sandbox0.PodSandboxStatus.Metadata.Namespace, cName0),
 | 
							container0.ContainerStatus.Id: getTestContainerInfo(seedContainer0, pName0, sandbox0.PodSandboxStatus.Metadata.Namespace, cName0),
 | 
				
			||||||
		container1.ContainerStatus.Id: getTestContainerInfo(seedContainer1, pName0, sandbox0.PodSandboxStatus.Metadata.Namespace, cName1),
 | 
							container1.ContainerStatus.Id: getTestContainerInfo(seedContainer1, pName0, sandbox0.PodSandboxStatus.Metadata.Namespace, cName1),
 | 
				
			||||||
@@ -593,14 +593,14 @@ func TestCRIListPodCPUAndMemoryStats(t *testing.T) {
 | 
				
			|||||||
		"/":                           getTestContainerInfo(seedRoot, "", "", ""),
 | 
							"/":                           getTestContainerInfo(seedRoot, "", "", ""),
 | 
				
			||||||
		"/kubelet":                    getTestContainerInfo(seedKubelet, "", "", ""),
 | 
							"/kubelet":                    getTestContainerInfo(seedKubelet, "", "", ""),
 | 
				
			||||||
		"/system":                     getTestContainerInfo(seedMisc, "", "", ""),
 | 
							"/system":                     getTestContainerInfo(seedMisc, "", "", ""),
 | 
				
			||||||
		sandbox0.PodSandboxStatus.Id:  getTestContainerInfo(seedSandbox0, pName0, sandbox0.PodSandboxStatus.Metadata.Namespace, leaky.PodInfraContainerName),
 | 
							sandbox0.PodSandboxStatus.Id:  getTestContainerInfo(seedSandbox0, pName0, sandbox0.PodSandboxStatus.Metadata.Namespace, kubelettypes.PodInfraContainerName),
 | 
				
			||||||
		sandbox0Cgroup:                getTestContainerInfo(seedSandbox0, "", "", ""),
 | 
							sandbox0Cgroup:                getTestContainerInfo(seedSandbox0, "", "", ""),
 | 
				
			||||||
		container0.ContainerStatus.Id: getTestContainerInfo(seedContainer0, pName0, sandbox0.PodSandboxStatus.Metadata.Namespace, cName0),
 | 
							container0.ContainerStatus.Id: getTestContainerInfo(seedContainer0, pName0, sandbox0.PodSandboxStatus.Metadata.Namespace, cName0),
 | 
				
			||||||
		container1.ContainerStatus.Id: getTestContainerInfo(seedContainer1, pName0, sandbox0.PodSandboxStatus.Metadata.Namespace, cName1),
 | 
							container1.ContainerStatus.Id: getTestContainerInfo(seedContainer1, pName0, sandbox0.PodSandboxStatus.Metadata.Namespace, cName1),
 | 
				
			||||||
		sandbox1.PodSandboxStatus.Id:  getTestContainerInfo(seedSandbox1, pName1, sandbox1.PodSandboxStatus.Metadata.Namespace, leaky.PodInfraContainerName),
 | 
							sandbox1.PodSandboxStatus.Id:  getTestContainerInfo(seedSandbox1, pName1, sandbox1.PodSandboxStatus.Metadata.Namespace, kubelettypes.PodInfraContainerName),
 | 
				
			||||||
		sandbox1Cgroup:                getTestContainerInfo(seedSandbox1, "", "", ""),
 | 
							sandbox1Cgroup:                getTestContainerInfo(seedSandbox1, "", "", ""),
 | 
				
			||||||
		container2.ContainerStatus.Id: getTestContainerInfo(seedContainer2, pName1, sandbox1.PodSandboxStatus.Metadata.Namespace, cName2),
 | 
							container2.ContainerStatus.Id: getTestContainerInfo(seedContainer2, pName1, sandbox1.PodSandboxStatus.Metadata.Namespace, cName2),
 | 
				
			||||||
		sandbox2.PodSandboxStatus.Id:  getTestContainerInfo(seedSandbox2, pName2, sandbox2.PodSandboxStatus.Metadata.Namespace, leaky.PodInfraContainerName),
 | 
							sandbox2.PodSandboxStatus.Id:  getTestContainerInfo(seedSandbox2, pName2, sandbox2.PodSandboxStatus.Metadata.Namespace, kubelettypes.PodInfraContainerName),
 | 
				
			||||||
		sandbox2Cgroup:                getTestContainerInfo(seedSandbox2, "", "", ""),
 | 
							sandbox2Cgroup:                getTestContainerInfo(seedSandbox2, "", "", ""),
 | 
				
			||||||
		container4.ContainerStatus.Id: getTestContainerInfo(seedContainer3, pName2, sandbox2.PodSandboxStatus.Metadata.Namespace, cName3),
 | 
							container4.ContainerStatus.Id: getTestContainerInfo(seedContainer3, pName2, sandbox2.PodSandboxStatus.Metadata.Namespace, cName3),
 | 
				
			||||||
		sandbox3Cgroup:                getTestContainerInfo(seedSandbox3, "", "", ""),
 | 
							sandbox3Cgroup:                getTestContainerInfo(seedSandbox3, "", "", ""),
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -24,6 +24,13 @@ const (
 | 
				
			|||||||
	KubernetesContainerNameLabel = "io.kubernetes.container.name"
 | 
						KubernetesContainerNameLabel = "io.kubernetes.container.name"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Label value constants
 | 
				
			||||||
 | 
					const (
 | 
				
			||||||
 | 
						// PodInfraContainerName is the KubernetesPodNameLabel value for infra
 | 
				
			||||||
 | 
						// containers.
 | 
				
			||||||
 | 
						PodInfraContainerName = "POD"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// GetContainerName returns the value of the KubernetesContainerNameLabel.
 | 
					// GetContainerName returns the value of the KubernetesContainerNameLabel.
 | 
				
			||||||
func GetContainerName(labels map[string]string) string {
 | 
					func GetContainerName(labels map[string]string) string {
 | 
				
			||||||
	return labels[KubernetesContainerNameLabel]
 | 
						return labels[KubernetesContainerNameLabel]
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user