diff --git a/contrib/mesos/pkg/scheduler/meta/annotations.go b/contrib/mesos/pkg/scheduler/meta/annotations.go index 60a1d28f9ef..85f1745a8c5 100644 --- a/contrib/mesos/pkg/scheduler/meta/annotations.go +++ b/contrib/mesos/pkg/scheduler/meta/annotations.go @@ -34,4 +34,5 @@ const ( PortNameMappingKeyFormat = PortNameMappingKeyPrefix + "%s_%s" ContainerPortKeyFormat = "k8s.mesosphere.io/containerPort_%s_%s_%d" StaticPodFilenameKey = "k8s.mesosphere.io/staticPodFilename" + RolesKey = "k8s.mesosphere.io/roles" ) diff --git a/contrib/mesos/pkg/scheduler/meta/labels.go b/contrib/mesos/pkg/scheduler/meta/labels.go deleted file mode 100644 index 8353b4153eb..00000000000 --- a/contrib/mesos/pkg/scheduler/meta/labels.go +++ /dev/null @@ -1,22 +0,0 @@ -/* -Copyright 2015 The Kubernetes Authors All rights reserved. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package meta - -// kubernetes api object labels -const ( - RolesKey = "k8s.mesosphere.io/roles" -) diff --git a/contrib/mesos/pkg/scheduler/podtask/pod_task.go b/contrib/mesos/pkg/scheduler/podtask/pod_task.go index 30740fed6c4..05b0bbf5b64 100644 --- a/contrib/mesos/pkg/scheduler/podtask/pod_task.go +++ b/contrib/mesos/pkg/scheduler/podtask/pod_task.go @@ -170,10 +170,10 @@ func (t *T) Has(f FlagType) (exists bool) { } // Roles returns the valid roles under which this pod task can be scheduled. -// If the pod has roles labels defined they are being used +// If the pod has roles annotations defined they are being used // else default pod roles are being returned. -func (t *T) Roles() []string { - if r, ok := t.Pod.ObjectMeta.Labels[annotation.RolesKey]; ok { +func (t *T) Roles() (result []string) { + if r, ok := t.Pod.ObjectMeta.Annotations[annotation.RolesKey]; ok { roles := strings.Split(r, ",") for i, r := range roles { diff --git a/contrib/mesos/pkg/scheduler/podtask/pod_task_test.go b/contrib/mesos/pkg/scheduler/podtask/pod_task_test.go index 92671736240..ba15499cbfd 100644 --- a/contrib/mesos/pkg/scheduler/podtask/pod_task_test.go +++ b/contrib/mesos/pkg/scheduler/podtask/pod_task_test.go @@ -56,7 +56,7 @@ func TestRoles(t *testing.T) { assert := assert.New(t) for i, tt := range []struct { - labels map[string]string + annotations map[string]string frameworkRoles []string want []string }{ @@ -105,7 +105,7 @@ func TestRoles(t *testing.T) { }, } { task := fakePodTask("test", tt.frameworkRoles, starRole) - task.Pod.ObjectMeta.Labels = tt.labels + task.Pod.ObjectMeta.Annotations = tt.annotations assert.True(reflect.DeepEqual(task.Roles(), tt.want), "test #%d got %#v want %#v", i, task.Roles(), tt.want) } } diff --git a/test/e2e/mesos.go b/test/e2e/mesos.go index f2b97096d4d..6843ce0c8b0 100644 --- a/test/e2e/mesos.go +++ b/test/e2e/mesos.go @@ -73,7 +73,7 @@ var _ = Describe("Mesos", func() { fmt.Sprintf("number of static pods in namespace %s is %d", ns, numpods)) }) - It("schedules pods labelled with roles on correct slaves", func() { + It("schedules pods annotated with roles on correct slaves", func() { // launch a pod to find a node which can launch a pod. We intentionally do // not just take the node list and choose the first of them. Depending on the // cluster and the scheduler it might be that a "normal" pod cannot be @@ -86,7 +86,7 @@ var _ = Describe("Mesos", func() { }, ObjectMeta: api.ObjectMeta{ Name: podName, - Labels: map[string]string{ + Annotations: map[string]string{ "k8s.mesosphere.io/roles": "public", }, },