Merge pull request #79591 from tedyu/ctrl-util-label

Simplify the check of presence of labels in createPods
This commit is contained in:
Kubernetes Prow Robot 2019-07-01 01:45:19 -07:00 committed by GitHub
commit d48f123a40
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -573,7 +573,7 @@ func (r RealPodControl) createPods(nodeName, namespace string, template *v1.PodT
if len(nodeName) != 0 {
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")
}
newPod, err := r.KubeClient.CoreV1().Pods(namespace).Create(pod)