Warn if pod has no labels

This commit is contained in:
Clayton Coleman
2014-11-06 17:53:28 -05:00
parent d97f6cd0d8
commit 8a59000472
2 changed files with 6 additions and 2 deletions

View File

@@ -89,7 +89,7 @@ func (c *testClient) Validate(t *testing.T, received runtime.Object, err error)
c.ValidateCommon(t, err) c.ValidateCommon(t, err)
if c.Response.Body != nil && !reflect.DeepEqual(c.Response.Body, received) { if c.Response.Body != nil && !reflect.DeepEqual(c.Response.Body, received) {
t.Errorf("bad response for request %#v: expected %s, got %s", c.Request, c.Response.Body, received) t.Errorf("bad response for request %#v: expected %#v, got %#v", c.Request, c.Response.Body, received)
} }
} }
@@ -97,7 +97,7 @@ func (c *testClient) ValidateRaw(t *testing.T, received []byte, err error) {
c.ValidateCommon(t, err) c.ValidateCommon(t, err)
if c.Response.Body != nil && !reflect.DeepEqual(c.Response.Body, received) { if c.Response.Body != nil && !reflect.DeepEqual(c.Response.Body, received) {
t.Errorf("bad response for request %#v: expected %s, got %s", c.Request, c.Response.Body, received) t.Errorf("bad response for request %#v: expected %#v, got %#v", c.Request, c.Response.Body, received)
} }
} }

View File

@@ -66,6 +66,10 @@ func (r RealPodControl) createReplica(namespace string, controller api.Replicati
glog.Errorf("Unable to convert pod template: %v", err) glog.Errorf("Unable to convert pod template: %v", err)
return return
} }
if labels.Set(pod.Labels).AsSelector().Empty() {
glog.Errorf("Unable to create pod replica, no labels")
return
}
if _, err := r.kubeClient.Pods(namespace).Create(pod); err != nil { if _, err := r.kubeClient.Pods(namespace).Create(pod); err != nil {
glog.Errorf("Unable to create pod replica: %v", err) glog.Errorf("Unable to create pod replica: %v", err)
} }