Update pod_container_manager_linux.go (#114598)

* Update pod_container_manager_linux.go

This is a simple optimization to reduce repeated invoking of the GetPodContainerName function.

* Update pod_container_manager_linux.go

将podContainerName, _ := m.GetPodContainerName(pod)更靠近使用podcontainerName变量的位置
This commit is contained in:
kunkunhaohao 2023-03-15 00:38:36 +08:00 committed by GitHub
parent f769c66aa8
commit a772691165
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -70,7 +70,6 @@ func (m *podContainerManagerImpl) Exists(pod *v1.Pod) bool {
// pod cgroup exists if qos cgroup hierarchy flag is enabled.
// If the pod level container doesn't already exist it is created.
func (m *podContainerManagerImpl) EnsureExists(pod *v1.Pod) error {
podContainerName, _ := m.GetPodContainerName(pod)
// check if container already exist
alreadyExists := m.Exists(pod)
if !alreadyExists {
@ -80,6 +79,7 @@ func (m *podContainerManagerImpl) EnsureExists(pod *v1.Pod) error {
enforceMemoryQoS = true
}
// Create the pod container
podContainerName, _ := m.GetPodContainerName(pod)
containerConfig := &CgroupConfig{
Name: podContainerName,
ResourceParameters: ResourceConfigForPod(pod, m.enforceCPULimits, m.cpuCFSQuotaPeriod, enforceMemoryQoS),