mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-12 05:21:58 +00:00
Merge pull request #5995 from ArtfulCoder/pause_no_port_forward_for_net_host
Kill running Pod running with -net=true if kubelet does not allow it
This commit is contained in:
commit
106cc037ee
@ -1326,11 +1326,22 @@ func (kl *Kubelet) canRunPod(pod *api.Pod) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (kl *Kubelet) killContainersInRunningPod(runningPod kubecontainer.Pod) {
|
||||||
|
for _, container := range runningPod.Containers {
|
||||||
|
glog.V(3).Infof("Killing unwanted container %+v", container)
|
||||||
|
err := kl.killContainer(container)
|
||||||
|
if err != nil {
|
||||||
|
glog.Errorf("Error killing container: %v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (kl *Kubelet) syncPod(pod *api.Pod, mirrorPod *api.Pod, runningPod kubecontainer.Pod) error {
|
func (kl *Kubelet) syncPod(pod *api.Pod, mirrorPod *api.Pod, runningPod kubecontainer.Pod) error {
|
||||||
podFullName := kubecontainer.GetPodFullName(pod)
|
podFullName := kubecontainer.GetPodFullName(pod)
|
||||||
uid := pod.UID
|
uid := pod.UID
|
||||||
err := kl.canRunPod(pod)
|
err := kl.canRunPod(pod)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
kl.killContainersInRunningPod(runningPod)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user