Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 1.2 cherrypick batch 16/3 morning #23051

Merged
merged 2 commits into from
Mar 16, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 2 additions & 5 deletions cluster/addons/cluster-monitoring/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
# Kubernetes Monitoring

[Heapster](https://github.com/GoogleCloudPlatform/heapster) enables monitoring and performance analysis in Kubernetes Clusters.
[Heapster](https://github.com/kubernetes/heapster) enables monitoring and performance analysis in Kubernetes Clusters.
Heapster collects signals from kubelets and the api server, processes them, and exports them via REST APIs or to a configurable timeseries storage backend.

Use [Kubedash](https://github.com/kubernetes/kubedash) to visualize Heapster metrics. </br>

*Note: Kubedash is an experimental feature*

More details can be found in [Monitoring user guide](http://kubernetes.io/docs/user-guide/monitoring/).

[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/cluster/addons/cluster-monitoring/README.md?pixel)]()
9 changes: 8 additions & 1 deletion pkg/apis/extensions/v1beta1/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down
110 changes: 89 additions & 21 deletions pkg/apis/extensions/v1beta1/defaults_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -374,45 +374,107 @@ func TestSetDefaultJobParallelismAndCompletions(t *testing.T) {
}

func TestSetDefaultJobSelector(t *testing.T) {
expected := &Job{
Spec: JobSpec{
Selector: &LabelSelector{
tests := []struct {
original *Job
expectedSelector *LabelSelector
}{
// selector set explicitly, nil autoSelector
{
original: &Job{
Spec: JobSpec{
Selector: &LabelSelector{
MatchLabels: map[string]string{"job": "selector"},
},
},
},
expectedSelector: &LabelSelector{
MatchLabels: map[string]string{"job": "selector"},
},
Completions: newInt32(1),
Parallelism: newInt32(1),
},
}
tests := []*Job{
// selector set explicitly, completions and parallelism - default
// selector set explicitly, autoSelector=true
{
Spec: JobSpec{
Selector: &LabelSelector{
MatchLabels: map[string]string{"job": "selector"},
original: &Job{
Spec: JobSpec{
Selector: &LabelSelector{
MatchLabels: map[string]string{"job": "selector"},
},
AutoSelector: newBool(true),
},
},
expectedSelector: &LabelSelector{
MatchLabels: map[string]string{"job": "selector"},
},
},
// selector from template labels, completions and parallelism - default
// selector set explicitly, autoSelector=false
{
Spec: JobSpec{
Template: v1.PodTemplateSpec{
ObjectMeta: v1.ObjectMeta{
Labels: map[string]string{"job": "selector"},
original: &Job{
Spec: JobSpec{
Selector: &LabelSelector{
MatchLabels: map[string]string{"job": "selector"},
},
AutoSelector: newBool(false),
},
},
expectedSelector: &LabelSelector{
MatchLabels: map[string]string{"job": "selector"},
},
},
// selector from template labels
{
original: &Job{
Spec: JobSpec{
Template: v1.PodTemplateSpec{
ObjectMeta: v1.ObjectMeta{
Labels: map[string]string{"job": "selector"},
},
},
},
},
expectedSelector: &LabelSelector{
MatchLabels: map[string]string{"job": "selector"},
},
},
// selector from template labels, autoSelector=false
{
original: &Job{
Spec: JobSpec{
Template: v1.PodTemplateSpec{
ObjectMeta: v1.ObjectMeta{
Labels: map[string]string{"job": "selector"},
},
},
AutoSelector: newBool(false),
},
},
expectedSelector: &LabelSelector{
MatchLabels: map[string]string{"job": "selector"},
},
},
// selector not copied from template labels, autoSelector=true
{
original: &Job{
Spec: JobSpec{
Template: v1.PodTemplateSpec{
ObjectMeta: v1.ObjectMeta{
Labels: map[string]string{"job": "selector"},
},
},
AutoSelector: newBool(true),
},
},
expectedSelector: nil,
},
}

for _, original := range tests {
obj2 := roundTrip(t, runtime.Object(original))
for i, testcase := range tests {
obj2 := roundTrip(t, runtime.Object(testcase.original))
got, ok := obj2.(*Job)
if !ok {
t.Errorf("unexpected object: %v", got)
t.Errorf("%d: unexpected object: %v", i, got)
t.FailNow()
}
if !reflect.DeepEqual(got.Spec.Selector, expected.Spec.Selector) {
t.Errorf("got different selectors %#v %#v", got.Spec.Selector, expected.Spec.Selector)
if !reflect.DeepEqual(got.Spec.Selector, testcase.expectedSelector) {
t.Errorf("%d: got different selectors %#v %#v", i, got.Spec.Selector, testcase.expectedSelector)
}
}
}
Expand Down Expand Up @@ -661,3 +723,9 @@ func newString(val string) *string {
*p = val
return p
}

func newBool(val bool) *bool {
b := new(bool)
*b = val
return b
}
4 changes: 2 additions & 2 deletions pkg/apis/extensions/validation/validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -980,7 +980,7 @@ func TestValidateJob(t *testing.T) {
MatchLabels: map[string]string{"a": "b"},
}
validGeneratedSelector := &unversioned.LabelSelector{
MatchLabels: map[string]string{"collection-uid": "1a2b3c"},
MatchLabels: map[string]string{"controller-uid": "1a2b3c", "job-name": "myjob"},
}
validPodTemplateSpecForManual := api.PodTemplateSpec{
ObjectMeta: api.ObjectMeta{
Expand Down Expand Up @@ -1023,7 +1023,7 @@ func TestValidateJob(t *testing.T) {
},
Spec: extensions.JobSpec{
Selector: validGeneratedSelector,
ManualSelector: newBool(true),
ManualSelector: newBool(false),
Template: validPodTemplateSpecForGenerated,
},
},
Expand Down