Simplify the check of presence of labels in createPods

This commit is contained in:
Ted Yu 2019-07-01 15:32:26 +08:00 committed by Ted Yu
parent 6a2d0f67d1
commit 69aeabc397

View File

@ -573,7 +573,7 @@ func (r RealPodControl) createPods(nodeName, namespace string, template *v1.PodT
if len(nodeName) != 0 { if len(nodeName) != 0 {
pod.Spec.NodeName = nodeName pod.Spec.NodeName = nodeName
} }
if labels.Set(pod.Labels).AsSelectorPreValidated().Empty() { if len(labels.Set(pod.Labels)) == 0 {
return fmt.Errorf("unable to create pods, no labels") return fmt.Errorf("unable to create pods, no labels")
} }
newPod, err := r.KubeClient.CoreV1().Pods(namespace).Create(pod) newPod, err := r.KubeClient.CoreV1().Pods(namespace).Create(pod)