mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-03 19:58:17 +00:00 
			
		
		
		
	optimize killPod() and syncPod() functions
make sure that one of the two arguments must be non-nil: runningPod, status ,just like the function note says and judge the return value in syncPod() function before setting podKilled
This commit is contained in:
		@@ -1463,9 +1463,10 @@ func (kl *Kubelet) syncPod(o syncPodOptions) error {
 | 
				
			|||||||
		// exists or the pod is running for the first time
 | 
							// exists or the pod is running for the first time
 | 
				
			||||||
		podKilled := false
 | 
							podKilled := false
 | 
				
			||||||
		if !pcm.Exists(pod) && !firstSync {
 | 
							if !pcm.Exists(pod) && !firstSync {
 | 
				
			||||||
			kl.killPod(pod, nil, podStatus, nil)
 | 
								if err := kl.killPod(pod, nil, podStatus, nil); err == nil {
 | 
				
			||||||
				podKilled = true
 | 
									podKilled = true
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
		// Create and Update pod's Cgroups
 | 
							// Create and Update pod's Cgroups
 | 
				
			||||||
		// Don't create cgroups for run once pod if it was killed above
 | 
							// Don't create cgroups for run once pod if it was killed above
 | 
				
			||||||
		// The current policy is not to restart the run once pods when
 | 
							// The current policy is not to restart the run once pods when
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -645,6 +645,8 @@ func (kl *Kubelet) killPod(pod *v1.Pod, runningPod *kubecontainer.Pod, status *k
 | 
				
			|||||||
		p = *runningPod
 | 
							p = *runningPod
 | 
				
			||||||
	} else if status != nil {
 | 
						} else if status != nil {
 | 
				
			||||||
		p = kubecontainer.ConvertPodStatusToRunningPod(kl.GetRuntime().Type(), status)
 | 
							p = kubecontainer.ConvertPodStatusToRunningPod(kl.GetRuntime().Type(), status)
 | 
				
			||||||
 | 
						} else {
 | 
				
			||||||
 | 
							return fmt.Errorf("one of the two arguments must be non-nil: runningPod, status")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// cache the pod cgroup Name for reducing the cpu resource limits of the pod cgroup once the pod is killed
 | 
						// cache the pod cgroup Name for reducing the cpu resource limits of the pod cgroup once the pod is killed
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user