Avoid populating job selector from pod template labels in autoSelector case

This commit is contained in:
Jordan Liggitt
2016-03-16 02:23:01 -04:00
parent 49092c0b99
commit 64f51723c8
3 changed files with 106 additions and 31 deletions

View File

@@ -86,7 +86,14 @@ func addDefaultingFuncs(scheme *runtime.Scheme) {
labels := obj.Spec.Template.Labels
// TODO: support templates defined elsewhere when we support them in the API
if labels != nil {
if obj.Spec.Selector == nil {
// if an autoselector is requested, we'll build the selector later with controller-uid and job-name
autoSelector := bool(obj.Spec.AutoSelector != nil && *obj.Spec.AutoSelector)
// otherwise, we are using a manual selector
manualSelector := !autoSelector
// and default behavior for an unspecified manual selector is to use the pod template labels
if manualSelector && obj.Spec.Selector == nil {
obj.Spec.Selector = &LabelSelector{
MatchLabels: labels,
}