Rename ID -> Name

This commit is contained in:
Clayton Coleman
2014-10-22 13:02:02 -04:00
parent bdebff5b28
commit bb77a5d15f
107 changed files with 777 additions and 777 deletions

View File

@@ -111,15 +111,15 @@ func TestPodUpdate(c *client.Client) bool {
glog.Errorf("Failed to create pod: %v", err) glog.Errorf("Failed to create pod: %v", err)
return false return false
} }
defer c.DeletePod(ctx, pod.ID) defer c.DeletePod(ctx, pod.Name)
waitForPodRunning(c, pod.ID) waitForPodRunning(c, pod.Name)
pods, err := c.ListPods(ctx, labels.SelectorFromSet(labels.Set(map[string]string{"time": value}))) pods, err := c.ListPods(ctx, labels.SelectorFromSet(labels.Set(map[string]string{"time": value})))
if len(pods.Items) != 1 { if len(pods.Items) != 1 {
glog.Errorf("Failed to find the correct pod") glog.Errorf("Failed to find the correct pod")
return false return false
} }
podOut, err := c.GetPod(ctx, pod.ID) podOut, err := c.GetPod(ctx, pod.Name)
if err != nil { if err != nil {
glog.Errorf("Failed to get pod: %v", err) glog.Errorf("Failed to get pod: %v", err)
return false return false
@@ -133,7 +133,7 @@ func TestPodUpdate(c *client.Client) bool {
glog.Errorf("Failed to update pod: %v", err) glog.Errorf("Failed to update pod: %v", err)
return false return false
} }
waitForPodRunning(c, pod.ID) waitForPodRunning(c, pod.Name)
pods, err = c.ListPods(ctx, labels.SelectorFromSet(labels.Set(map[string]string{"time": value}))) pods, err = c.ListPods(ctx, labels.SelectorFromSet(labels.Set(map[string]string{"time": value})))
if len(pods.Items) != 1 { if len(pods.Items) != 1 {
glog.Errorf("Failed to find the correct pod after update.") glog.Errorf("Failed to find the correct pod after update.")

View File

@@ -184,7 +184,7 @@ func podsOnMinions(c *client.Client, pods api.PodList) wait.ConditionFunc {
podInfo := fakePodInfoGetter{} podInfo := fakePodInfoGetter{}
return func() (bool, error) { return func() (bool, error) {
for i := range pods.Items { for i := range pods.Items {
host, id, namespace := pods.Items[i].CurrentState.Host, pods.Items[i].ID, pods.Items[i].Namespace host, id, namespace := pods.Items[i].CurrentState.Host, pods.Items[i].Name, pods.Items[i].Namespace
if len(host) == 0 { if len(host) == 0 {
return false, nil return false, nil
} }
@@ -251,7 +251,7 @@ func runAtomicPutTest(c *client.Client) {
var svc api.Service var svc api.Service
err := c.Post().Path("services").Body( err := c.Post().Path("services").Body(
&api.Service{ &api.Service{
TypeMeta: api.TypeMeta{ID: "atomicservice", APIVersion: latest.Version}, TypeMeta: api.TypeMeta{Name: "atomicservice", APIVersion: latest.Version},
Port: 12345, Port: 12345,
Labels: map[string]string{ Labels: map[string]string{
"name": "atomicService", "name": "atomicService",
@@ -282,7 +282,7 @@ func runAtomicPutTest(c *client.Client) {
var tmpSvc api.Service var tmpSvc api.Service
err := c.Get(). err := c.Get().
Path("services"). Path("services").
Path(svc.ID). Path(svc.Name).
PollPeriod(100 * time.Millisecond). PollPeriod(100 * time.Millisecond).
Do(). Do().
Into(&tmpSvc) Into(&tmpSvc)
@@ -296,7 +296,7 @@ func runAtomicPutTest(c *client.Client) {
tmpSvc.Selector[l] = v tmpSvc.Selector[l] = v
} }
glog.Infof("Posting update (%s, %s)", l, v) glog.Infof("Posting update (%s, %s)", l, v)
err = c.Put().Path("services").Path(svc.ID).Body(&tmpSvc).Do().Error() err = c.Put().Path("services").Path(svc.Name).Body(&tmpSvc).Do().Error()
if err != nil { if err != nil {
if errors.IsConflict(err) { if errors.IsConflict(err) {
glog.Infof("Conflict: (%s, %s)", l, v) glog.Infof("Conflict: (%s, %s)", l, v)
@@ -313,7 +313,7 @@ func runAtomicPutTest(c *client.Client) {
}(label, value) }(label, value)
} }
wg.Wait() wg.Wait()
if err := c.Get().Path("services").Path(svc.ID).Do().Into(&svc); err != nil { if err := c.Get().Path("services").Path(svc.Name).Do().Into(&svc); err != nil {
glog.Fatalf("Failed getting atomicService after writers are complete: %v", err) glog.Fatalf("Failed getting atomicService after writers are complete: %v", err)
} }
if !reflect.DeepEqual(testLabels, labels.Set(svc.Selector)) { if !reflect.DeepEqual(testLabels, labels.Set(svc.Selector)) {
@@ -325,7 +325,7 @@ func runAtomicPutTest(c *client.Client) {
func runServiceTest(client *client.Client) { func runServiceTest(client *client.Client) {
ctx := api.NewDefaultContext() ctx := api.NewDefaultContext()
pod := api.Pod{ pod := api.Pod{
TypeMeta: api.TypeMeta{ID: "foo"}, TypeMeta: api.TypeMeta{Name: "foo"},
DesiredState: api.PodState{ DesiredState: api.PodState{
Manifest: api.ContainerManifest{ Manifest: api.ContainerManifest{
Version: "v1beta1", Version: "v1beta1",
@@ -351,11 +351,11 @@ func runServiceTest(client *client.Client) {
if err != nil { if err != nil {
glog.Fatalf("Failed to create pod: %v, %v", pod, err) glog.Fatalf("Failed to create pod: %v, %v", pod, err)
} }
if err := wait.Poll(time.Second, time.Second*20, podExists(client, ctx, pod.ID)); err != nil { if err := wait.Poll(time.Second, time.Second*20, podExists(client, ctx, pod.Name)); err != nil {
glog.Fatalf("FAILED: pod never started running %v", err) glog.Fatalf("FAILED: pod never started running %v", err)
} }
svc1 := api.Service{ svc1 := api.Service{
TypeMeta: api.TypeMeta{ID: "service1"}, TypeMeta: api.TypeMeta{Name: "service1"},
Selector: map[string]string{ Selector: map[string]string{
"name": "thisisalonglabel", "name": "thisisalonglabel",
}, },
@@ -365,12 +365,12 @@ func runServiceTest(client *client.Client) {
if err != nil { if err != nil {
glog.Fatalf("Failed to create service: %v, %v", svc1, err) glog.Fatalf("Failed to create service: %v, %v", svc1, err)
} }
if err := wait.Poll(time.Second, time.Second*20, endpointsSet(client, ctx, svc1.ID, 1)); err != nil { if err := wait.Poll(time.Second, time.Second*20, endpointsSet(client, ctx, svc1.Name, 1)); err != nil {
glog.Fatalf("FAILED: unexpected endpoints: %v", err) glog.Fatalf("FAILED: unexpected endpoints: %v", err)
} }
// A second service with the same port. // A second service with the same port.
svc2 := api.Service{ svc2 := api.Service{
TypeMeta: api.TypeMeta{ID: "service2"}, TypeMeta: api.TypeMeta{Name: "service2"},
Selector: map[string]string{ Selector: map[string]string{
"name": "thisisalonglabel", "name": "thisisalonglabel",
}, },
@@ -380,7 +380,7 @@ func runServiceTest(client *client.Client) {
if err != nil { if err != nil {
glog.Fatalf("Failed to create service: %v, %v", svc2, err) glog.Fatalf("Failed to create service: %v, %v", svc2, err)
} }
if err := wait.Poll(time.Second, time.Second*20, endpointsSet(client, ctx, svc2.ID, 1)); err != nil { if err := wait.Poll(time.Second, time.Second*20, endpointsSet(client, ctx, svc2.Name, 1)); err != nil {
glog.Fatalf("FAILED: unexpected endpoints: %v", err) glog.Fatalf("FAILED: unexpected endpoints: %v", err)
} }
glog.Info("Service test passed.") glog.Info("Service test passed.")

View File

@@ -32,7 +32,7 @@ func init() {
out.Spec.Containers = in.Containers out.Spec.Containers = in.Containers
out.Spec.Volumes = in.Volumes out.Spec.Volumes = in.Volumes
out.Spec.RestartPolicy = in.RestartPolicy out.Spec.RestartPolicy = in.RestartPolicy
out.ID = in.ID out.Name = in.ID
out.UID = in.UUID out.UID = in.UUID
return nil return nil
}, },
@@ -41,7 +41,7 @@ func init() {
out.Volumes = in.Spec.Volumes out.Volumes = in.Spec.Volumes
out.RestartPolicy = in.Spec.RestartPolicy out.RestartPolicy = in.Spec.RestartPolicy
out.Version = "v1beta2" out.Version = "v1beta2"
out.ID = in.ID out.ID = in.Name
out.UUID = in.UID out.UUID = in.UID
return nil return nil
}, },
@@ -71,7 +71,7 @@ func init() {
// Only copy a subset of fields, and override manifest attributes with the pod // Only copy a subset of fields, and override manifest attributes with the pod
// metadata // metadata
out.UID = in.UID out.UID = in.UID
out.ID = in.ID out.Name = in.Name
out.Namespace = in.Namespace out.Namespace = in.Namespace
out.CreationTimestamp = in.CreationTimestamp out.CreationTimestamp = in.CreationTimestamp
return nil return nil

View File

@@ -37,7 +37,7 @@ var apiObjectFuzzer = fuzz.New().NilChance(.5).NumElements(1, 1).Funcs(
// APIVersion and Kind must remain blank in memory. // APIVersion and Kind must remain blank in memory.
j.APIVersion = "" j.APIVersion = ""
j.Kind = "" j.Kind = ""
j.ID = c.RandString() j.Name = c.RandString()
// TODO: Fix JSON/YAML packages and/or write custom encoding // TODO: Fix JSON/YAML packages and/or write custom encoding
// for uint64's. Somehow the LS *byte* of this is lost, but // for uint64's. Somehow the LS *byte* of this is lost, but
// only when all 8 bytes are set. // only when all 8 bytes are set.

View File

@@ -36,7 +36,7 @@ func TestGetReference(t *testing.T) {
"pod": { "pod": {
obj: &Pod{ obj: &Pod{
TypeMeta: TypeMeta{ TypeMeta: TypeMeta{
ID: "foo", Name: "foo",
ResourceVersion: "42", ResourceVersion: "42",
SelfLink: "/api/v1beta1/pods/foo", SelfLink: "/api/v1beta1/pods/foo",
}, },
@@ -52,7 +52,7 @@ func TestGetReference(t *testing.T) {
"serviceList": { "serviceList": {
obj: &ServiceList{ obj: &ServiceList{
TypeMeta: TypeMeta{ TypeMeta: TypeMeta{
ID: "foo", Name: "foo",
ResourceVersion: "42", ResourceVersion: "42",
SelfLink: "/api/v1beta2/services", SelfLink: "/api/v1beta2/services",
}, },
@@ -68,7 +68,7 @@ func TestGetReference(t *testing.T) {
"badSelfLink": { "badSelfLink": {
obj: &ServiceList{ obj: &ServiceList{
TypeMeta: TypeMeta{ TypeMeta: TypeMeta{
ID: "foo", Name: "foo",
ResourceVersion: "42", ResourceVersion: "42",
SelfLink: "v1beta2/services", SelfLink: "v1beta2/services",
}, },

View File

@@ -46,7 +46,7 @@ var apiObjectFuzzer = fuzz.New().NilChance(.5).NumElements(1, 1).Funcs(
// APIVersion and Kind must remain blank in memory. // APIVersion and Kind must remain blank in memory.
j.APIVersion = "" j.APIVersion = ""
j.Kind = "" j.Kind = ""
j.ID = c.RandString() j.Name = c.RandString()
// TODO: Fix JSON/YAML packages and/or write custom encoding // TODO: Fix JSON/YAML packages and/or write custom encoding
// for uint64's. Somehow the LS *byte* of this is lost, but // for uint64's. Somehow the LS *byte* of this is lost, but
// only when all 8 bytes are set. // only when all 8 bytes are set.
@@ -63,7 +63,7 @@ var apiObjectFuzzer = fuzz.New().NilChance(.5).NumElements(1, 1).Funcs(
// APIVersion and Kind must remain blank in memory. // APIVersion and Kind must remain blank in memory.
j.APIVersion = "" j.APIVersion = ""
j.Kind = "" j.Kind = ""
j.ID = c.RandString() j.Name = c.RandString()
// TODO: Fix JSON/YAML packages and/or write custom encoding // TODO: Fix JSON/YAML packages and/or write custom encoding
// for uint64's. Somehow the LS *byte* of this is lost, but // for uint64's. Somehow the LS *byte* of this is lost, but
// only when all 8 bytes are set. // only when all 8 bytes are set.

View File

@@ -245,7 +245,7 @@ type Lifecycle struct {
// TypeMeta is shared by all objects sent to, or returned from the client. // TypeMeta is shared by all objects sent to, or returned from the client.
type TypeMeta struct { type TypeMeta struct {
Kind string `json:"kind,omitempty" yaml:"kind,omitempty"` Kind string `json:"kind,omitempty" yaml:"kind,omitempty"`
ID string `json:"id,omitempty" yaml:"id,omitempty"` Name string `json:"name,omitempty" yaml:"name,omitempty"`
CreationTimestamp util.Time `json:"creationTimestamp,omitempty" yaml:"creationTimestamp,omitempty"` CreationTimestamp util.Time `json:"creationTimestamp,omitempty" yaml:"creationTimestamp,omitempty"`
SelfLink string `json:"selfLink,omitempty" yaml:"selfLink,omitempty"` SelfLink string `json:"selfLink,omitempty" yaml:"selfLink,omitempty"`
ResourceVersion string `json:"resourceVersion,omitempty" yaml:"resourceVersion,omitempty"` ResourceVersion string `json:"resourceVersion,omitempty" yaml:"resourceVersion,omitempty"`
@@ -458,7 +458,7 @@ type ResourceName string
type ResourceList map[ResourceName]util.IntOrString type ResourceList map[ResourceName]util.IntOrString
// Minion is a worker node in Kubernetenes. // Minion is a worker node in Kubernetenes.
// The name of the minion according to etcd is in TypeMeta.ID. // The name of the minion according to etcd is in ID.
type Minion struct { type Minion struct {
TypeMeta `json:",inline" yaml:",inline"` TypeMeta `json:",inline" yaml:",inline"`
// Queried from cloud provider, if available. // Queried from cloud provider, if available.

View File

@@ -30,7 +30,7 @@ func init() {
out.APIVersion = in.APIVersion out.APIVersion = in.APIVersion
out.Kind = in.Kind out.Kind = in.Kind
out.Namespace = in.Namespace out.Namespace = in.Namespace
out.ID = in.ID out.ID = in.Name
out.CreationTimestamp = in.CreationTimestamp out.CreationTimestamp = in.CreationTimestamp
out.SelfLink = in.SelfLink out.SelfLink = in.SelfLink
out.Annotations = in.Annotations out.Annotations = in.Annotations
@@ -48,7 +48,7 @@ func init() {
out.APIVersion = in.APIVersion out.APIVersion = in.APIVersion
out.Kind = in.Kind out.Kind = in.Kind
out.Namespace = in.Namespace out.Namespace = in.Namespace
out.ID = in.ID out.Name = in.ID
out.CreationTimestamp = in.CreationTimestamp out.CreationTimestamp = in.CreationTimestamp
out.SelfLink = in.SelfLink out.SelfLink = in.SelfLink
out.Annotations = in.Annotations out.Annotations = in.Annotations

View File

@@ -119,7 +119,7 @@ func TestMinionListConversionToNew(t *testing.T) {
return v1beta1.Minion{TypeMeta: v1beta1.TypeMeta{ID: id}} return v1beta1.Minion{TypeMeta: v1beta1.TypeMeta{ID: id}}
} }
newMinion := func(id string) newer.Minion { newMinion := func(id string) newer.Minion {
return newer.Minion{TypeMeta: newer.TypeMeta{ID: id}} return newer.Minion{TypeMeta: newer.TypeMeta{Name: id}}
} }
oldMinions := []v1beta1.Minion{ oldMinions := []v1beta1.Minion{
oldMinion("foo"), oldMinion("foo"),
@@ -166,7 +166,7 @@ func TestMinionListConversionToOld(t *testing.T) {
return v1beta1.Minion{TypeMeta: v1beta1.TypeMeta{ID: id}} return v1beta1.Minion{TypeMeta: v1beta1.TypeMeta{ID: id}}
} }
newMinion := func(id string) newer.Minion { newMinion := func(id string) newer.Minion {
return newer.Minion{TypeMeta: newer.TypeMeta{ID: id}} return newer.Minion{TypeMeta: newer.TypeMeta{Name: id}}
} }
oldMinions := []v1beta1.Minion{ oldMinions := []v1beta1.Minion{
oldMinion("foo"), oldMinion("foo"),

View File

@@ -484,7 +484,7 @@ type ResourceName string
type ResourceList map[ResourceName]util.IntOrString type ResourceList map[ResourceName]util.IntOrString
// Minion is a worker node in Kubernetenes. // Minion is a worker node in Kubernetenes.
// The name of the minion according to etcd is in TypeMeta.ID. // The name of the minion according to etcd is in ID.
type Minion struct { type Minion struct {
TypeMeta `json:",inline" yaml:",inline"` TypeMeta `json:",inline" yaml:",inline"`
// Queried from cloud provider, if available. // Queried from cloud provider, if available.

View File

@@ -30,7 +30,7 @@ func init() {
out.APIVersion = in.APIVersion out.APIVersion = in.APIVersion
out.Kind = in.Kind out.Kind = in.Kind
out.Namespace = in.Namespace out.Namespace = in.Namespace
out.ID = in.ID out.ID = in.Name
out.CreationTimestamp = in.CreationTimestamp out.CreationTimestamp = in.CreationTimestamp
out.SelfLink = in.SelfLink out.SelfLink = in.SelfLink
out.Annotations = in.Annotations out.Annotations = in.Annotations
@@ -48,7 +48,7 @@ func init() {
out.APIVersion = in.APIVersion out.APIVersion = in.APIVersion
out.Kind = in.Kind out.Kind = in.Kind
out.Namespace = in.Namespace out.Namespace = in.Namespace
out.ID = in.ID out.Name = in.ID
out.CreationTimestamp = in.CreationTimestamp out.CreationTimestamp = in.CreationTimestamp
out.SelfLink = in.SelfLink out.SelfLink = in.SelfLink
out.Annotations = in.Annotations out.Annotations = in.Annotations

View File

@@ -449,7 +449,7 @@ type ResourceName string
type ResourceList map[ResourceName]util.IntOrString type ResourceList map[ResourceName]util.IntOrString
// Minion is a worker node in Kubernetenes. // Minion is a worker node in Kubernetenes.
// The name of the minion according to etcd is in TypeMeta.ID. // The name of the minion according to etcd is in ID.
type Minion struct { type Minion struct {
TypeMeta `json:",inline" yaml:",inline"` TypeMeta `json:",inline" yaml:",inline"`
// Queried from cloud provider, if available. // Queried from cloud provider, if available.

View File

@@ -657,7 +657,7 @@ type ResourceName string
type ResourceList map[ResourceName]util.IntOrString type ResourceList map[ResourceName]util.IntOrString
// Node is a worker node in Kubernetenes. // Node is a worker node in Kubernetenes.
// The name of the node according to etcd is in TypeMeta.ID. // The name of the node according to etcd is in ID.
type Node struct { type Node struct {
TypeMeta `json:",inline" yaml:",inline"` TypeMeta `json:",inline" yaml:",inline"`
Metadata ObjectMeta `json:"metadata,omitempty" yaml:"metadata,omitempty"` Metadata ObjectMeta `json:"metadata,omitempty" yaml:"metadata,omitempty"`

View File

@@ -332,8 +332,8 @@ func ValidatePodState(podState *api.PodState) errs.ErrorList {
// ValidatePod tests if required fields in the pod are set. // ValidatePod tests if required fields in the pod are set.
func ValidatePod(pod *api.Pod) errs.ErrorList { func ValidatePod(pod *api.Pod) errs.ErrorList {
allErrs := errs.ErrorList{} allErrs := errs.ErrorList{}
if len(pod.ID) == 0 { if len(pod.Name) == 0 {
allErrs = append(allErrs, errs.NewFieldRequired("id", pod.ID)) allErrs = append(allErrs, errs.NewFieldRequired("id", pod.Name))
} }
if !util.IsDNSSubdomain(pod.Namespace) { if !util.IsDNSSubdomain(pod.Namespace) {
allErrs = append(allErrs, errs.NewFieldInvalid("namespace", pod.Namespace)) allErrs = append(allErrs, errs.NewFieldInvalid("namespace", pod.Namespace))
@@ -346,8 +346,8 @@ func ValidatePod(pod *api.Pod) errs.ErrorList {
func ValidatePodUpdate(newPod, oldPod *api.Pod) errs.ErrorList { func ValidatePodUpdate(newPod, oldPod *api.Pod) errs.ErrorList {
allErrs := errs.ErrorList{} allErrs := errs.ErrorList{}
if newPod.ID != oldPod.ID { if newPod.Name != oldPod.Name {
allErrs = append(allErrs, errs.NewFieldInvalid("ID", newPod.ID)) allErrs = append(allErrs, errs.NewFieldInvalid("ID", newPod.Name))
} }
if len(newPod.DesiredState.Manifest.Containers) != len(oldPod.DesiredState.Manifest.Containers) { if len(newPod.DesiredState.Manifest.Containers) != len(oldPod.DesiredState.Manifest.Containers) {
@@ -373,10 +373,10 @@ func ValidatePodUpdate(newPod, oldPod *api.Pod) errs.ErrorList {
// ValidateService tests if required fields in the service are set. // ValidateService tests if required fields in the service are set.
func ValidateService(service *api.Service) errs.ErrorList { func ValidateService(service *api.Service) errs.ErrorList {
allErrs := errs.ErrorList{} allErrs := errs.ErrorList{}
if len(service.ID) == 0 { if len(service.Name) == 0 {
allErrs = append(allErrs, errs.NewFieldRequired("id", service.ID)) allErrs = append(allErrs, errs.NewFieldRequired("id", service.Name))
} else if !util.IsDNS952Label(service.ID) { } else if !util.IsDNS952Label(service.Name) {
allErrs = append(allErrs, errs.NewFieldInvalid("id", service.ID)) allErrs = append(allErrs, errs.NewFieldInvalid("id", service.Name))
} }
if !util.IsDNSSubdomain(service.Namespace) { if !util.IsDNSSubdomain(service.Namespace) {
allErrs = append(allErrs, errs.NewFieldInvalid("namespace", service.Namespace)) allErrs = append(allErrs, errs.NewFieldInvalid("namespace", service.Namespace))
@@ -398,8 +398,8 @@ func ValidateService(service *api.Service) errs.ErrorList {
// ValidateReplicationController tests if required fields in the replication controller are set. // ValidateReplicationController tests if required fields in the replication controller are set.
func ValidateReplicationController(controller *api.ReplicationController) errs.ErrorList { func ValidateReplicationController(controller *api.ReplicationController) errs.ErrorList {
allErrs := errs.ErrorList{} allErrs := errs.ErrorList{}
if len(controller.ID) == 0 { if len(controller.Name) == 0 {
allErrs = append(allErrs, errs.NewFieldRequired("id", controller.ID)) allErrs = append(allErrs, errs.NewFieldRequired("id", controller.Name))
} }
if !util.IsDNSSubdomain(controller.Namespace) { if !util.IsDNSSubdomain(controller.Namespace) {
allErrs = append(allErrs, errs.NewFieldInvalid("namespace", controller.Namespace)) allErrs = append(allErrs, errs.NewFieldInvalid("namespace", controller.Namespace))
@@ -440,15 +440,15 @@ func ValidateReadOnlyPersistentDisks(volumes []api.Volume) errs.ErrorList {
// ValidateBoundPod tests if required fields on a bound pod are set. // ValidateBoundPod tests if required fields on a bound pod are set.
func ValidateBoundPod(pod *api.BoundPod) (errors []error) { func ValidateBoundPod(pod *api.BoundPod) (errors []error) {
if !util.IsDNSSubdomain(pod.ID) { if !util.IsDNSSubdomain(pod.Name) {
errors = append(errors, errs.NewFieldInvalid("id", pod.ID)) errors = append(errors, errs.NewFieldInvalid("id", pod.Name))
} }
if !util.IsDNSSubdomain(pod.Namespace) { if !util.IsDNSSubdomain(pod.Namespace) {
errors = append(errors, errs.NewFieldInvalid("namespace", pod.Namespace)) errors = append(errors, errs.NewFieldInvalid("namespace", pod.Namespace))
} }
containerManifest := &api.ContainerManifest{ containerManifest := &api.ContainerManifest{
Version: "v1beta2", Version: "v1beta2",
ID: pod.ID, ID: pod.Name,
UUID: pod.UID, UUID: pod.UID,
Containers: pod.Spec.Containers, Containers: pod.Spec.Containers,
Volumes: pod.Spec.Volumes, Volumes: pod.Spec.Volumes,

View File

@@ -367,7 +367,7 @@ func TestValidateManifest(t *testing.T) {
func TestValidatePod(t *testing.T) { func TestValidatePod(t *testing.T) {
errs := ValidatePod(&api.Pod{ errs := ValidatePod(&api.Pod{
TypeMeta: api.TypeMeta{ID: "foo", Namespace: api.NamespaceDefault}, TypeMeta: api.TypeMeta{Name: "foo", Namespace: api.NamespaceDefault},
Labels: map[string]string{ Labels: map[string]string{
"foo": "bar", "foo": "bar",
}, },
@@ -385,7 +385,7 @@ func TestValidatePod(t *testing.T) {
t.Errorf("Unexpected non-zero error list: %#v", errs) t.Errorf("Unexpected non-zero error list: %#v", errs)
} }
errs = ValidatePod(&api.Pod{ errs = ValidatePod(&api.Pod{
TypeMeta: api.TypeMeta{ID: "foo", Namespace: api.NamespaceDefault}, TypeMeta: api.TypeMeta{Name: "foo", Namespace: api.NamespaceDefault},
Labels: map[string]string{ Labels: map[string]string{
"foo": "bar", "foo": "bar",
}, },
@@ -398,7 +398,7 @@ func TestValidatePod(t *testing.T) {
} }
errs = ValidatePod(&api.Pod{ errs = ValidatePod(&api.Pod{
TypeMeta: api.TypeMeta{ID: "foo", Namespace: api.NamespaceDefault}, TypeMeta: api.TypeMeta{Name: "foo", Namespace: api.NamespaceDefault},
Labels: map[string]string{ Labels: map[string]string{
"foo": "bar", "foo": "bar",
}, },
@@ -426,23 +426,23 @@ func TestValidatePodUpdate(t *testing.T) {
{api.Pod{}, api.Pod{}, true, "nothing"}, {api.Pod{}, api.Pod{}, true, "nothing"},
{ {
api.Pod{ api.Pod{
TypeMeta: api.TypeMeta{ID: "foo"}, TypeMeta: api.TypeMeta{Name: "foo"},
}, },
api.Pod{ api.Pod{
TypeMeta: api.TypeMeta{ID: "bar"}, TypeMeta: api.TypeMeta{Name: "bar"},
}, },
false, false,
"ids", "ids",
}, },
{ {
api.Pod{ api.Pod{
TypeMeta: api.TypeMeta{ID: "foo"}, TypeMeta: api.TypeMeta{Name: "foo"},
Labels: map[string]string{ Labels: map[string]string{
"foo": "bar", "foo": "bar",
}, },
}, },
api.Pod{ api.Pod{
TypeMeta: api.TypeMeta{ID: "foo"}, TypeMeta: api.TypeMeta{Name: "foo"},
Labels: map[string]string{ Labels: map[string]string{
"bar": "foo", "bar": "foo",
}, },
@@ -452,7 +452,7 @@ func TestValidatePodUpdate(t *testing.T) {
}, },
{ {
api.Pod{ api.Pod{
TypeMeta: api.TypeMeta{ID: "foo"}, TypeMeta: api.TypeMeta{Name: "foo"},
DesiredState: api.PodState{ DesiredState: api.PodState{
Manifest: api.ContainerManifest{ Manifest: api.ContainerManifest{
Containers: []api.Container{ Containers: []api.Container{
@@ -464,7 +464,7 @@ func TestValidatePodUpdate(t *testing.T) {
}, },
}, },
api.Pod{ api.Pod{
TypeMeta: api.TypeMeta{ID: "foo"}, TypeMeta: api.TypeMeta{Name: "foo"},
DesiredState: api.PodState{ DesiredState: api.PodState{
Manifest: api.ContainerManifest{ Manifest: api.ContainerManifest{
Containers: []api.Container{ Containers: []api.Container{
@@ -483,7 +483,7 @@ func TestValidatePodUpdate(t *testing.T) {
}, },
{ {
api.Pod{ api.Pod{
TypeMeta: api.TypeMeta{ID: "foo"}, TypeMeta: api.TypeMeta{Name: "foo"},
DesiredState: api.PodState{ DesiredState: api.PodState{
Manifest: api.ContainerManifest{ Manifest: api.ContainerManifest{
Containers: []api.Container{ Containers: []api.Container{
@@ -495,7 +495,7 @@ func TestValidatePodUpdate(t *testing.T) {
}, },
}, },
api.Pod{ api.Pod{
TypeMeta: api.TypeMeta{ID: "foo"}, TypeMeta: api.TypeMeta{Name: "foo"},
DesiredState: api.PodState{ DesiredState: api.PodState{
Manifest: api.ContainerManifest{ Manifest: api.ContainerManifest{
Containers: []api.Container{ Containers: []api.Container{
@@ -511,7 +511,7 @@ func TestValidatePodUpdate(t *testing.T) {
}, },
{ {
api.Pod{ api.Pod{
TypeMeta: api.TypeMeta{ID: "foo"}, TypeMeta: api.TypeMeta{Name: "foo"},
DesiredState: api.PodState{ DesiredState: api.PodState{
Manifest: api.ContainerManifest{ Manifest: api.ContainerManifest{
Containers: []api.Container{ Containers: []api.Container{
@@ -524,7 +524,7 @@ func TestValidatePodUpdate(t *testing.T) {
}, },
}, },
api.Pod{ api.Pod{
TypeMeta: api.TypeMeta{ID: "foo"}, TypeMeta: api.TypeMeta{Name: "foo"},
DesiredState: api.PodState{ DesiredState: api.PodState{
Manifest: api.ContainerManifest{ Manifest: api.ContainerManifest{
Containers: []api.Container{ Containers: []api.Container{
@@ -541,7 +541,7 @@ func TestValidatePodUpdate(t *testing.T) {
}, },
{ {
api.Pod{ api.Pod{
TypeMeta: api.TypeMeta{ID: "foo"}, TypeMeta: api.TypeMeta{Name: "foo"},
DesiredState: api.PodState{ DesiredState: api.PodState{
Manifest: api.ContainerManifest{ Manifest: api.ContainerManifest{
Containers: []api.Container{ Containers: []api.Container{
@@ -556,7 +556,7 @@ func TestValidatePodUpdate(t *testing.T) {
}, },
}, },
api.Pod{ api.Pod{
TypeMeta: api.TypeMeta{ID: "foo"}, TypeMeta: api.TypeMeta{Name: "foo"},
DesiredState: api.PodState{ DesiredState: api.PodState{
Manifest: api.ContainerManifest{ Manifest: api.ContainerManifest{
Containers: []api.Container{ Containers: []api.Container{
@@ -608,7 +608,7 @@ func TestValidateService(t *testing.T) {
{ {
name: "missing namespace", name: "missing namespace",
svc: api.Service{ svc: api.Service{
TypeMeta: api.TypeMeta{ID: "foo"}, TypeMeta: api.TypeMeta{Name: "foo"},
Port: 8675, Port: 8675,
Selector: map[string]string{"foo": "bar"}, Selector: map[string]string{"foo": "bar"},
}, },
@@ -618,7 +618,7 @@ func TestValidateService(t *testing.T) {
{ {
name: "invalid id", name: "invalid id",
svc: api.Service{ svc: api.Service{
TypeMeta: api.TypeMeta{ID: "123abc", Namespace: api.NamespaceDefault}, TypeMeta: api.TypeMeta{Name: "123abc", Namespace: api.NamespaceDefault},
Port: 8675, Port: 8675,
Selector: map[string]string{"foo": "bar"}, Selector: map[string]string{"foo": "bar"},
}, },
@@ -628,7 +628,7 @@ func TestValidateService(t *testing.T) {
{ {
name: "missing port", name: "missing port",
svc: api.Service{ svc: api.Service{
TypeMeta: api.TypeMeta{ID: "abc123", Namespace: api.NamespaceDefault}, TypeMeta: api.TypeMeta{Name: "abc123", Namespace: api.NamespaceDefault},
Selector: map[string]string{"foo": "bar"}, Selector: map[string]string{"foo": "bar"},
}, },
// Should fail because the port number is missing/invalid. // Should fail because the port number is missing/invalid.
@@ -637,7 +637,7 @@ func TestValidateService(t *testing.T) {
{ {
name: "invalid port", name: "invalid port",
svc: api.Service{ svc: api.Service{
TypeMeta: api.TypeMeta{ID: "abc123", Namespace: api.NamespaceDefault}, TypeMeta: api.TypeMeta{Name: "abc123", Namespace: api.NamespaceDefault},
Port: 65536, Port: 65536,
Selector: map[string]string{"foo": "bar"}, Selector: map[string]string{"foo": "bar"},
}, },
@@ -647,7 +647,7 @@ func TestValidateService(t *testing.T) {
{ {
name: "invalid protocol", name: "invalid protocol",
svc: api.Service{ svc: api.Service{
TypeMeta: api.TypeMeta{ID: "abc123", Namespace: api.NamespaceDefault}, TypeMeta: api.TypeMeta{Name: "abc123", Namespace: api.NamespaceDefault},
Port: 8675, Port: 8675,
Protocol: "INVALID", Protocol: "INVALID",
Selector: map[string]string{"foo": "bar"}, Selector: map[string]string{"foo": "bar"},
@@ -658,7 +658,7 @@ func TestValidateService(t *testing.T) {
{ {
name: "missing selector", name: "missing selector",
svc: api.Service{ svc: api.Service{
TypeMeta: api.TypeMeta{ID: "foo", Namespace: api.NamespaceDefault}, TypeMeta: api.TypeMeta{Name: "foo", Namespace: api.NamespaceDefault},
Port: 8675, Port: 8675,
}, },
// Should fail because the selector is missing. // Should fail because the selector is missing.
@@ -667,7 +667,7 @@ func TestValidateService(t *testing.T) {
{ {
name: "valid 1", name: "valid 1",
svc: api.Service{ svc: api.Service{
TypeMeta: api.TypeMeta{ID: "abc123", Namespace: api.NamespaceDefault}, TypeMeta: api.TypeMeta{Name: "abc123", Namespace: api.NamespaceDefault},
Port: 1, Port: 1,
Protocol: "TCP", Protocol: "TCP",
Selector: map[string]string{"foo": "bar"}, Selector: map[string]string{"foo": "bar"},
@@ -677,7 +677,7 @@ func TestValidateService(t *testing.T) {
{ {
name: "valid 2", name: "valid 2",
svc: api.Service{ svc: api.Service{
TypeMeta: api.TypeMeta{ID: "abc123", Namespace: api.NamespaceDefault}, TypeMeta: api.TypeMeta{Name: "abc123", Namespace: api.NamespaceDefault},
Port: 65535, Port: 65535,
Protocol: "UDP", Protocol: "UDP",
Selector: map[string]string{"foo": "bar"}, Selector: map[string]string{"foo": "bar"},
@@ -687,7 +687,7 @@ func TestValidateService(t *testing.T) {
{ {
name: "valid 3", name: "valid 3",
svc: api.Service{ svc: api.Service{
TypeMeta: api.TypeMeta{ID: "abc123", Namespace: api.NamespaceDefault}, TypeMeta: api.TypeMeta{Name: "abc123", Namespace: api.NamespaceDefault},
Port: 80, Port: 80,
Selector: map[string]string{"foo": "bar"}, Selector: map[string]string{"foo": "bar"},
}, },
@@ -704,7 +704,7 @@ func TestValidateService(t *testing.T) {
svc := api.Service{ svc := api.Service{
Port: 6502, Port: 6502,
TypeMeta: api.TypeMeta{ID: "foo", Namespace: api.NamespaceDefault}, TypeMeta: api.TypeMeta{Name: "foo", Namespace: api.NamespaceDefault},
Selector: map[string]string{"foo": "bar"}, Selector: map[string]string{"foo": "bar"},
} }
errs := ValidateService(&svc) errs := ValidateService(&svc)
@@ -736,14 +736,14 @@ func TestValidateReplicationController(t *testing.T) {
} }
successCases := []api.ReplicationController{ successCases := []api.ReplicationController{
{ {
TypeMeta: api.TypeMeta{ID: "abc", Namespace: api.NamespaceDefault}, TypeMeta: api.TypeMeta{Name: "abc", Namespace: api.NamespaceDefault},
DesiredState: api.ReplicationControllerState{ DesiredState: api.ReplicationControllerState{
ReplicaSelector: validSelector, ReplicaSelector: validSelector,
PodTemplate: validPodTemplate, PodTemplate: validPodTemplate,
}, },
}, },
{ {
TypeMeta: api.TypeMeta{ID: "abc-123", Namespace: api.NamespaceDefault}, TypeMeta: api.TypeMeta{Name: "abc-123", Namespace: api.NamespaceDefault},
DesiredState: api.ReplicationControllerState{ DesiredState: api.ReplicationControllerState{
ReplicaSelector: validSelector, ReplicaSelector: validSelector,
PodTemplate: validPodTemplate, PodTemplate: validPodTemplate,
@@ -758,47 +758,47 @@ func TestValidateReplicationController(t *testing.T) {
errorCases := map[string]api.ReplicationController{ errorCases := map[string]api.ReplicationController{
"zero-length ID": { "zero-length ID": {
TypeMeta: api.TypeMeta{ID: "", Namespace: api.NamespaceDefault}, TypeMeta: api.TypeMeta{Name: "", Namespace: api.NamespaceDefault},
DesiredState: api.ReplicationControllerState{ DesiredState: api.ReplicationControllerState{
ReplicaSelector: validSelector, ReplicaSelector: validSelector,
PodTemplate: validPodTemplate, PodTemplate: validPodTemplate,
}, },
}, },
"missing-namespace": { "missing-namespace": {
TypeMeta: api.TypeMeta{ID: "abc-123"}, TypeMeta: api.TypeMeta{Name: "abc-123"},
DesiredState: api.ReplicationControllerState{ DesiredState: api.ReplicationControllerState{
ReplicaSelector: validSelector, ReplicaSelector: validSelector,
PodTemplate: validPodTemplate, PodTemplate: validPodTemplate,
}, },
}, },
"empty selector": { "empty selector": {
TypeMeta: api.TypeMeta{ID: "abc", Namespace: api.NamespaceDefault}, TypeMeta: api.TypeMeta{Name: "abc", Namespace: api.NamespaceDefault},
DesiredState: api.ReplicationControllerState{ DesiredState: api.ReplicationControllerState{
PodTemplate: validPodTemplate, PodTemplate: validPodTemplate,
}, },
}, },
"selector_doesnt_match": { "selector_doesnt_match": {
TypeMeta: api.TypeMeta{ID: "abc", Namespace: api.NamespaceDefault}, TypeMeta: api.TypeMeta{Name: "abc", Namespace: api.NamespaceDefault},
DesiredState: api.ReplicationControllerState{ DesiredState: api.ReplicationControllerState{
ReplicaSelector: map[string]string{"foo": "bar"}, ReplicaSelector: map[string]string{"foo": "bar"},
PodTemplate: validPodTemplate, PodTemplate: validPodTemplate,
}, },
}, },
"invalid manifest": { "invalid manifest": {
TypeMeta: api.TypeMeta{ID: "abc", Namespace: api.NamespaceDefault}, TypeMeta: api.TypeMeta{Name: "abc", Namespace: api.NamespaceDefault},
DesiredState: api.ReplicationControllerState{ DesiredState: api.ReplicationControllerState{
ReplicaSelector: validSelector, ReplicaSelector: validSelector,
}, },
}, },
"read-write presistent disk": { "read-write presistent disk": {
TypeMeta: api.TypeMeta{ID: "abc"}, TypeMeta: api.TypeMeta{Name: "abc"},
DesiredState: api.ReplicationControllerState{ DesiredState: api.ReplicationControllerState{
ReplicaSelector: validSelector, ReplicaSelector: validSelector,
PodTemplate: invalidVolumePodTemplate, PodTemplate: invalidVolumePodTemplate,
}, },
}, },
"negative_replicas": { "negative_replicas": {
TypeMeta: api.TypeMeta{ID: "abc", Namespace: api.NamespaceDefault}, TypeMeta: api.TypeMeta{Name: "abc", Namespace: api.NamespaceDefault},
DesiredState: api.ReplicationControllerState{ DesiredState: api.ReplicationControllerState{
Replicas: -1, Replicas: -1,
ReplicaSelector: validSelector, ReplicaSelector: validSelector,
@@ -827,13 +827,13 @@ func TestValidateReplicationController(t *testing.T) {
func TestValidateBoundPodNoName(t *testing.T) { func TestValidateBoundPodNoName(t *testing.T) {
errorCases := map[string]api.BoundPod{ errorCases := map[string]api.BoundPod{
// manifest is tested in api/validation_test.go, ensure it is invoked // manifest is tested in api/validation_test.go, ensure it is invoked
"empty version": {TypeMeta: api.TypeMeta{ID: "test"}, Spec: api.PodSpec{Containers: []api.Container{{Name: ""}}}}, "empty version": {TypeMeta: api.TypeMeta{Name: "test"}, Spec: api.PodSpec{Containers: []api.Container{{Name: ""}}}},
// Name // Name
"zero-length name": {TypeMeta: api.TypeMeta{ID: ""}}, "zero-length name": {TypeMeta: api.TypeMeta{Name: ""}},
"name > 255 characters": {TypeMeta: api.TypeMeta{ID: strings.Repeat("a", 256)}}, "name > 255 characters": {TypeMeta: api.TypeMeta{Name: strings.Repeat("a", 256)}},
"name not a DNS subdomain": {TypeMeta: api.TypeMeta{ID: "a.b.c."}}, "name not a DNS subdomain": {TypeMeta: api.TypeMeta{Name: "a.b.c."}},
"name with underscore": {TypeMeta: api.TypeMeta{ID: "a_b_c"}}, "name with underscore": {TypeMeta: api.TypeMeta{Name: "a_b_c"}},
} }
for k, v := range errorCases { for k, v := range errorCases {
if errs := ValidateBoundPod(&v); len(errs) == 0 { if errs := ValidateBoundPod(&v); len(errs) == 0 {

View File

@@ -54,7 +54,7 @@ func init() {
type Simple struct { type Simple struct {
api.TypeMeta `yaml:",inline" json:",inline"` api.TypeMeta `yaml:",inline" json:",inline"`
Name string `yaml:"name,omitempty" json:"name,omitempty"` Other string `yaml:"other,omitempty" json:"other,omitempty"`
} }
func (*Simple) IsAnAPIObject() {} func (*Simple) IsAnAPIObject() {}
@@ -108,7 +108,7 @@ func (storage *SimpleRESTStorage) Delete(ctx api.Context, id string) (<-chan run
} }
return MakeAsync(func() (runtime.Object, error) { return MakeAsync(func() (runtime.Object, error) {
if storage.injectedFunction != nil { if storage.injectedFunction != nil {
return storage.injectedFunction(&Simple{TypeMeta: api.TypeMeta{ID: id}}) return storage.injectedFunction(&Simple{TypeMeta: api.TypeMeta{Name: id}})
} }
return &api.Status{Status: api.StatusSuccess}, nil return &api.Status{Status: api.StatusSuccess}, nil
}), nil }), nil
@@ -295,7 +295,7 @@ func TestNonEmptyList(t *testing.T) {
list: []Simple{ list: []Simple{
{ {
TypeMeta: api.TypeMeta{Kind: "Simple"}, TypeMeta: api.TypeMeta{Kind: "Simple"},
Name: "foo", Other: "foo",
}, },
}, },
} }
@@ -322,7 +322,7 @@ func TestNonEmptyList(t *testing.T) {
t.Errorf("Unexpected response: %#v", listOut) t.Errorf("Unexpected response: %#v", listOut)
return return
} }
if listOut.Items[0].Name != simpleStorage.list[0].Name { if listOut.Items[0].Other != simpleStorage.list[0].Other {
t.Errorf("Unexpected data: %#v, %s", listOut.Items[0], string(body)) t.Errorf("Unexpected data: %#v, %s", listOut.Items[0], string(body))
} }
} }
@@ -331,7 +331,7 @@ func TestGet(t *testing.T) {
storage := map[string]RESTStorage{} storage := map[string]RESTStorage{}
simpleStorage := SimpleRESTStorage{ simpleStorage := SimpleRESTStorage{
item: Simple{ item: Simple{
Name: "foo", Other: "foo",
}, },
} }
selfLinker := &setTestSelfLinker{ selfLinker := &setTestSelfLinker{
@@ -431,7 +431,7 @@ func TestUpdate(t *testing.T) {
server := httptest.NewServer(handler) server := httptest.NewServer(handler)
item := &Simple{ item := &Simple{
Name: "bar", Other: "bar",
} }
body, err := codec.Encode(item) body, err := codec.Encode(item)
if err != nil { if err != nil {
@@ -464,7 +464,7 @@ func TestUpdateMissing(t *testing.T) {
server := httptest.NewServer(handler) server := httptest.NewServer(handler)
item := &Simple{ item := &Simple{
Name: "bar", Other: "bar",
} }
body, err := codec.Encode(item) body, err := codec.Encode(item)
if err != nil { if err != nil {
@@ -493,7 +493,7 @@ func TestCreate(t *testing.T) {
client := http.Client{} client := http.Client{}
simple := &Simple{ simple := &Simple{
Name: "foo", Other: "foo",
} }
data, _ := codec.Encode(simple) data, _ := codec.Encode(simple)
request, err := http.NewRequest("POST", server.URL+"/prefix/version/foo", bytes.NewBuffer(data)) request, err := http.NewRequest("POST", server.URL+"/prefix/version/foo", bytes.NewBuffer(data))
@@ -532,7 +532,7 @@ func TestCreateNotFound(t *testing.T) {
server := httptest.NewServer(handler) server := httptest.NewServer(handler)
client := http.Client{} client := http.Client{}
simple := &Simple{Name: "foo"} simple := &Simple{Other: "foo"}
data, _ := codec.Encode(simple) data, _ := codec.Encode(simple)
request, err := http.NewRequest("POST", server.URL+"/prefix/version/simple", bytes.NewBuffer(data)) request, err := http.NewRequest("POST", server.URL+"/prefix/version/simple", bytes.NewBuffer(data))
if err != nil { if err != nil {
@@ -597,7 +597,7 @@ func TestSyncCreate(t *testing.T) {
client := http.Client{} client := http.Client{}
simple := &Simple{ simple := &Simple{
Name: "bar", Other: "bar",
} }
data, _ := codec.Encode(simple) data, _ := codec.Encode(simple)
request, err := http.NewRequest("POST", server.URL+"/prefix/version/foo?sync=true", bytes.NewBuffer(data)) request, err := http.NewRequest("POST", server.URL+"/prefix/version/foo?sync=true", bytes.NewBuffer(data))
@@ -691,7 +691,7 @@ func TestAsyncCreateError(t *testing.T) {
handler.(*defaultAPIServer).group.handler.asyncOpWait = 0 handler.(*defaultAPIServer).group.handler.asyncOpWait = 0
server := httptest.NewServer(handler) server := httptest.NewServer(handler)
simple := &Simple{Name: "bar"} simple := &Simple{Other: "bar"}
data, _ := codec.Encode(simple) data, _ := codec.Encode(simple)
status := expectApiStatus(t, "POST", fmt.Sprintf("%s/prefix/version/foo", server.URL), data, http.StatusAccepted) status := expectApiStatus(t, "POST", fmt.Sprintf("%s/prefix/version/foo", server.URL), data, http.StatusAccepted)
@@ -787,7 +787,7 @@ func TestSyncCreateTimeout(t *testing.T) {
}, codec, "/prefix/version", selfLinker) }, codec, "/prefix/version", selfLinker)
server := httptest.NewServer(handler) server := httptest.NewServer(handler)
simple := &Simple{Name: "foo"} simple := &Simple{Other: "foo"}
data, _ := codec.Encode(simple) data, _ := codec.Encode(simple)
itemOut := expectApiStatus(t, "POST", server.URL+"/prefix/version/foo?sync=true&timeout=4ms", data, http.StatusAccepted) itemOut := expectApiStatus(t, "POST", server.URL+"/prefix/version/foo?sync=true&timeout=4ms", data, http.StatusAccepted)
if itemOut.Status != api.StatusWorking || itemOut.Details == nil || itemOut.Details.ID == "" { if itemOut.Status != api.StatusWorking || itemOut.Details == nil || itemOut.Details.ID == "" {

View File

@@ -125,7 +125,7 @@ func (ops *Operations) List() *api.ServerOpList {
sort.StringSlice(ids).Sort() sort.StringSlice(ids).Sort()
ol := &api.ServerOpList{} ol := &api.ServerOpList{}
for _, id := range ids { for _, id := range ids {
ol.Items = append(ol.Items, api.ServerOp{TypeMeta: api.TypeMeta{ID: id}}) ol.Items = append(ol.Items, api.ServerOp{TypeMeta: api.TypeMeta{Name: id}})
} }
return ol return ol
} }

View File

@@ -43,7 +43,7 @@ func TestOperation(t *testing.T) {
time.Sleep(time.Millisecond) time.Sleep(time.Millisecond)
go func() { go func() {
time.Sleep(500 * time.Millisecond) time.Sleep(500 * time.Millisecond)
c <- &Simple{TypeMeta: api.TypeMeta{ID: "All done"}} c <- &Simple{TypeMeta: api.TypeMeta{Name: "All done"}}
}() }()
if op.expired(time.Now().Add(-time.Minute)) { if op.expired(time.Now().Add(-time.Minute)) {
@@ -96,7 +96,7 @@ func TestOperation(t *testing.T) {
t.Errorf("expire failed to remove the operation %#v", ops) t.Errorf("expire failed to remove the operation %#v", ops)
} }
if op.result.(*Simple).ID != "All done" { if op.result.(*Simple).Name != "All done" {
t.Errorf("Got unexpected result: %#v", op.result) t.Errorf("Got unexpected result: %#v", op.result)
} }
} }
@@ -119,7 +119,7 @@ func TestOperationsList(t *testing.T) {
client := http.Client{} client := http.Client{}
simple := &Simple{ simple := &Simple{
Name: "foo", TypeMeta: api.TypeMeta{Name: "foo"},
} }
data, err := codec.Encode(simple) data, err := codec.Encode(simple)
if err != nil { if err != nil {
@@ -175,7 +175,7 @@ func TestOpGet(t *testing.T) {
client := http.Client{} client := http.Client{}
simple := &Simple{ simple := &Simple{
Name: "foo", TypeMeta: api.TypeMeta{Name: "foo"},
} }
data, err := codec.Encode(simple) data, err := codec.Encode(simple)
t.Log(string(data)) t.Log(string(data))

View File

@@ -39,9 +39,9 @@ var watchTestTable = []struct {
t watch.EventType t watch.EventType
obj runtime.Object obj runtime.Object
}{ }{
{watch.Added, &Simple{Name: "A Name"}}, {watch.Added, &Simple{Other: "A Name"}},
{watch.Modified, &Simple{Name: "Another Name"}}, {watch.Modified, &Simple{Other: "Another Name"}},
{watch.Deleted, &Simple{Name: "Another Name"}}, {watch.Deleted, &Simple{Other: "Another Name"}},
} }
func TestWatchWebsocket(t *testing.T) { func TestWatchWebsocket(t *testing.T) {

View File

@@ -54,13 +54,13 @@ func TestReflector_watchHandler(t *testing.T) {
s := NewStore() s := NewStore()
g := NewReflector(&testLW{}, &api.Pod{}, s) g := NewReflector(&testLW{}, &api.Pod{}, s)
fw := watch.NewFake() fw := watch.NewFake()
s.Add("foo", &api.Pod{TypeMeta: api.TypeMeta{ID: "foo"}}) s.Add("foo", &api.Pod{TypeMeta: api.TypeMeta{Name: "foo"}})
s.Add("bar", &api.Pod{TypeMeta: api.TypeMeta{ID: "bar"}}) s.Add("bar", &api.Pod{TypeMeta: api.TypeMeta{Name: "bar"}})
go func() { go func() {
fw.Add(&api.Service{TypeMeta: api.TypeMeta{ID: "rejected"}}) fw.Add(&api.Service{TypeMeta: api.TypeMeta{Name: "rejected"}})
fw.Delete(&api.Pod{TypeMeta: api.TypeMeta{ID: "foo"}}) fw.Delete(&api.Pod{TypeMeta: api.TypeMeta{Name: "foo"}})
fw.Modify(&api.Pod{TypeMeta: api.TypeMeta{ID: "bar", ResourceVersion: "55"}}) fw.Modify(&api.Pod{TypeMeta: api.TypeMeta{Name: "bar", ResourceVersion: "55"}})
fw.Add(&api.Pod{TypeMeta: api.TypeMeta{ID: "baz", ResourceVersion: "32"}}) fw.Add(&api.Pod{TypeMeta: api.TypeMeta{Name: "baz", ResourceVersion: "32"}})
fw.Stop() fw.Stop()
}() }()
var resumeRV string var resumeRV string
@@ -132,7 +132,7 @@ func TestReflector_listAndWatch(t *testing.T) {
fw = <-createdFakes fw = <-createdFakes
} }
sendingRV := strconv.FormatUint(uint64(i+2), 10) sendingRV := strconv.FormatUint(uint64(i+2), 10)
fw.Add(&api.Pod{TypeMeta: api.TypeMeta{ID: id, ResourceVersion: sendingRV}}) fw.Add(&api.Pod{TypeMeta: api.TypeMeta{Name: id, ResourceVersion: sendingRV}})
if sendingRV == "3" { if sendingRV == "3" {
// Inject a failure. // Inject a failure.
fw.Stop() fw.Stop()
@@ -143,7 +143,7 @@ func TestReflector_listAndWatch(t *testing.T) {
// Verify we received the right ids with the right resource versions. // Verify we received the right ids with the right resource versions.
for i, id := range ids { for i, id := range ids {
pod := s.Pop().(*api.Pod) pod := s.Pop().(*api.Pod)
if e, a := id, pod.ID; e != a { if e, a := id, pod.Name; e != a {
t.Errorf("%v: Expected %v, got %v", i, e, a) t.Errorf("%v: Expected %v, got %v", i, e, a)
} }
if e, a := strconv.FormatUint(uint64(i+2), 10), pod.ResourceVersion; e != a { if e, a := strconv.FormatUint(uint64(i+2), 10), pod.ResourceVersion; e != a {
@@ -158,7 +158,7 @@ func TestReflector_listAndWatch(t *testing.T) {
func TestReflector_listAndWatchWithErrors(t *testing.T) { func TestReflector_listAndWatchWithErrors(t *testing.T) {
mkPod := func(id string, rv string) *api.Pod { mkPod := func(id string, rv string) *api.Pod {
return &api.Pod{TypeMeta: api.TypeMeta{ID: id, ResourceVersion: rv}} return &api.Pod{TypeMeta: api.TypeMeta{Name: id, ResourceVersion: rv}}
} }
mkList := func(rv string, pods ...*api.Pod) *api.PodList { mkList := func(rv string, pods ...*api.Pod) *api.PodList {
list := &api.PodList{TypeMeta: api.TypeMeta{ResourceVersion: rv}} list := &api.PodList{TypeMeta: api.TypeMeta{ResourceVersion: rv}}
@@ -208,11 +208,11 @@ func TestReflector_listAndWatchWithErrors(t *testing.T) {
checkMap := map[string]string{} checkMap := map[string]string{}
for _, item := range current { for _, item := range current {
pod := item.(*api.Pod) pod := item.(*api.Pod)
checkMap[pod.ID] = pod.ResourceVersion checkMap[pod.Name] = pod.ResourceVersion
} }
for _, pod := range item.list.Items { for _, pod := range item.list.Items {
if e, a := pod.ResourceVersion, checkMap[pod.ID]; e != a { if e, a := pod.ResourceVersion, checkMap[pod.Name]; e != a {
t.Errorf("%v: expected %v, got %v for pod %v", line, e, a, pod.ID) t.Errorf("%v: expected %v, got %v for pod %v", line, e, a, pod.Name)
} }
} }
if e, a := len(item.list.Items), len(checkMap); e != a { if e, a := len(item.list.Items), len(checkMap); e != a {

View File

@@ -136,7 +136,7 @@ func (c *Client) UpdatePod(ctx api.Context, pod *api.Pod) (result *api.Pod, err
err = fmt.Errorf("invalid update object, missing resource version: %v", pod) err = fmt.Errorf("invalid update object, missing resource version: %v", pod)
return return
} }
err = c.Put().Namespace(api.Namespace(ctx)).Path("pods").Path(pod.ID).Body(pod).Do().Into(result) err = c.Put().Namespace(api.Namespace(ctx)).Path("pods").Path(pod.Name).Body(pod).Do().Into(result)
return return
} }
@@ -168,7 +168,7 @@ func (c *Client) UpdateReplicationController(ctx api.Context, controller *api.Re
err = fmt.Errorf("invalid update object, missing resource version: %v", controller) err = fmt.Errorf("invalid update object, missing resource version: %v", controller)
return return
} }
err = c.Put().Namespace(api.Namespace(ctx)).Path("replicationControllers").Path(controller.ID).Body(controller).Do().Into(result) err = c.Put().Namespace(api.Namespace(ctx)).Path("replicationControllers").Path(controller.Name).Body(controller).Do().Into(result)
return return
} }
@@ -217,7 +217,7 @@ func (c *Client) UpdateService(ctx api.Context, svc *api.Service) (result *api.S
err = fmt.Errorf("invalid update object, missing resource version: %v", svc) err = fmt.Errorf("invalid update object, missing resource version: %v", svc)
return return
} }
err = c.Put().Namespace(api.Namespace(ctx)).Path("services").Path(svc.ID).Body(svc).Do().Into(result) err = c.Put().Namespace(api.Namespace(ctx)).Path("services").Path(svc.Name).Body(svc).Do().Into(result)
return return
} }
@@ -280,7 +280,7 @@ func (c *Client) UpdateEndpoints(ctx api.Context, endpoints *api.Endpoints) (*ap
err := c.Put(). err := c.Put().
Namespace(api.Namespace(ctx)). Namespace(api.Namespace(ctx)).
Path("endpoints"). Path("endpoints").
Path(endpoints.ID). Path(endpoints.Name).
Body(endpoints). Body(endpoints).
Do(). Do().
Into(result) Into(result)

View File

@@ -266,7 +266,7 @@ func TestCreatePod(t *testing.T) {
func TestUpdatePod(t *testing.T) { func TestUpdatePod(t *testing.T) {
requestPod := &api.Pod{ requestPod := &api.Pod{
TypeMeta: api.TypeMeta{ID: "foo", ResourceVersion: "1"}, TypeMeta: api.TypeMeta{Name: "foo", ResourceVersion: "1"},
CurrentState: api.PodState{ CurrentState: api.PodState{
Status: "Foobar", Status: "Foobar",
}, },
@@ -290,7 +290,7 @@ func TestListControllers(t *testing.T) {
Body: &api.ReplicationControllerList{ Body: &api.ReplicationControllerList{
Items: []api.ReplicationController{ Items: []api.ReplicationController{
{ {
TypeMeta: api.TypeMeta{ID: "foo"}, TypeMeta: api.TypeMeta{Name: "foo"},
DesiredState: api.ReplicationControllerState{ DesiredState: api.ReplicationControllerState{
Replicas: 2, Replicas: 2,
}, },
@@ -314,7 +314,7 @@ func TestGetController(t *testing.T) {
Response: Response{ Response: Response{
StatusCode: 200, StatusCode: 200,
Body: &api.ReplicationController{ Body: &api.ReplicationController{
TypeMeta: api.TypeMeta{ID: "foo"}, TypeMeta: api.TypeMeta{Name: "foo"},
DesiredState: api.ReplicationControllerState{ DesiredState: api.ReplicationControllerState{
Replicas: 2, Replicas: 2,
}, },
@@ -331,14 +331,14 @@ func TestGetController(t *testing.T) {
func TestUpdateController(t *testing.T) { func TestUpdateController(t *testing.T) {
requestController := &api.ReplicationController{ requestController := &api.ReplicationController{
TypeMeta: api.TypeMeta{ID: "foo", ResourceVersion: "1"}, TypeMeta: api.TypeMeta{Name: "foo", ResourceVersion: "1"},
} }
c := &testClient{ c := &testClient{
Request: testRequest{Method: "PUT", Path: "/replicationControllers/foo"}, Request: testRequest{Method: "PUT", Path: "/replicationControllers/foo"},
Response: Response{ Response: Response{
StatusCode: 200, StatusCode: 200,
Body: &api.ReplicationController{ Body: &api.ReplicationController{
TypeMeta: api.TypeMeta{ID: "foo"}, TypeMeta: api.TypeMeta{Name: "foo"},
DesiredState: api.ReplicationControllerState{ DesiredState: api.ReplicationControllerState{
Replicas: 2, Replicas: 2,
}, },
@@ -364,14 +364,14 @@ func TestDeleteController(t *testing.T) {
func TestCreateController(t *testing.T) { func TestCreateController(t *testing.T) {
requestController := &api.ReplicationController{ requestController := &api.ReplicationController{
TypeMeta: api.TypeMeta{ID: "foo"}, TypeMeta: api.TypeMeta{Name: "foo"},
} }
c := &testClient{ c := &testClient{
Request: testRequest{Method: "POST", Path: "/replicationControllers", Body: requestController}, Request: testRequest{Method: "POST", Path: "/replicationControllers", Body: requestController},
Response: Response{ Response: Response{
StatusCode: 200, StatusCode: 200,
Body: &api.ReplicationController{ Body: &api.ReplicationController{
TypeMeta: api.TypeMeta{ID: "foo"}, TypeMeta: api.TypeMeta{Name: "foo"},
DesiredState: api.ReplicationControllerState{ DesiredState: api.ReplicationControllerState{
Replicas: 2, Replicas: 2,
}, },
@@ -402,7 +402,7 @@ func TestListServices(t *testing.T) {
Body: &api.ServiceList{ Body: &api.ServiceList{
Items: []api.Service{ Items: []api.Service{
{ {
TypeMeta: api.TypeMeta{ID: "name"}, TypeMeta: api.TypeMeta{Name: "name"},
Labels: map[string]string{ Labels: map[string]string{
"foo": "bar", "foo": "bar",
"name": "baz", "name": "baz",
@@ -426,7 +426,7 @@ func TestListServicesLabels(t *testing.T) {
Body: &api.ServiceList{ Body: &api.ServiceList{
Items: []api.Service{ Items: []api.Service{
{ {
TypeMeta: api.TypeMeta{ID: "name"}, TypeMeta: api.TypeMeta{Name: "name"},
Labels: map[string]string{ Labels: map[string]string{
"foo": "bar", "foo": "bar",
"name": "baz", "name": "baz",
@@ -449,7 +449,7 @@ func TestListServicesLabels(t *testing.T) {
func TestGetService(t *testing.T) { func TestGetService(t *testing.T) {
c := &testClient{ c := &testClient{
Request: testRequest{Method: "GET", Path: "/services/1"}, Request: testRequest{Method: "GET", Path: "/services/1"},
Response: Response{StatusCode: 200, Body: &api.Service{TypeMeta: api.TypeMeta{ID: "service-1"}}}, Response: Response{StatusCode: 200, Body: &api.Service{TypeMeta: api.TypeMeta{Name: "service-1"}}},
} }
response, err := c.Setup().GetService(api.NewDefaultContext(), "1") response, err := c.Setup().GetService(api.NewDefaultContext(), "1")
c.Validate(t, response, err) c.Validate(t, response, err)
@@ -457,15 +457,15 @@ func TestGetService(t *testing.T) {
func TestCreateService(t *testing.T) { func TestCreateService(t *testing.T) {
c := &testClient{ c := &testClient{
Request: testRequest{Method: "POST", Path: "/services", Body: &api.Service{TypeMeta: api.TypeMeta{ID: "service-1"}}}, Request: testRequest{Method: "POST", Path: "/services", Body: &api.Service{TypeMeta: api.TypeMeta{Name: "service-1"}}},
Response: Response{StatusCode: 200, Body: &api.Service{TypeMeta: api.TypeMeta{ID: "service-1"}}}, Response: Response{StatusCode: 200, Body: &api.Service{TypeMeta: api.TypeMeta{Name: "service-1"}}},
} }
response, err := c.Setup().CreateService(api.NewDefaultContext(), &api.Service{TypeMeta: api.TypeMeta{ID: "service-1"}}) response, err := c.Setup().CreateService(api.NewDefaultContext(), &api.Service{TypeMeta: api.TypeMeta{Name: "service-1"}})
c.Validate(t, response, err) c.Validate(t, response, err)
} }
func TestUpdateService(t *testing.T) { func TestUpdateService(t *testing.T) {
svc := &api.Service{TypeMeta: api.TypeMeta{ID: "service-1", ResourceVersion: "1"}} svc := &api.Service{TypeMeta: api.TypeMeta{Name: "service-1", ResourceVersion: "1"}}
c := &testClient{ c := &testClient{
Request: testRequest{Method: "PUT", Path: "/services/service-1", Body: svc}, Request: testRequest{Method: "PUT", Path: "/services/service-1", Body: svc},
Response: Response{StatusCode: 200, Body: svc}, Response: Response{StatusCode: 200, Body: svc},
@@ -490,7 +490,7 @@ func TestListEndpooints(t *testing.T) {
Body: &api.EndpointsList{ Body: &api.EndpointsList{
Items: []api.Endpoints{ Items: []api.Endpoints{
{ {
TypeMeta: api.TypeMeta{ID: "endpoint-1"}, TypeMeta: api.TypeMeta{Name: "endpoint-1"},
Endpoints: []string{"10.245.1.2:8080", "10.245.1.3:8080"}, Endpoints: []string{"10.245.1.2:8080", "10.245.1.3:8080"},
}, },
}, },
@@ -504,7 +504,7 @@ func TestListEndpooints(t *testing.T) {
func TestGetEndpoints(t *testing.T) { func TestGetEndpoints(t *testing.T) {
c := &testClient{ c := &testClient{
Request: testRequest{Method: "GET", Path: "/endpoints/endpoint-1"}, Request: testRequest{Method: "GET", Path: "/endpoints/endpoint-1"},
Response: Response{StatusCode: 200, Body: &api.Endpoints{TypeMeta: api.TypeMeta{ID: "endpoint-1"}}}, Response: Response{StatusCode: 200, Body: &api.Endpoints{TypeMeta: api.TypeMeta{Name: "endpoint-1"}}},
} }
response, err := c.Setup().GetEndpoints(api.NewDefaultContext(), "endpoint-1") response, err := c.Setup().GetEndpoints(api.NewDefaultContext(), "endpoint-1")
c.Validate(t, response, err) c.Validate(t, response, err)
@@ -540,7 +540,7 @@ func TestGetServerVersion(t *testing.T) {
func TestListMinions(t *testing.T) { func TestListMinions(t *testing.T) {
c := &testClient{ c := &testClient{
Request: testRequest{Method: "GET", Path: "/minions"}, Request: testRequest{Method: "GET", Path: "/minions"},
Response: Response{StatusCode: 200, Body: &api.MinionList{TypeMeta: api.TypeMeta{ID: "minion-1"}}}, Response: Response{StatusCode: 200, Body: &api.MinionList{TypeMeta: api.TypeMeta{Name: "minion-1"}}},
} }
response, err := c.Setup().ListMinions() response, err := c.Setup().ListMinions()
c.Validate(t, response, err) c.Validate(t, response, err)
@@ -549,7 +549,7 @@ func TestListMinions(t *testing.T) {
func TestCreateMinion(t *testing.T) { func TestCreateMinion(t *testing.T) {
requestMinion := &api.Minion{ requestMinion := &api.Minion{
TypeMeta: api.TypeMeta{ TypeMeta: api.TypeMeta{
ID: "minion-1", Name: "minion-1",
}, },
HostIP: "123.321.456.654", HostIP: "123.321.456.654",
NodeResources: api.NodeResources{ NodeResources: api.NodeResources{

View File

@@ -64,7 +64,7 @@ func (c *Fake) CreatePod(ctx api.Context, pod *api.Pod) (*api.Pod, error) {
} }
func (c *Fake) UpdatePod(ctx api.Context, pod *api.Pod) (*api.Pod, error) { func (c *Fake) UpdatePod(ctx api.Context, pod *api.Pod) (*api.Pod, error) {
c.Actions = append(c.Actions, FakeAction{Action: "update-pod", Value: pod.ID}) c.Actions = append(c.Actions, FakeAction{Action: "update-pod", Value: pod.Name})
return &api.Pod{}, nil return &api.Pod{}, nil
} }
@@ -166,7 +166,7 @@ func (c *Fake) DeleteMinion(id string) error {
// CreateEvent makes a new event. Returns the copy of the event the server returns, or an error. // CreateEvent makes a new event. Returns the copy of the event the server returns, or an error.
func (c *Fake) CreateEvent(event *api.Event) (*api.Event, error) { func (c *Fake) CreateEvent(event *api.Event) (*api.Event, error) {
c.Actions = append(c.Actions, FakeAction{Action: "get-event", Value: event.ID}) c.Actions = append(c.Actions, FakeAction{Action: "get-event", Value: event.Name})
return &api.Event{}, nil return &api.Event{}, nil
} }

View File

@@ -56,7 +56,7 @@ func TestEventf(t *testing.T) {
obj: &api.Pod{ obj: &api.Pod{
TypeMeta: api.TypeMeta{ TypeMeta: api.TypeMeta{
SelfLink: "/api/v1beta1/pods/foo", SelfLink: "/api/v1beta1/pods/foo",
ID: "foo", Name: "foo",
}, },
}, },
fieldPath: "desiredState.manifest.containers[2]", fieldPath: "desiredState.manifest.containers[2]",

View File

@@ -72,7 +72,7 @@ func TestDoRequestNewWay(t *testing.T) {
} }
func TestDoRequestNewWayReader(t *testing.T) { func TestDoRequestNewWayReader(t *testing.T) {
reqObj := &api.Pod{TypeMeta: api.TypeMeta{ID: "foo"}} reqObj := &api.Pod{TypeMeta: api.TypeMeta{Name: "foo"}}
reqBodyExpected, _ := v1beta1.Codec.Encode(reqObj) reqBodyExpected, _ := v1beta1.Codec.Encode(reqObj)
expectedObj := &api.Service{Port: 12345} expectedObj := &api.Service{Port: 12345}
expectedBody, _ := v1beta1.Codec.Encode(expectedObj) expectedBody, _ := v1beta1.Codec.Encode(expectedObj)
@@ -108,7 +108,7 @@ func TestDoRequestNewWayReader(t *testing.T) {
} }
func TestDoRequestNewWayObj(t *testing.T) { func TestDoRequestNewWayObj(t *testing.T) {
reqObj := &api.Pod{TypeMeta: api.TypeMeta{ID: "foo"}} reqObj := &api.Pod{TypeMeta: api.TypeMeta{Name: "foo"}}
reqBodyExpected, _ := v1beta2.Codec.Encode(reqObj) reqBodyExpected, _ := v1beta2.Codec.Encode(reqObj)
expectedObj := &api.Service{Port: 12345} expectedObj := &api.Service{Port: 12345}
expectedBody, _ := v1beta2.Codec.Encode(expectedObj) expectedBody, _ := v1beta2.Codec.Encode(expectedObj)
@@ -143,7 +143,7 @@ func TestDoRequestNewWayObj(t *testing.T) {
} }
func TestDoRequestNewWayFile(t *testing.T) { func TestDoRequestNewWayFile(t *testing.T) {
reqObj := &api.Pod{TypeMeta: api.TypeMeta{ID: "foo"}} reqObj := &api.Pod{TypeMeta: api.TypeMeta{Name: "foo"}}
reqBodyExpected, err := v1beta1.Codec.Encode(reqObj) reqBodyExpected, err := v1beta1.Codec.Encode(reqObj)
if err != nil { if err != nil {
t.Errorf("unexpected error: %v", err) t.Errorf("unexpected error: %v", err)
@@ -380,9 +380,9 @@ func TestWatch(t *testing.T) {
t watch.EventType t watch.EventType
obj runtime.Object obj runtime.Object
}{ }{
{watch.Added, &api.Pod{TypeMeta: api.TypeMeta{ID: "first"}}}, {watch.Added, &api.Pod{TypeMeta: api.TypeMeta{Name: "first"}}},
{watch.Modified, &api.Pod{TypeMeta: api.TypeMeta{ID: "second"}}}, {watch.Modified, &api.Pod{TypeMeta: api.TypeMeta{Name: "second"}}},
{watch.Deleted, &api.Pod{TypeMeta: api.TypeMeta{ID: "last"}}}, {watch.Deleted, &api.Pod{TypeMeta: api.TypeMeta{Name: "last"}}},
} }
auth := &Config{Username: "user", Password: "pass"} auth := &Config{Username: "user", Password: "pass"}

View File

@@ -70,19 +70,19 @@ func (s *MinionController) Sync() error {
} }
minionMap := make(map[string]*api.Minion) minionMap := make(map[string]*api.Minion)
for _, minion := range minions.Items { for _, minion := range minions.Items {
minionMap[minion.ID] = &minion minionMap[minion.Name] = &minion
} }
// Create or delete minions from registry. // Create or delete minions from registry.
for _, match := range matches.Items { for _, minion := range matches.Items {
if _, ok := minionMap[match.ID]; !ok { if _, ok := minionMap[minion.Name]; !ok {
glog.Infof("Create minion in registry: %s", match.ID) glog.Infof("Create minion in registry: %s", minion.Name)
err = s.registry.CreateMinion(nil, &match) err = s.registry.CreateMinion(nil, &minion)
if err != nil { if err != nil {
return err return err
} }
} }
delete(minionMap, match.ID) delete(minionMap, minion.Name)
} }
for minionID := range minionMap { for minionID := range minionMap {
@@ -109,7 +109,7 @@ func (s *MinionController) cloudMinions() (*api.MinionList, error) {
Items: make([]api.Minion, len(matches)), Items: make([]api.Minion, len(matches)),
} }
for i := range matches { for i := range matches {
result.Items[i].ID = matches[i] result.Items[i].Name = matches[i]
resources, err := instances.GetNodeResources(matches[i]) resources, err := instances.GetNodeResources(matches[i])
if err != nil { if err != nil {
return nil, err return nil, err

View File

@@ -45,8 +45,8 @@ func NewTestEtcdRegistry(client tools.EtcdClient) *etcdregistry.Registry {
func TestSyncCreateMinion(t *testing.T) { func TestSyncCreateMinion(t *testing.T) {
ctx := api.NewContext() ctx := api.NewContext()
fakeClient := tools.NewFakeEtcdClient(t) fakeClient := tools.NewFakeEtcdClient(t)
m1 := runtime.EncodeOrDie(latest.Codec, &api.Minion{TypeMeta: api.TypeMeta{ID: "m1"}}) m1 := runtime.EncodeOrDie(latest.Codec, &api.Minion{TypeMeta: api.TypeMeta{Name: "m1"}})
m2 := runtime.EncodeOrDie(latest.Codec, &api.Minion{TypeMeta: api.TypeMeta{ID: "m2"}}) m2 := runtime.EncodeOrDie(latest.Codec, &api.Minion{TypeMeta: api.TypeMeta{Name: "m2"}})
fakeClient.Set("/registry/minions/m1", m1, 0) fakeClient.Set("/registry/minions/m1", m1, 0)
fakeClient.Set("/registry/minions/m2", m2, 0) fakeClient.Set("/registry/minions/m2", m2, 0)
fakeClient.ExpectNotFoundGet("/registry/minions/m3") fakeClient.ExpectNotFoundGet("/registry/minions/m3")
@@ -88,9 +88,9 @@ func TestSyncCreateMinion(t *testing.T) {
func TestSyncDeleteMinion(t *testing.T) { func TestSyncDeleteMinion(t *testing.T) {
ctx := api.NewContext() ctx := api.NewContext()
fakeClient := tools.NewFakeEtcdClient(t) fakeClient := tools.NewFakeEtcdClient(t)
m1 := runtime.EncodeOrDie(latest.Codec, &api.Minion{TypeMeta: api.TypeMeta{ID: "m1"}}) m1 := runtime.EncodeOrDie(latest.Codec, &api.Minion{TypeMeta: api.TypeMeta{Name: "m1"}})
m2 := runtime.EncodeOrDie(latest.Codec, &api.Minion{TypeMeta: api.TypeMeta{ID: "m2"}}) m2 := runtime.EncodeOrDie(latest.Codec, &api.Minion{TypeMeta: api.TypeMeta{Name: "m2"}})
m3 := runtime.EncodeOrDie(latest.Codec, &api.Minion{TypeMeta: api.TypeMeta{ID: "m3"}}) m3 := runtime.EncodeOrDie(latest.Codec, &api.Minion{TypeMeta: api.TypeMeta{Name: "m3"}})
fakeClient.Set("/registry/minions/m1", m1, 0) fakeClient.Set("/registry/minions/m1", m1, 0)
fakeClient.Set("/registry/minions/m2", m2, 0) fakeClient.Set("/registry/minions/m2", m2, 0)
fakeClient.Set("/registry/minions/m3", m3, 0) fakeClient.Set("/registry/minions/m3", m3, 0)

View File

@@ -56,7 +56,7 @@ func (r RealPodControl) createReplica(ctx api.Context, controllerSpec api.Replic
labels := controllerSpec.DesiredState.PodTemplate.Labels labels := controllerSpec.DesiredState.PodTemplate.Labels
// TODO: don't fail to set this label just because the map isn't created. // TODO: don't fail to set this label just because the map isn't created.
if labels != nil { if labels != nil {
labels["replicationController"] = controllerSpec.ID labels["replicationController"] = controllerSpec.Name
} }
pod := &api.Pod{ pod := &api.Pod{
DesiredState: controllerSpec.DesiredState.PodTemplate.DesiredState, DesiredState: controllerSpec.DesiredState.PodTemplate.DesiredState,
@@ -127,7 +127,7 @@ func (rm *ReplicationManager) watchControllers(resourceVersion *string) {
*resourceVersion = rc.ResourceVersion *resourceVersion = rc.ResourceVersion
// Sync even if this is a deletion event, to ensure that we leave // Sync even if this is a deletion event, to ensure that we leave
// it in the desired state. // it in the desired state.
glog.V(4).Infof("About to sync from watch: %v", rc.ID) glog.V(4).Infof("About to sync from watch: %v", rc.Name)
rm.syncHandler(*rc) rm.syncHandler(*rc)
} }
} }
@@ -171,7 +171,7 @@ func (rm *ReplicationManager) syncReplicationController(controllerSpec api.Repli
for i := 0; i < diff; i++ { for i := 0; i < diff; i++ {
go func(ix int) { go func(ix int) {
defer wait.Done() defer wait.Done()
rm.podControl.deletePod(ctx, filteredList[ix].ID) rm.podControl.deletePod(ctx, filteredList[ix].Name)
}(i) }(i)
} }
wait.Wait() wait.Wait()
@@ -195,7 +195,7 @@ func (rm *ReplicationManager) synchronize() {
for ix := range controllerSpecs { for ix := range controllerSpecs {
go func(ix int) { go func(ix int) {
defer wg.Done() defer wg.Done()
glog.V(4).Infof("periodic sync of %v", controllerSpecs[ix].ID) glog.V(4).Infof("periodic sync of %v", controllerSpecs[ix].Name)
err := rm.syncHandler(controllerSpecs[ix]) err := rm.syncHandler(controllerSpecs[ix])
if err != nil { if err != nil {
glog.Errorf("Error synchronizing: %#v", err) glog.Errorf("Error synchronizing: %#v", err)

View File

@@ -90,7 +90,7 @@ func newPodList(count int) *api.PodList {
for i := 0; i < count; i++ { for i := 0; i < count; i++ {
pods = append(pods, api.Pod{ pods = append(pods, api.Pod{
TypeMeta: api.TypeMeta{ TypeMeta: api.TypeMeta{
ID: fmt.Sprintf("pod%d", i), Name: fmt.Sprintf("pod%d", i),
}, },
}) })
} }
@@ -345,7 +345,7 @@ func TestWatchControllers(t *testing.T) {
go manager.watchControllers(&resourceVersion) go manager.watchControllers(&resourceVersion)
// Test normal case // Test normal case
testControllerSpec.ID = "foo" testControllerSpec.Name = "foo"
client.w.Add(&testControllerSpec) client.w.Add(&testControllerSpec)
select { select {

View File

@@ -153,7 +153,7 @@ func Update(ctx api.Context, name string, client client.Interface, updatePeriod
for _, pod := range podList.Items { for _, pod := range podList.Items {
// We delete the pod here, the controller will recreate it. This will result in pulling // We delete the pod here, the controller will recreate it. This will result in pulling
// a new Docker image. This isn't a full "update" but it's what we support for now. // a new Docker image. This isn't a full "update" but it's what we support for now.
err = client.DeletePod(ctx, pod.ID) err = client.DeletePod(ctx, pod.Name)
if err != nil { if err != nil {
return err return err
} }
@@ -246,7 +246,7 @@ func RunController(ctx api.Context, image, name string, replicas int, client cli
} }
controller := &api.ReplicationController{ controller := &api.ReplicationController{
TypeMeta: api.TypeMeta{ TypeMeta: api.TypeMeta{
ID: name, Name: name,
}, },
DesiredState: api.ReplicationControllerState{ DesiredState: api.ReplicationControllerState{
Replicas: replicas, Replicas: replicas,
@@ -299,7 +299,7 @@ func RunController(ctx api.Context, image, name string, replicas int, client cli
func createService(ctx api.Context, name string, port int, client client.Interface) (*api.Service, error) { func createService(ctx api.Context, name string, port int, client client.Interface) (*api.Service, error) {
svc := &api.Service{ svc := &api.Service{
TypeMeta: api.TypeMeta{ID: name}, TypeMeta: api.TypeMeta{Name: name},
Port: port, Port: port,
Labels: map[string]string{ Labels: map[string]string{
"simpleService": name, "simpleService": name,

View File

@@ -38,8 +38,8 @@ func TestUpdateWithPods(t *testing.T) {
fakeClient := client.Fake{ fakeClient := client.Fake{
Pods: api.PodList{ Pods: api.PodList{
Items: []api.Pod{ Items: []api.Pod{
{TypeMeta: api.TypeMeta{ID: "pod-1"}}, {TypeMeta: api.TypeMeta{Name: "pod-1"}},
{TypeMeta: api.TypeMeta{ID: "pod-2"}}, {TypeMeta: api.TypeMeta{Name: "pod-2"}},
}, },
}, },
} }
@@ -69,8 +69,8 @@ func TestUpdateWithNewImage(t *testing.T) {
fakeClient := client.Fake{ fakeClient := client.Fake{
Pods: api.PodList{ Pods: api.PodList{
Items: []api.Pod{ Items: []api.Pod{
{TypeMeta: api.TypeMeta{ID: "pod-1"}}, {TypeMeta: api.TypeMeta{Name: "pod-1"}},
{TypeMeta: api.TypeMeta{ID: "pod-2"}}, {TypeMeta: api.TypeMeta{Name: "pod-2"}},
}, },
}, },
Ctrl: api.ReplicationController{ Ctrl: api.ReplicationController{
@@ -114,7 +114,7 @@ func TestRunController(t *testing.T) {
t.Errorf("Unexpected actions: %#v", fakeClient.Actions) t.Errorf("Unexpected actions: %#v", fakeClient.Actions)
} }
controller := fakeClient.Actions[0].Value.(*api.ReplicationController) controller := fakeClient.Actions[0].Value.(*api.ReplicationController)
if controller.ID != name || if controller.Name != name ||
controller.DesiredState.Replicas != replicas || controller.DesiredState.Replicas != replicas ||
controller.DesiredState.PodTemplate.DesiredState.Manifest.Containers[0].Image != image { controller.DesiredState.PodTemplate.DesiredState.Manifest.Containers[0].Image != image {
t.Errorf("Unexpected controller: %#v", controller) t.Errorf("Unexpected controller: %#v", controller)
@@ -135,7 +135,7 @@ func TestRunControllerWithWrongArgs(t *testing.T) {
t.Errorf("Unexpected actions: %#v", fakeClient.Actions) t.Errorf("Unexpected actions: %#v", fakeClient.Actions)
} }
controller := fakeClient.Actions[0].Value.(*api.ReplicationController) controller := fakeClient.Actions[0].Value.(*api.ReplicationController)
if controller.ID != name || if controller.Name != name ||
controller.DesiredState.Replicas != replicas || controller.DesiredState.Replicas != replicas ||
controller.DesiredState.PodTemplate.DesiredState.Manifest.Containers[0].Image != image { controller.DesiredState.PodTemplate.DesiredState.Manifest.Containers[0].Image != image {
t.Errorf("Unexpected controller: %#v", controller) t.Errorf("Unexpected controller: %#v", controller)
@@ -154,7 +154,7 @@ func TestRunControllerWithService(t *testing.T) {
t.Errorf("Unexpected actions: %#v", fakeClient.Actions) t.Errorf("Unexpected actions: %#v", fakeClient.Actions)
} }
controller := fakeClient.Actions[0].Value.(*api.ReplicationController) controller := fakeClient.Actions[0].Value.(*api.ReplicationController)
if controller.ID != name || if controller.Name != name ||
controller.DesiredState.Replicas != replicas || controller.DesiredState.Replicas != replicas ||
controller.DesiredState.PodTemplate.DesiredState.Manifest.Containers[0].Image != image { controller.DesiredState.PodTemplate.DesiredState.Manifest.Containers[0].Image != image {
t.Errorf("Unexpected controller: %#v", controller) t.Errorf("Unexpected controller: %#v", controller)

View File

@@ -69,7 +69,7 @@ var testParser = NewParser(map[string]runtime.Object{
func TestParsePod(t *testing.T) { func TestParsePod(t *testing.T) {
DoParseTest(t, "pods", &api.Pod{ DoParseTest(t, "pods", &api.Pod{
TypeMeta: api.TypeMeta{APIVersion: "v1beta1", ID: "test pod", Kind: "Pod"}, TypeMeta: api.TypeMeta{APIVersion: "v1beta1", Name: "test pod", Kind: "Pod"},
DesiredState: api.PodState{ DesiredState: api.PodState{
Manifest: api.ContainerManifest{ Manifest: api.ContainerManifest{
ID: "My manifest", ID: "My manifest",
@@ -86,7 +86,7 @@ func TestParsePod(t *testing.T) {
func TestParseService(t *testing.T) { func TestParseService(t *testing.T) {
DoParseTest(t, "services", &api.Service{ DoParseTest(t, "services", &api.Service{
TypeMeta: api.TypeMeta{APIVersion: "v1beta1", ID: "my service", Kind: "Service"}, TypeMeta: api.TypeMeta{APIVersion: "v1beta1", Name: "my service", Kind: "Service"},
Port: 8080, Port: 8080,
Labels: map[string]string{ Labels: map[string]string{
"area": "staging", "area": "staging",
@@ -99,7 +99,7 @@ func TestParseService(t *testing.T) {
func TestParseController(t *testing.T) { func TestParseController(t *testing.T) {
DoParseTest(t, "replicationControllers", &api.ReplicationController{ DoParseTest(t, "replicationControllers", &api.ReplicationController{
TypeMeta: api.TypeMeta{APIVersion: "v1beta1", ID: "my controller", Kind: "ReplicationController"}, TypeMeta: api.TypeMeta{APIVersion: "v1beta1", Name: "my controller", Kind: "ReplicationController"},
DesiredState: api.ReplicationControllerState{ DesiredState: api.ReplicationControllerState{
Replicas: 9001, Replicas: 9001,
PodTemplate: api.PodTemplate{ PodTemplate: api.PodTemplate{
@@ -134,7 +134,7 @@ func TestParseCustomType(t *testing.T) {
"custom": &TestParseType{}, "custom": &TestParseType{},
}) })
DoParseTest(t, "custom", &TestParseType{ DoParseTest(t, "custom", &TestParseType{
TypeMeta: api.TypeMeta{APIVersion: "", ID: "my custom object", Kind: "TestParseType"}, TypeMeta: api.TypeMeta{APIVersion: "", Name: "my custom object", Kind: "TestParseType"},
Data: "test data", Data: "test data",
}, v1beta1.Codec, parser) }, v1beta1.Codec, parser)
} }

View File

@@ -194,7 +194,7 @@ func podHostString(host, ip string) string {
func printPod(pod *api.Pod, w io.Writer) error { func printPod(pod *api.Pod, w io.Writer) error {
_, err := fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s\n", _, err := fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s\n",
pod.ID, makeImageList(pod.DesiredState.Manifest), pod.Name, makeImageList(pod.DesiredState.Manifest),
podHostString(pod.CurrentState.Host, pod.CurrentState.HostIP), podHostString(pod.CurrentState.Host, pod.CurrentState.HostIP),
labels.Set(pod.Labels), pod.CurrentState.Status) labels.Set(pod.Labels), pod.CurrentState.Status)
return err return err
@@ -209,16 +209,16 @@ func printPodList(podList *api.PodList, w io.Writer) error {
return nil return nil
} }
func printReplicationController(ctrl *api.ReplicationController, w io.Writer) error { func printReplicationController(controller *api.ReplicationController, w io.Writer) error {
_, err := fmt.Fprintf(w, "%s\t%s\t%s\t%d\n", _, err := fmt.Fprintf(w, "%s\t%s\t%s\t%d\n",
ctrl.ID, makeImageList(ctrl.DesiredState.PodTemplate.DesiredState.Manifest), controller.Name, makeImageList(controller.DesiredState.PodTemplate.DesiredState.Manifest),
labels.Set(ctrl.DesiredState.ReplicaSelector), ctrl.DesiredState.Replicas) labels.Set(controller.DesiredState.ReplicaSelector), controller.DesiredState.Replicas)
return err return err
} }
func printReplicationControllerList(list *api.ReplicationControllerList, w io.Writer) error { func printReplicationControllerList(list *api.ReplicationControllerList, w io.Writer) error {
for _, ctrl := range list.Items { for _, controller := range list.Items {
if err := printReplicationController(&ctrl, w); err != nil { if err := printReplicationController(&controller, w); err != nil {
return err return err
} }
} }
@@ -226,7 +226,7 @@ func printReplicationControllerList(list *api.ReplicationControllerList, w io.Wr
} }
func printService(svc *api.Service, w io.Writer) error { func printService(svc *api.Service, w io.Writer) error {
_, err := fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%d\n", svc.ID, labels.Set(svc.Labels), _, err := fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%d\n", svc.Name, labels.Set(svc.Labels),
labels.Set(svc.Selector), svc.PortalIP, svc.Port) labels.Set(svc.Selector), svc.PortalIP, svc.Port)
return err return err
} }
@@ -241,7 +241,7 @@ func printServiceList(list *api.ServiceList, w io.Writer) error {
} }
func printMinion(minion *api.Minion, w io.Writer) error { func printMinion(minion *api.Minion, w io.Writer) error {
_, err := fmt.Fprintf(w, "%s\n", minion.ID) _, err := fmt.Fprintf(w, "%s\n", minion.Name)
return err return err
} }

View File

@@ -68,7 +68,7 @@ func TestYAMLPrinterPrint(t *testing.T) {
} }
obj := &api.Pod{ obj := &api.Pod{
TypeMeta: api.TypeMeta{ID: "foo"}, TypeMeta: api.TypeMeta{Name: "foo"},
} }
buf.Reset() buf.Reset()
printer.PrintObj(obj, buf) printer.PrintObj(obj, buf)
@@ -92,7 +92,7 @@ func TestIdentityPrinter(t *testing.T) {
} }
obj := &api.Pod{ obj := &api.Pod{
TypeMeta: api.TypeMeta{ID: "foo"}, TypeMeta: api.TypeMeta{Name: "foo"},
} }
buff.Reset() buff.Reset()
printer.PrintObj(obj, buff) printer.PrintObj(obj, buff)

View File

@@ -61,7 +61,7 @@ func describePod(w io.Writer, c client.Interface, id string) (string, error) {
} }
return tabbedString(func(out *tabwriter.Writer) error { return tabbedString(func(out *tabwriter.Writer) error {
fmt.Fprintf(out, "ID:\t%s\n", pod.ID) fmt.Fprintf(out, "Name:\t%s\n", pod.Name)
fmt.Fprintf(out, "Image(s):\t%s\n", makeImageList(pod.DesiredState.Manifest)) fmt.Fprintf(out, "Image(s):\t%s\n", makeImageList(pod.DesiredState.Manifest))
fmt.Fprintf(out, "Host:\t%s\n", pod.CurrentState.Host+"/"+pod.CurrentState.HostIP) fmt.Fprintf(out, "Host:\t%s\n", pod.CurrentState.Host+"/"+pod.CurrentState.HostIP)
fmt.Fprintf(out, "Labels:\t%s\n", formatLabels(pod.Labels)) fmt.Fprintf(out, "Labels:\t%s\n", formatLabels(pod.Labels))
@@ -72,50 +72,50 @@ func describePod(w io.Writer, c client.Interface, id string) (string, error) {
} }
func describeReplicationController(w io.Writer, c client.Interface, id string) (string, error) { func describeReplicationController(w io.Writer, c client.Interface, id string) (string, error) {
rc, err := c.GetReplicationController(api.NewDefaultContext(), id) controller, err := c.GetReplicationController(api.NewDefaultContext(), id)
if err != nil { if err != nil {
return "", err return "", err
} }
running, waiting, terminated, err := getPodStatusForReplicationController(c, rc) running, waiting, terminated, err := getPodStatusForReplicationController(c, controller)
if err != nil { if err != nil {
return "", err return "", err
} }
return tabbedString(func(out *tabwriter.Writer) error { return tabbedString(func(out *tabwriter.Writer) error {
fmt.Fprintf(out, "ID:\t%s\n", rc.ID) fmt.Fprintf(out, "Name:\t%s\n", controller.Name)
fmt.Fprintf(out, "Image(s):\t%s\n", makeImageList(rc.DesiredState.PodTemplate.DesiredState.Manifest)) fmt.Fprintf(out, "Image(s):\t%s\n", makeImageList(controller.DesiredState.PodTemplate.DesiredState.Manifest))
fmt.Fprintf(out, "Selector:\t%s\n", formatLabels(rc.DesiredState.ReplicaSelector)) fmt.Fprintf(out, "Selector:\t%s\n", formatLabels(controller.DesiredState.ReplicaSelector))
fmt.Fprintf(out, "Labels:\t%s\n", formatLabels(rc.Labels)) fmt.Fprintf(out, "Labels:\t%s\n", formatLabels(controller.Labels))
fmt.Fprintf(out, "Replicas:\t%d current / %d desired\n", rc.CurrentState.Replicas, rc.DesiredState.Replicas) fmt.Fprintf(out, "Replicas:\t%d current / %d desired\n", controller.CurrentState.Replicas, controller.DesiredState.Replicas)
fmt.Fprintf(out, "Pods Status:\t%d Running / %d Waiting / %d Terminated\n", running, waiting, terminated) fmt.Fprintf(out, "Pods Status:\t%d Running / %d Waiting / %d Terminated\n", running, waiting, terminated)
return nil return nil
}) })
} }
func describeService(w io.Writer, c client.Interface, id string) (string, error) { func describeService(w io.Writer, c client.Interface, id string) (string, error) {
s, err := c.GetService(api.NewDefaultContext(), id) service, err := c.GetService(api.NewDefaultContext(), id)
if err != nil { if err != nil {
return "", err return "", err
} }
return tabbedString(func(out *tabwriter.Writer) error { return tabbedString(func(out *tabwriter.Writer) error {
fmt.Fprintf(out, "ID:\t%s\n", s.ID) fmt.Fprintf(out, "Name:\t%s\n", service.Name)
fmt.Fprintf(out, "Labels:\t%s\n", formatLabels(s.Labels)) fmt.Fprintf(out, "Labels:\t%s\n", formatLabels(service.Labels))
fmt.Fprintf(out, "Selector:\t%s\n", formatLabels(s.Selector)) fmt.Fprintf(out, "Selector:\t%s\n", formatLabels(service.Selector))
fmt.Fprintf(out, "Port:\t%d\n", s.Port) fmt.Fprintf(out, "Port:\t%d\n", service.Port)
return nil return nil
}) })
} }
func describeMinion(w io.Writer, c client.Interface, id string) (string, error) { func describeMinion(w io.Writer, c client.Interface, id string) (string, error) {
m, err := getMinion(c, id) minion, err := getMinion(c, id)
if err != nil { if err != nil {
return "", err return "", err
} }
return tabbedString(func(out *tabwriter.Writer) error { return tabbedString(func(out *tabwriter.Writer) error {
fmt.Fprintf(out, "ID:\t%s\n", m.ID) fmt.Fprintf(out, "Name:\t%s\n", minion.Name)
return nil return nil
}) })
} }
@@ -127,9 +127,9 @@ func getMinion(c client.Interface, id string) (*api.Minion, error) {
glog.Fatalf("Error getting minion info: %v\n", err) glog.Fatalf("Error getting minion info: %v\n", err)
} }
for _, m := range minionList.Items { for _, minion := range minionList.Items {
if id == m.TypeMeta.ID { if id == minion.Name {
return &m, nil return &minion, nil
} }
} }
return nil, fmt.Errorf("Minion %s not found", id) return nil, fmt.Errorf("Minion %s not found", id)
@@ -148,17 +148,17 @@ func getReplicationControllersForLabels(c client.Interface, labelsToMatch labels
// Find the ones that match labelsToMatch. // Find the ones that match labelsToMatch.
var matchingRCs []api.ReplicationController var matchingRCs []api.ReplicationController
for _, rc := range rcs.Items { for _, controller := range rcs.Items {
selector := labels.SelectorFromSet(rc.DesiredState.ReplicaSelector) selector := labels.SelectorFromSet(controller.DesiredState.ReplicaSelector)
if selector.Matches(labelsToMatch) { if selector.Matches(labelsToMatch) {
matchingRCs = append(matchingRCs, rc) matchingRCs = append(matchingRCs, controller)
} }
} }
// Format the matching RC's into strings. // Format the matching RC's into strings.
var rcStrings []string var rcStrings []string
for _, rc := range matchingRCs { for _, controller := range matchingRCs {
rcStrings = append(rcStrings, fmt.Sprintf("%s (%d/%d replicas created)", rc.ID, rc.CurrentState.Replicas, rc.DesiredState.Replicas)) rcStrings = append(rcStrings, fmt.Sprintf("%s (%d/%d replicas created)", controller.Name, controller.CurrentState.Replicas, controller.DesiredState.Replicas))
} }
list := strings.Join(rcStrings, ", ") list := strings.Join(rcStrings, ", ")
@@ -168,8 +168,8 @@ func getReplicationControllersForLabels(c client.Interface, labelsToMatch labels
return list return list
} }
func getPodStatusForReplicationController(kubeClient client.Interface, rc *api.ReplicationController) (running, waiting, terminated int, err error) { func getPodStatusForReplicationController(kubeClient client.Interface, controller *api.ReplicationController) (running, waiting, terminated int, err error) {
rcPods, err := kubeClient.ListPods(api.NewDefaultContext(), labels.SelectorFromSet(rc.DesiredState.ReplicaSelector)) rcPods, err := kubeClient.ListPods(api.NewDefaultContext(), labels.SelectorFromSet(controller.DesiredState.ReplicaSelector))
if err != nil { if err != nil {
return return
} }

View File

@@ -194,7 +194,7 @@ func podHostString(host, ip string) string {
func printPod(pod *api.Pod, w io.Writer) error { func printPod(pod *api.Pod, w io.Writer) error {
_, err := fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s\n", _, err := fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s\n",
pod.ID, makeImageList(pod.DesiredState.Manifest), pod.Name, makeImageList(pod.DesiredState.Manifest),
podHostString(pod.CurrentState.Host, pod.CurrentState.HostIP), podHostString(pod.CurrentState.Host, pod.CurrentState.HostIP),
labels.Set(pod.Labels), pod.CurrentState.Status) labels.Set(pod.Labels), pod.CurrentState.Status)
return err return err
@@ -209,16 +209,16 @@ func printPodList(podList *api.PodList, w io.Writer) error {
return nil return nil
} }
func printReplicationController(ctrl *api.ReplicationController, w io.Writer) error { func printReplicationController(controller *api.ReplicationController, w io.Writer) error {
_, err := fmt.Fprintf(w, "%s\t%s\t%s\t%d\n", _, err := fmt.Fprintf(w, "%s\t%s\t%s\t%d\n",
ctrl.ID, makeImageList(ctrl.DesiredState.PodTemplate.DesiredState.Manifest), controller.Name, makeImageList(controller.DesiredState.PodTemplate.DesiredState.Manifest),
labels.Set(ctrl.DesiredState.ReplicaSelector), ctrl.DesiredState.Replicas) labels.Set(controller.DesiredState.ReplicaSelector), controller.DesiredState.Replicas)
return err return err
} }
func printReplicationControllerList(list *api.ReplicationControllerList, w io.Writer) error { func printReplicationControllerList(list *api.ReplicationControllerList, w io.Writer) error {
for _, ctrl := range list.Items { for _, controller := range list.Items {
if err := printReplicationController(&ctrl, w); err != nil { if err := printReplicationController(&controller, w); err != nil {
return err return err
} }
} }
@@ -226,7 +226,7 @@ func printReplicationControllerList(list *api.ReplicationControllerList, w io.Wr
} }
func printService(svc *api.Service, w io.Writer) error { func printService(svc *api.Service, w io.Writer) error {
_, err := fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%d\n", svc.ID, labels.Set(svc.Labels), _, err := fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%d\n", svc.Name, labels.Set(svc.Labels),
labels.Set(svc.Selector), svc.PortalIP, svc.Port) labels.Set(svc.Selector), svc.PortalIP, svc.Port)
return err return err
} }
@@ -241,7 +241,7 @@ func printServiceList(list *api.ServiceList, w io.Writer) error {
} }
func printMinion(minion *api.Minion, w io.Writer) error { func printMinion(minion *api.Minion, w io.Writer) error {
_, err := fmt.Fprintf(w, "%s\n", minion.ID) _, err := fmt.Fprintf(w, "%s\n", minion.Name)
return err return err
} }

View File

@@ -69,7 +69,7 @@ func testPrinter(t *testing.T, printer ResourcePrinter, unmarshalFunc func(data
} }
obj := &api.Pod{ obj := &api.Pod{
TypeMeta: api.TypeMeta{ID: "foo"}, TypeMeta: api.TypeMeta{Name: "foo"},
} }
buf.Reset() buf.Reset()
printer.PrintObj(obj, buf) printer.PrintObj(obj, buf)

View File

@@ -260,7 +260,7 @@ func filterInvalidPods(pods []api.BoundPod, source string) (filtered []*api.Boun
var errors []error var errors []error
name := podUniqueName(&pods[i]) name := podUniqueName(&pods[i])
if names.Has(name) { if names.Has(name) {
errors = append(errors, apierrs.NewFieldDuplicate("name", pods[i].ID)) errors = append(errors, apierrs.NewFieldDuplicate("name", pods[i].Name))
} else { } else {
names.Insert(name) names.Insert(name)
} }
@@ -268,7 +268,7 @@ func filterInvalidPods(pods []api.BoundPod, source string) (filtered []*api.Boun
errors = append(errors, errs...) errors = append(errors, errs...)
} }
if len(errors) > 0 { if len(errors) > 0 {
glog.Warningf("Pod %d (%s) from %s failed validation, ignoring: %v", i+1, pods[i].ID, source, errors) glog.Warningf("Pod %d (%s) from %s failed validation, ignoring: %v", i+1, pods[i].Name, source, errors)
continue continue
} }
filtered = append(filtered, &pods[i]) filtered = append(filtered, &pods[i])
@@ -307,5 +307,5 @@ func podUniqueName(pod *api.BoundPod) string {
if len(namespace) == 0 { if len(namespace) == 0 {
namespace = api.NamespaceDefault namespace = api.NamespaceDefault
} }
return fmt.Sprintf("%s.%s", pod.ID, namespace) return fmt.Sprintf("%s.%s", pod.Name, namespace)
} }

View File

@@ -45,13 +45,13 @@ func (s sortedPods) Less(i, j int) bool {
if s[i].Namespace < s[j].Namespace { if s[i].Namespace < s[j].Namespace {
return true return true
} }
return s[i].ID < s[j].ID return s[i].Name < s[j].Name
} }
func CreateValidPod(name, namespace, source string) api.BoundPod { func CreateValidPod(name, namespace, source string) api.BoundPod {
return api.BoundPod{ return api.BoundPod{
TypeMeta: api.TypeMeta{ TypeMeta: api.TypeMeta{
ID: name, Name: name,
Namespace: namespace, Namespace: namespace,
Annotations: map[string]string{kubelet.ConfigSourceAnnotationKey: source}, Annotations: map[string]string{kubelet.ConfigSourceAnnotationKey: source},
}, },
@@ -158,7 +158,7 @@ func TestInvalidPodFiltered(t *testing.T) {
expectPodUpdate(t, ch, CreatePodUpdate(kubelet.ADD, CreateValidPod("foo", "new", "test"))) expectPodUpdate(t, ch, CreatePodUpdate(kubelet.ADD, CreateValidPod("foo", "new", "test")))
// add an invalid update // add an invalid update
podUpdate = CreatePodUpdate(kubelet.UPDATE, api.BoundPod{TypeMeta: api.TypeMeta{ID: "foo"}}) podUpdate = CreatePodUpdate(kubelet.UPDATE, api.BoundPod{TypeMeta: api.TypeMeta{Name: "foo"}})
channel <- podUpdate channel <- podUpdate
expectNoPodUpdate(t, ch) expectNoPodUpdate(t, ch)
} }
@@ -217,7 +217,7 @@ func TestNewPodAddedUpdatedRemoved(t *testing.T) {
channel <- podUpdate channel <- podUpdate
expectPodUpdate(t, ch, CreatePodUpdate(kubelet.UPDATE, pod)) expectPodUpdate(t, ch, CreatePodUpdate(kubelet.UPDATE, pod))
podUpdate = CreatePodUpdate(kubelet.REMOVE, api.BoundPod{TypeMeta: api.TypeMeta{ID: "foo", Namespace: "new"}}) podUpdate = CreatePodUpdate(kubelet.REMOVE, api.BoundPod{TypeMeta: api.TypeMeta{Name: "foo", Namespace: "new"}})
channel <- podUpdate channel <- podUpdate
expectPodUpdate(t, ch, CreatePodUpdate(kubelet.REMOVE, pod)) expectPodUpdate(t, ch, CreatePodUpdate(kubelet.REMOVE, pod))
} }

View File

@@ -95,8 +95,8 @@ func eventToPods(ev watch.Event) ([]api.BoundPod, error) {
} }
for i, pod := range boundPods.Items { for i, pod := range boundPods.Items {
if len(pod.ID) == 0 { if len(pod.Name) == 0 {
pod.ID = fmt.Sprintf("%d", i+1) pod.Name = fmt.Sprintf("%d", i+1)
} }
// TODO: generate random UID if not present // TODO: generate random UID if not present
if pod.UID == "" && !pod.CreationTimestamp.IsZero() { if pod.UID == "" && !pod.CreationTimestamp.IsZero() {

View File

@@ -44,14 +44,14 @@ func TestEventToPods(t *testing.T) {
input: watch.Event{ input: watch.Event{
Object: &api.BoundPods{ Object: &api.BoundPods{
Items: []api.BoundPod{ Items: []api.BoundPod{
{TypeMeta: api.TypeMeta{ID: "foo"}}, {TypeMeta: api.TypeMeta{Name: "foo"}},
{TypeMeta: api.TypeMeta{ID: "bar"}}, {TypeMeta: api.TypeMeta{Name: "bar"}},
}, },
}, },
}, },
pods: []api.BoundPod{ pods: []api.BoundPod{
{TypeMeta: api.TypeMeta{ID: "foo", Namespace: "default"}, Spec: api.PodSpec{}}, {TypeMeta: api.TypeMeta{Name: "foo", Namespace: "default"}, Spec: api.PodSpec{}},
{TypeMeta: api.TypeMeta{ID: "bar", Namespace: "default"}, Spec: api.PodSpec{}}, {TypeMeta: api.TypeMeta{Name: "bar", Namespace: "default"}, Spec: api.PodSpec{}},
}, },
fail: false, fail: false,
}, },
@@ -59,14 +59,14 @@ func TestEventToPods(t *testing.T) {
input: watch.Event{ input: watch.Event{
Object: &api.BoundPods{ Object: &api.BoundPods{
Items: []api.BoundPod{ Items: []api.BoundPod{
{TypeMeta: api.TypeMeta{ID: "1"}}, {TypeMeta: api.TypeMeta{Name: "1"}},
{TypeMeta: api.TypeMeta{ID: "2", Namespace: "foo"}}, {TypeMeta: api.TypeMeta{Name: "2", Namespace: "foo"}},
}, },
}, },
}, },
pods: []api.BoundPod{ pods: []api.BoundPod{
{TypeMeta: api.TypeMeta{ID: "1", Namespace: "default"}, Spec: api.PodSpec{}}, {TypeMeta: api.TypeMeta{Name: "1", Namespace: "default"}, Spec: api.PodSpec{}},
{TypeMeta: api.TypeMeta{ID: "2", Namespace: "foo"}, Spec: api.PodSpec{}}, {TypeMeta: api.TypeMeta{Name: "2", Namespace: "foo"}, Spec: api.PodSpec{}},
}, },
fail: false, fail: false,
}, },

View File

@@ -153,7 +153,7 @@ func extractFromFile(filename string) (api.BoundPod, error) {
return pod, fmt.Errorf("can't convert pod from file %q: %v", filename, err) return pod, fmt.Errorf("can't convert pod from file %q: %v", filename, err)
} }
pod.ID = simpleSubdomainSafeHash(filename) pod.Name = simpleSubdomainSafeHash(filename)
if len(pod.UID) == 0 { if len(pod.UID) == 0 {
pod.UID = simpleSubdomainSafeHash(filename) pod.UID = simpleSubdomainSafeHash(filename)
} }
@@ -164,7 +164,7 @@ func extractFromFile(filename string) (api.BoundPod, error) {
if glog.V(4) { if glog.V(4) {
glog.Infof("Got pod from file %q: %#v", filename, pod) glog.Infof("Got pod from file %q: %#v", filename, pod)
} else { } else {
glog.V(1).Infof("Got pod from file %q: %s.%s (%s)", filename, pod.Namespace, pod.ID, pod.UID) glog.V(1).Infof("Got pod from file %q: %s.%s (%s)", filename, pod.Namespace, pod.Name, pod.UID)
} }
return pod, nil return pod, nil
} }

View File

@@ -53,7 +53,7 @@ func ExampleManifestAndPod(id string) (api.ContainerManifest, api.BoundPod) {
} }
expectedPod := api.BoundPod{ expectedPod := api.BoundPod{
TypeMeta: api.TypeMeta{ TypeMeta: api.TypeMeta{
ID: id, Name: id,
UID: "uid", UID: "uid",
Namespace: "default", Namespace: "default",
}, },
@@ -119,7 +119,7 @@ func TestReadFromFile(t *testing.T) {
update := got.(kubelet.PodUpdate) update := got.(kubelet.PodUpdate)
expected := CreatePodUpdate(kubelet.SET, api.BoundPod{ expected := CreatePodUpdate(kubelet.SET, api.BoundPod{
TypeMeta: api.TypeMeta{ TypeMeta: api.TypeMeta{
ID: simpleSubdomainSafeHash(file.Name()), Name: simpleSubdomainSafeHash(file.Name()),
UID: simpleSubdomainSafeHash(file.Name()), UID: simpleSubdomainSafeHash(file.Name()),
Namespace: "default", Namespace: "default",
}, },
@@ -159,7 +159,7 @@ func TestExtractFromValidDataFile(t *testing.T) {
file := writeTestFile(t, os.TempDir(), "test_pod_config", string(text)) file := writeTestFile(t, os.TempDir(), "test_pod_config", string(text))
defer os.Remove(file.Name()) defer os.Remove(file.Name())
expectedPod.ID = simpleSubdomainSafeHash(file.Name()) expectedPod.Name = simpleSubdomainSafeHash(file.Name())
ch := make(chan interface{}, 1) ch := make(chan interface{}, 1)
c := SourceFile{file.Name(), ch} c := SourceFile{file.Name(), ch}
@@ -226,7 +226,7 @@ func TestExtractFromDir(t *testing.T) {
} }
ioutil.WriteFile(name, data, 0755) ioutil.WriteFile(name, data, 0755)
files[i] = file files[i] = file
pods[i].ID = simpleSubdomainSafeHash(name) pods[i].Name = simpleSubdomainSafeHash(name)
} }
ch := make(chan interface{}, 1) ch := make(chan interface{}, 1)

View File

@@ -92,8 +92,8 @@ func (s *SourceURL) extractFromURL() error {
if err := api.Scheme.Convert(&manifest, &pod); err != nil { if err := api.Scheme.Convert(&manifest, &pod); err != nil {
return err return err
} }
if len(pod.ID) == 0 { if len(pod.Name) == 0 {
pod.ID = "1" pod.Name = "1"
} }
if len(pod.Namespace) == 0 { if len(pod.Namespace) == 0 {
pod.Namespace = api.NamespaceDefault pod.Namespace = api.NamespaceDefault
@@ -132,8 +132,8 @@ func (s *SourceURL) extractFromURL() error {
} }
for i := range boundPods.Items { for i := range boundPods.Items {
pod := &boundPods.Items[i] pod := &boundPods.Items[i]
if len(pod.ID) == 0 { if len(pod.Name) == 0 {
pod.ID = fmt.Sprintf("%d", i+1) pod.Name = fmt.Sprintf("%d", i+1)
} }
if len(pod.Namespace) == 0 { if len(pod.Namespace) == 0 {
pod.Namespace = api.NamespaceDefault pod.Namespace = api.NamespaceDefault

View File

@@ -125,7 +125,7 @@ func TestExtractFromHTTP(t *testing.T) {
expected: CreatePodUpdate(kubelet.SET, expected: CreatePodUpdate(kubelet.SET,
api.BoundPod{ api.BoundPod{
TypeMeta: api.TypeMeta{ TypeMeta: api.TypeMeta{
ID: "foo", Name: "foo",
Namespace: "default", Namespace: "default",
}, },
Spec: api.PodSpec{ Spec: api.PodSpec{
@@ -142,14 +142,14 @@ func TestExtractFromHTTP(t *testing.T) {
expected: CreatePodUpdate(kubelet.SET, expected: CreatePodUpdate(kubelet.SET,
api.BoundPod{ api.BoundPod{
TypeMeta: api.TypeMeta{ TypeMeta: api.TypeMeta{
ID: "1", Name: "1",
Namespace: "default", Namespace: "default",
}, },
Spec: api.PodSpec{Containers: []api.Container{{Name: "1", Image: "foo"}}}, Spec: api.PodSpec{Containers: []api.Container{{Name: "1", Image: "foo"}}},
}, },
api.BoundPod{ api.BoundPod{
TypeMeta: api.TypeMeta{ TypeMeta: api.TypeMeta{
ID: "bar", Name: "bar",
Namespace: "default", Namespace: "default",
}, },
Spec: api.PodSpec{Containers: []api.Container{{Name: "1", Image: "foo"}}}, Spec: api.PodSpec{Containers: []api.Container{{Name: "1", Image: "foo"}}},

View File

@@ -279,7 +279,7 @@ func milliCPUToShares(milliCPU int) int {
func (kl *Kubelet) mountExternalVolumes(pod *api.BoundPod) (volumeMap, error) { func (kl *Kubelet) mountExternalVolumes(pod *api.BoundPod) (volumeMap, error) {
podVolumes := make(volumeMap) podVolumes := make(volumeMap)
for _, vol := range pod.Spec.Volumes { for _, vol := range pod.Spec.Volumes {
extVolume, err := volume.CreateVolumeBuilder(&vol, pod.ID, kl.rootDirectory) extVolume, err := volume.CreateVolumeBuilder(&vol, pod.Name, kl.rootDirectory)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@@ -334,7 +334,7 @@ func (kl *Kubelet) runContainer(pod *api.BoundPod, container *api.Container, pod
Cmd: container.Command, Cmd: container.Command,
Env: envVariables, Env: envVariables,
ExposedPorts: exposedPorts, ExposedPorts: exposedPorts,
Hostname: pod.ID, Hostname: pod.Name,
Image: container.Image, Image: container.Image,
Memory: int64(container.Memory), Memory: int64(container.Memory),
CpuShares: int64(milliCPUToShares(container.CPU)), CpuShares: int64(milliCPUToShares(container.CPU)),
@@ -609,7 +609,7 @@ func getDesiredVolumes(pods []api.BoundPod) map[string]api.Volume {
desiredVolumes := make(map[string]api.Volume) desiredVolumes := make(map[string]api.Volume)
for _, pod := range pods { for _, pod := range pods {
for _, volume := range pod.Spec.Volumes { for _, volume := range pod.Spec.Volumes {
identifier := path.Join(pod.ID, volume.Name) identifier := path.Join(pod.Name, volume.Name)
desiredVolumes[identifier] = volume desiredVolumes[identifier] = volume
} }
} }

View File

@@ -114,7 +114,7 @@ func TestKillContainer(t *testing.T) {
}, },
} }
fakeDocker.Container = &docker.Container{ fakeDocker.Container = &docker.Container{
ID: "foobar", Name: "foobar",
} }
err := kubelet.killContainer(&fakeDocker.ContainerList[0]) err := kubelet.killContainer(&fakeDocker.ContainerList[0])
@@ -168,7 +168,7 @@ func TestSyncPodsDoesNothing(t *testing.T) {
err := kubelet.SyncPods([]api.BoundPod{ err := kubelet.SyncPods([]api.BoundPod{
{ {
TypeMeta: api.TypeMeta{ TypeMeta: api.TypeMeta{
ID: "foo", Name: "foo",
Namespace: "new", Namespace: "new",
Annotations: map[string]string{ConfigSourceAnnotationKey: "test"}, Annotations: map[string]string{ConfigSourceAnnotationKey: "test"},
}, },
@@ -214,7 +214,7 @@ func TestSyncPodsCreatesNetAndContainer(t *testing.T) {
err := kubelet.SyncPods([]api.BoundPod{ err := kubelet.SyncPods([]api.BoundPod{
{ {
TypeMeta: api.TypeMeta{ TypeMeta: api.TypeMeta{
ID: "foo", Name: "foo",
Namespace: "new", Namespace: "new",
Annotations: map[string]string{ConfigSourceAnnotationKey: "test"}, Annotations: map[string]string{ConfigSourceAnnotationKey: "test"},
}, },
@@ -262,7 +262,7 @@ func TestSyncPodsCreatesNetAndContainerPullsImage(t *testing.T) {
err := kubelet.SyncPods([]api.BoundPod{ err := kubelet.SyncPods([]api.BoundPod{
{ {
TypeMeta: api.TypeMeta{ TypeMeta: api.TypeMeta{
ID: "foo", Name: "foo",
Namespace: "new", Namespace: "new",
Annotations: map[string]string{ConfigSourceAnnotationKey: "test"}, Annotations: map[string]string{ConfigSourceAnnotationKey: "test"},
}, },
@@ -307,7 +307,7 @@ func TestSyncPodsWithNetCreatesContainer(t *testing.T) {
err := kubelet.SyncPods([]api.BoundPod{ err := kubelet.SyncPods([]api.BoundPod{
{ {
TypeMeta: api.TypeMeta{ TypeMeta: api.TypeMeta{
ID: "foo", Name: "foo",
Namespace: "new", Namespace: "new",
Annotations: map[string]string{ConfigSourceAnnotationKey: "test"}, Annotations: map[string]string{ConfigSourceAnnotationKey: "test"},
}, },
@@ -348,7 +348,7 @@ func TestSyncPodsWithNetCreatesContainerCallsHandler(t *testing.T) {
err := kubelet.SyncPods([]api.BoundPod{ err := kubelet.SyncPods([]api.BoundPod{
{ {
TypeMeta: api.TypeMeta{ TypeMeta: api.TypeMeta{
ID: "foo", Name: "foo",
Namespace: "new", Namespace: "new",
Annotations: map[string]string{ConfigSourceAnnotationKey: "test"}, Annotations: map[string]string{ConfigSourceAnnotationKey: "test"},
}, },
@@ -401,7 +401,7 @@ func TestSyncPodsDeletesWithNoNetContainer(t *testing.T) {
err := kubelet.SyncPods([]api.BoundPod{ err := kubelet.SyncPods([]api.BoundPod{
{ {
TypeMeta: api.TypeMeta{ TypeMeta: api.TypeMeta{
ID: "foo", Name: "foo",
Namespace: "new", Namespace: "new",
Annotations: map[string]string{ConfigSourceAnnotationKey: "test"}, Annotations: map[string]string{ConfigSourceAnnotationKey: "test"},
}, },
@@ -496,7 +496,7 @@ func TestSyncPodDeletesDuplicate(t *testing.T) {
} }
err := kubelet.syncPod(&api.BoundPod{ err := kubelet.syncPod(&api.BoundPod{
TypeMeta: api.TypeMeta{ TypeMeta: api.TypeMeta{
ID: "bar", Name: "bar",
Namespace: "new", Namespace: "new",
Annotations: map[string]string{ConfigSourceAnnotationKey: "test"}, Annotations: map[string]string{ConfigSourceAnnotationKey: "test"},
}, },
@@ -545,7 +545,7 @@ func TestSyncPodBadHash(t *testing.T) {
} }
err := kubelet.syncPod(&api.BoundPod{ err := kubelet.syncPod(&api.BoundPod{
TypeMeta: api.TypeMeta{ TypeMeta: api.TypeMeta{
ID: "foo", Name: "foo",
Namespace: "new", Namespace: "new",
Annotations: map[string]string{ConfigSourceAnnotationKey: "test"}, Annotations: map[string]string{ConfigSourceAnnotationKey: "test"},
}, },
@@ -589,7 +589,7 @@ func TestSyncPodUnhealthy(t *testing.T) {
} }
err := kubelet.syncPod(&api.BoundPod{ err := kubelet.syncPod(&api.BoundPod{
TypeMeta: api.TypeMeta{ TypeMeta: api.TypeMeta{
ID: "foo", Name: "foo",
Namespace: "new", Namespace: "new",
Annotations: map[string]string{ConfigSourceAnnotationKey: "test"}, Annotations: map[string]string{ConfigSourceAnnotationKey: "test"},
}, },
@@ -649,7 +649,7 @@ func TestMountExternalVolumes(t *testing.T) {
kubelet, _, _ := newTestKubelet(t) kubelet, _, _ := newTestKubelet(t)
pod := api.BoundPod{ pod := api.BoundPod{
TypeMeta: api.TypeMeta{ TypeMeta: api.TypeMeta{
ID: "foo", Name: "foo",
Namespace: "test", Namespace: "test",
}, },
Spec: api.PodSpec{ Spec: api.PodSpec{
@@ -704,7 +704,7 @@ func TestMakeVolumesAndBinds(t *testing.T) {
pod := api.BoundPod{ pod := api.BoundPod{
TypeMeta: api.TypeMeta{ TypeMeta: api.TypeMeta{
ID: "pod", Name: "pod",
Namespace: "test", Namespace: "test",
}, },
} }
@@ -991,7 +991,7 @@ func TestRunInContainerNoSuchPod(t *testing.T) {
podNamespace := "etcd" podNamespace := "etcd"
containerName := "containerFoo" containerName := "containerFoo"
output, err := kubelet.RunInContainer( output, err := kubelet.RunInContainer(
GetPodFullName(&api.BoundPod{TypeMeta: api.TypeMeta{ID: podName, Namespace: podNamespace}}), GetPodFullName(&api.BoundPod{TypeMeta: api.TypeMeta{Name: podName, Namespace: podNamespace}}),
"", "",
containerName, containerName,
[]string{"ls"}) []string{"ls"})
@@ -1024,7 +1024,7 @@ func TestRunInContainer(t *testing.T) {
_, err := kubelet.RunInContainer( _, err := kubelet.RunInContainer(
GetPodFullName(&api.BoundPod{ GetPodFullName(&api.BoundPod{
TypeMeta: api.TypeMeta{ TypeMeta: api.TypeMeta{
ID: podName, Name: podName,
Namespace: podNamespace, Namespace: podNamespace,
Annotations: map[string]string{ConfigSourceAnnotationKey: "test"}, Annotations: map[string]string{ConfigSourceAnnotationKey: "test"},
}, },
@@ -1033,7 +1033,7 @@ func TestRunInContainer(t *testing.T) {
containerName, containerName,
cmd) cmd)
if fakeCommandRunner.ID != containerID { if fakeCommandRunner.ID != containerID {
t.Errorf("unexected ID: %s", fakeCommandRunner.ID) t.Errorf("unexected Name: %s", fakeCommandRunner.ID)
} }
if !reflect.DeepEqual(fakeCommandRunner.Cmd, cmd) { if !reflect.DeepEqual(fakeCommandRunner.Cmd, cmd) {
t.Errorf("unexpected commnd: %s", fakeCommandRunner.Cmd) t.Errorf("unexpected commnd: %s", fakeCommandRunner.Cmd)
@@ -1166,7 +1166,7 @@ func TestSyncPodEventHandlerFails(t *testing.T) {
} }
err := kubelet.syncPod(&api.BoundPod{ err := kubelet.syncPod(&api.BoundPod{
TypeMeta: api.TypeMeta{ TypeMeta: api.TypeMeta{
ID: "foo", Name: "foo",
Namespace: "new", Namespace: "new",
Annotations: map[string]string{ConfigSourceAnnotationKey: "test"}, Annotations: map[string]string{ConfigSourceAnnotationKey: "test"},
}, },

View File

@@ -73,10 +73,10 @@ func (kl *Kubelet) runOnce(pods []api.BoundPod) (results []RunPodResult, err err
results = append(results, res) results = append(results, res)
if res.Err != nil { if res.Err != nil {
// TODO(proppy): report which containers failed the pod. // TODO(proppy): report which containers failed the pod.
glog.Infof("failed to start pod %q: %v", res.Pod.ID, res.Err) glog.Infof("failed to start pod %q: %v", res.Pod.Name, res.Err)
failedPods = append(failedPods, res.Pod.ID) failedPods = append(failedPods, res.Pod.Name)
} else { } else {
glog.Infof("started pod %q", res.Pod.ID) glog.Infof("started pod %q", res.Pod.Name)
} }
} }
if len(failedPods) > 0 { if len(failedPods) > 0 {
@@ -100,18 +100,18 @@ func (kl *Kubelet) runPod(pod api.BoundPod) error {
return fmt.Errorf("failed to check pod status: %v", err) return fmt.Errorf("failed to check pod status: %v", err)
} }
if running { if running {
glog.Infof("pod %q containers running", pod.ID) glog.Infof("pod %q containers running", pod.Name)
return nil return nil
} }
glog.Infof("pod %q containers not running: syncing", pod.ID) glog.Infof("pod %q containers not running: syncing", pod.Name)
if err = kl.syncPod(&pod, dockerContainers); err != nil { if err = kl.syncPod(&pod, dockerContainers); err != nil {
return fmt.Errorf("error syncing pod: %v", err) return fmt.Errorf("error syncing pod: %v", err)
} }
if retry >= RunOnceMaxRetries { if retry >= RunOnceMaxRetries {
return fmt.Errorf("timeout error: pod %q containers not running after %d retries", pod.ID, RunOnceMaxRetries) return fmt.Errorf("timeout error: pod %q containers not running after %d retries", pod.Name, RunOnceMaxRetries)
} }
// TODO(proppy): health checking would be better than waiting + checking the state at the next iteration. // TODO(proppy): health checking would be better than waiting + checking the state at the next iteration.
glog.Infof("pod %q containers synced, waiting for %v", pod.ID, delay) glog.Infof("pod %q containers synced, waiting for %v", pod.Name, delay)
<-time.After(delay) <-time.After(delay)
retry++ retry++
delay *= RunOnceRetryDelayBackoff delay *= RunOnceRetryDelayBackoff

View File

@@ -109,7 +109,7 @@ func TestRunOnce(t *testing.T) {
results, err := kb.runOnce([]api.BoundPod{ results, err := kb.runOnce([]api.BoundPod{
{ {
TypeMeta: api.TypeMeta{ TypeMeta: api.TypeMeta{
ID: "foo", Name: "foo",
Namespace: "new", Namespace: "new",
Annotations: map[string]string{ConfigSourceAnnotationKey: "test"}, Annotations: map[string]string{ConfigSourceAnnotationKey: "test"},
}, },
@@ -126,7 +126,7 @@ func TestRunOnce(t *testing.T) {
if results[0].Err != nil { if results[0].Err != nil {
t.Errorf("unexpected run pod error: %v", results[0].Err) t.Errorf("unexpected run pod error: %v", results[0].Err)
} }
if results[0].Pod.ID != "foo" { if results[0].Pod.Name != "foo" {
t.Errorf("unexpected pod: %q", results[0].Pod.ID) t.Errorf("unexpected pod: %q", results[0].Pod.Name)
} }
} }

View File

@@ -126,14 +126,14 @@ func (s *Server) handleContainer(w http.ResponseWriter, req *http.Request) {
s.error(w, err) s.error(w, err)
return return
} }
pod.ID = containerManifest.ID pod.Name = containerManifest.ID
pod.UID = containerManifest.UUID pod.UID = containerManifest.UUID
pod.Spec.Containers = containerManifest.Containers pod.Spec.Containers = containerManifest.Containers
pod.Spec.Volumes = containerManifest.Volumes pod.Spec.Volumes = containerManifest.Volumes
pod.Spec.RestartPolicy = containerManifest.RestartPolicy pod.Spec.RestartPolicy = containerManifest.RestartPolicy
//TODO: sha1 of manifest? //TODO: sha1 of manifest?
if pod.ID == "" { if pod.Name == "" {
pod.ID = "1" pod.Name = "1"
} }
if pod.UID == "" { if pod.UID == "" {
pod.UID = "1" pod.UID = "1"
@@ -158,7 +158,7 @@ func (s *Server) handleContainers(w http.ResponseWriter, req *http.Request) {
} }
pods := make([]api.BoundPod, len(specs)) pods := make([]api.BoundPod, len(specs))
for i := range specs { for i := range specs {
pods[i].ID = fmt.Sprintf("%d", i+1) pods[i].Name = fmt.Sprintf("%d", i+1)
pods[i].Spec = specs[i] pods[i].Spec = specs[i]
} }
s.updates <- PodUpdate{pods, SET} s.updates <- PodUpdate{pods, SET}
@@ -205,7 +205,7 @@ func (s *Server) handleContainerLogs(w http.ResponseWriter, req *http.Request) {
podFullName := GetPodFullName(&api.BoundPod{ podFullName := GetPodFullName(&api.BoundPod{
TypeMeta: api.TypeMeta{ TypeMeta: api.TypeMeta{
ID: podID, Name: podID,
Namespace: podNamespace, Namespace: podNamespace,
Annotations: map[string]string{ConfigSourceAnnotationKey: "etcd"}, Annotations: map[string]string{ConfigSourceAnnotationKey: "etcd"},
}, },
@@ -249,7 +249,7 @@ func (s *Server) handlePodInfo(w http.ResponseWriter, req *http.Request) {
// TODO: backwards compatibility with existing API, needs API change // TODO: backwards compatibility with existing API, needs API change
podFullName := GetPodFullName(&api.BoundPod{ podFullName := GetPodFullName(&api.BoundPod{
TypeMeta: api.TypeMeta{ TypeMeta: api.TypeMeta{
ID: podID, Name: podID,
Namespace: podNamespace, Namespace: podNamespace,
Annotations: map[string]string{ConfigSourceAnnotationKey: "etcd"}, Annotations: map[string]string{ConfigSourceAnnotationKey: "etcd"},
}, },
@@ -324,7 +324,7 @@ func (s *Server) handleRun(w http.ResponseWriter, req *http.Request) {
} }
podFullName := GetPodFullName(&api.BoundPod{ podFullName := GetPodFullName(&api.BoundPod{
TypeMeta: api.TypeMeta{ TypeMeta: api.TypeMeta{
ID: podID, Name: podID,
Namespace: podNamespace, Namespace: podNamespace,
Annotations: map[string]string{ConfigSourceAnnotationKey: "etcd"}, Annotations: map[string]string{ConfigSourceAnnotationKey: "etcd"},
}, },
@@ -374,7 +374,7 @@ func (s *Server) serveStats(w http.ResponseWriter, req *http.Request) {
// Backward compatibility without uuid information // Backward compatibility without uuid information
podFullName := GetPodFullName(&api.BoundPod{ podFullName := GetPodFullName(&api.BoundPod{
TypeMeta: api.TypeMeta{ TypeMeta: api.TypeMeta{
ID: components[1], Name: components[1],
// TODO: I am broken // TODO: I am broken
Namespace: api.NamespaceDefault, Namespace: api.NamespaceDefault,
Annotations: map[string]string{ConfigSourceAnnotationKey: "etcd"}, Annotations: map[string]string{ConfigSourceAnnotationKey: "etcd"},
@@ -384,7 +384,7 @@ func (s *Server) serveStats(w http.ResponseWriter, req *http.Request) {
case 4: case 4:
podFullName := GetPodFullName(&api.BoundPod{ podFullName := GetPodFullName(&api.BoundPod{
TypeMeta: api.TypeMeta{ TypeMeta: api.TypeMeta{
ID: components[1], Name: components[1],
// TODO: I am broken // TODO: I am broken
Namespace: "", Namespace: "",
Annotations: map[string]string{ConfigSourceAnnotationKey: "etcd"}, Annotations: map[string]string{ConfigSourceAnnotationKey: "etcd"},

View File

@@ -133,8 +133,8 @@ func TestContainer(t *testing.T) {
expectedPods := []api.BoundPod{ expectedPods := []api.BoundPod{
{ {
TypeMeta: api.TypeMeta{ TypeMeta: api.TypeMeta{
ID: "test_manifest", Name: "test_manifest",
UID: "value", UID: "value",
}, },
Spec: api.PodSpec{ Spec: api.PodSpec{
Containers: []api.Container{ Containers: []api.Container{
@@ -208,7 +208,7 @@ func TestContainers(t *testing.T) {
expectedPods := []api.BoundPod{ expectedPods := []api.BoundPod{
{ {
TypeMeta: api.TypeMeta{ TypeMeta: api.TypeMeta{
ID: "1", Name: "1",
}, },
Spec: api.PodSpec{ Spec: api.PodSpec{
Containers: []api.Container{ Containers: []api.Container{
@@ -228,7 +228,7 @@ func TestContainers(t *testing.T) {
}, },
{ {
TypeMeta: api.TypeMeta{ TypeMeta: api.TypeMeta{
ID: "2", Name: "2",
}, },
Spec: api.PodSpec{ Spec: api.PodSpec{
Containers: []api.Container{ Containers: []api.Container{

View File

@@ -50,5 +50,5 @@ type PodUpdate struct {
// GetPodFullName returns a name that uniquely identifies a pod across all config sources. // GetPodFullName returns a name that uniquely identifies a pod across all config sources.
func GetPodFullName(pod *api.BoundPod) string { func GetPodFullName(pod *api.BoundPod) string {
return fmt.Sprintf("%s.%s.%s", pod.ID, pod.Namespace, pod.Annotations[ConfigSourceAnnotationKey]) return fmt.Sprintf("%s.%s.%s", pod.Name, pod.Namespace, pod.Annotations[ConfigSourceAnnotationKey])
} }

View File

@@ -126,7 +126,7 @@ func (m *Master) init(c *Config) {
} else { } else {
for _, minionID := range c.Minions { for _, minionID := range c.Minions {
m.minionRegistry.CreateMinion(nil, &api.Minion{ m.minionRegistry.CreateMinion(nil, &api.Minion{
TypeMeta: api.TypeMeta{ID: minionID}, TypeMeta: api.TypeMeta{Name: minionID},
NodeResources: c.NodeResources, NodeResources: c.NodeResources,
}) })
} }

View File

@@ -87,7 +87,7 @@ func (p *PodCache) UpdateAllContainers() {
if pod.CurrentState.Host == "" { if pod.CurrentState.Host == "" {
continue continue
} }
err := p.updatePodInfo(pod.CurrentState.Host, pod.Namespace, pod.ID) err := p.updatePodInfo(pod.CurrentState.Host, pod.Namespace, pod.Name)
if err != nil && err != client.ErrPodInfoNotAvailable { if err != nil && err != client.ErrPodInfoNotAvailable {
glog.Errorf("Error synchronizing container: %v", err) glog.Errorf("Error synchronizing container: %v", err)
} }

View File

@@ -124,7 +124,7 @@ func TestPodGetPodInfoGetter(t *testing.T) {
func TestPodUpdateAllContainers(t *testing.T) { func TestPodUpdateAllContainers(t *testing.T) {
pod := api.Pod{ pod := api.Pod{
TypeMeta: api.TypeMeta{ID: "foo", Namespace: api.NamespaceDefault}, TypeMeta: api.TypeMeta{Name: "foo", Namespace: api.NamespaceDefault},
CurrentState: api.PodState{ CurrentState: api.PodState{
Host: "machine", Host: "machine",
}, },

View File

@@ -27,7 +27,7 @@ import (
) )
func TestServices(t *testing.T) { func TestServices(t *testing.T) {
service := api.Service{TypeMeta: api.TypeMeta{ID: "bar", ResourceVersion: "2"}} service := api.Service{TypeMeta: api.TypeMeta{Name: "bar", ResourceVersion: "2"}}
fakeWatch := watch.NewFake() fakeWatch := watch.NewFake()
fakeClient := &client.Fake{Watch: fakeWatch} fakeClient := &client.Fake{Watch: fakeWatch}
@@ -72,7 +72,7 @@ func TestServices(t *testing.T) {
} }
func TestServicesFromZero(t *testing.T) { func TestServicesFromZero(t *testing.T) {
service := api.Service{TypeMeta: api.TypeMeta{ID: "bar", ResourceVersion: "2"}} service := api.Service{TypeMeta: api.TypeMeta{Name: "bar", ResourceVersion: "2"}}
fakeWatch := watch.NewFake() fakeWatch := watch.NewFake()
fakeWatch.Stop() fakeWatch.Stop()
@@ -152,7 +152,7 @@ func TestServicesFromZeroError(t *testing.T) {
} }
func TestEndpoints(t *testing.T) { func TestEndpoints(t *testing.T) {
endpoint := api.Endpoints{TypeMeta: api.TypeMeta{ID: "bar", ResourceVersion: "2"}, Endpoints: []string{"127.0.0.1:9000"}} endpoint := api.Endpoints{TypeMeta: api.TypeMeta{Name: "bar", ResourceVersion: "2"}, Endpoints: []string{"127.0.0.1:9000"}}
fakeWatch := watch.NewFake() fakeWatch := watch.NewFake()
fakeClient := &client.Fake{Watch: fakeWatch} fakeClient := &client.Fake{Watch: fakeWatch}
@@ -197,7 +197,7 @@ func TestEndpoints(t *testing.T) {
} }
func TestEndpointsFromZero(t *testing.T) { func TestEndpointsFromZero(t *testing.T) {
endpoint := api.Endpoints{TypeMeta: api.TypeMeta{ID: "bar", ResourceVersion: "2"}, Endpoints: []string{"127.0.0.1:9000"}} endpoint := api.Endpoints{TypeMeta: api.TypeMeta{Name: "bar", ResourceVersion: "2"}, Endpoints: []string{"127.0.0.1:9000"}}
fakeWatch := watch.NewFake() fakeWatch := watch.NewFake()
fakeWatch.Stop() fakeWatch.Stop()

View File

@@ -127,19 +127,19 @@ func (s *endpointsStore) Merge(source string, change interface{}) error {
case ADD: case ADD:
glog.V(4).Infof("Adding new endpoint from source %s : %v", source, update.Endpoints) glog.V(4).Infof("Adding new endpoint from source %s : %v", source, update.Endpoints)
for _, value := range update.Endpoints { for _, value := range update.Endpoints {
endpoints[value.ID] = value endpoints[value.Name] = value
} }
case REMOVE: case REMOVE:
glog.V(4).Infof("Removing an endpoint %v", update) glog.V(4).Infof("Removing an endpoint %v", update)
for _, value := range update.Endpoints { for _, value := range update.Endpoints {
delete(endpoints, value.ID) delete(endpoints, value.Name)
} }
case SET: case SET:
glog.V(4).Infof("Setting endpoints %v", update) glog.V(4).Infof("Setting endpoints %v", update)
// Clear the old map entries by just creating a new map // Clear the old map entries by just creating a new map
endpoints = make(map[string]api.Endpoints) endpoints = make(map[string]api.Endpoints)
for _, value := range update.Endpoints { for _, value := range update.Endpoints {
endpoints[value.ID] = value endpoints[value.Name] = value
} }
default: default:
glog.V(4).Infof("Received invalid update type: %v", update) glog.V(4).Infof("Received invalid update type: %v", update)
@@ -222,19 +222,19 @@ func (s *serviceStore) Merge(source string, change interface{}) error {
case ADD: case ADD:
glog.V(4).Infof("Adding new service from source %s : %v", source, update.Services) glog.V(4).Infof("Adding new service from source %s : %v", source, update.Services)
for _, value := range update.Services { for _, value := range update.Services {
services[value.ID] = value services[value.Name] = value
} }
case REMOVE: case REMOVE:
glog.V(4).Infof("Removing a service %v", update) glog.V(4).Infof("Removing a service %v", update)
for _, value := range update.Services { for _, value := range update.Services {
delete(services, value.ID) delete(services, value.Name)
} }
case SET: case SET:
glog.V(4).Infof("Setting services %v", update) glog.V(4).Infof("Setting services %v", update)
// Clear the old map entries by just creating a new map // Clear the old map entries by just creating a new map
services = make(map[string]api.Service) services = make(map[string]api.Service)
for _, value := range update.Services { for _, value := range update.Services {
services[value.ID] = value services[value.Name] = value
} }
default: default:
glog.V(4).Infof("Received invalid update type: %v", update) glog.V(4).Infof("Received invalid update type: %v", update)

View File

@@ -45,7 +45,7 @@ func (s sortedServices) Swap(i, j int) {
s[i], s[j] = s[j], s[i] s[i], s[j] = s[j], s[i]
} }
func (s sortedServices) Less(i, j int) bool { func (s sortedServices) Less(i, j int) bool {
return s[i].TypeMeta.ID < s[j].TypeMeta.ID return s[i].Name < s[j].Name
} }
type ServiceHandlerMock struct { type ServiceHandlerMock struct {
@@ -83,7 +83,7 @@ func (s sortedEndpoints) Swap(i, j int) {
s[i], s[j] = s[j], s[i] s[i], s[j] = s[j], s[i]
} }
func (s sortedEndpoints) Less(i, j int) bool { func (s sortedEndpoints) Less(i, j int) bool {
return s[i].ID < s[j].ID return s[i].Name < s[j].Name
} }
type EndpointsHandlerMock struct { type EndpointsHandlerMock struct {
@@ -136,7 +136,7 @@ func TestNewServiceAddedAndNotified(t *testing.T) {
handler := NewServiceHandlerMock() handler := NewServiceHandlerMock()
handler.Wait(1) handler.Wait(1)
config.RegisterHandler(handler) config.RegisterHandler(handler)
serviceUpdate := CreateServiceUpdate(ADD, api.Service{TypeMeta: api.TypeMeta{ID: "foo"}, Port: 10}) serviceUpdate := CreateServiceUpdate(ADD, api.Service{TypeMeta: api.TypeMeta{Name: "foo"}, Port: 10})
channel <- serviceUpdate channel <- serviceUpdate
handler.ValidateServices(t, serviceUpdate.Services) handler.ValidateServices(t, serviceUpdate.Services)
@@ -147,24 +147,24 @@ func TestServiceAddedRemovedSetAndNotified(t *testing.T) {
channel := config.Channel("one") channel := config.Channel("one")
handler := NewServiceHandlerMock() handler := NewServiceHandlerMock()
config.RegisterHandler(handler) config.RegisterHandler(handler)
serviceUpdate := CreateServiceUpdate(ADD, api.Service{TypeMeta: api.TypeMeta{ID: "foo"}, Port: 10}) serviceUpdate := CreateServiceUpdate(ADD, api.Service{TypeMeta: api.TypeMeta{Name: "foo"}, Port: 10})
handler.Wait(1) handler.Wait(1)
channel <- serviceUpdate channel <- serviceUpdate
handler.ValidateServices(t, serviceUpdate.Services) handler.ValidateServices(t, serviceUpdate.Services)
serviceUpdate2 := CreateServiceUpdate(ADD, api.Service{TypeMeta: api.TypeMeta{ID: "bar"}, Port: 20}) serviceUpdate2 := CreateServiceUpdate(ADD, api.Service{TypeMeta: api.TypeMeta{Name: "bar"}, Port: 20})
handler.Wait(1) handler.Wait(1)
channel <- serviceUpdate2 channel <- serviceUpdate2
services := []api.Service{serviceUpdate2.Services[0], serviceUpdate.Services[0]} services := []api.Service{serviceUpdate2.Services[0], serviceUpdate.Services[0]}
handler.ValidateServices(t, services) handler.ValidateServices(t, services)
serviceUpdate3 := CreateServiceUpdate(REMOVE, api.Service{TypeMeta: api.TypeMeta{ID: "foo"}}) serviceUpdate3 := CreateServiceUpdate(REMOVE, api.Service{TypeMeta: api.TypeMeta{Name: "foo"}})
handler.Wait(1) handler.Wait(1)
channel <- serviceUpdate3 channel <- serviceUpdate3
services = []api.Service{serviceUpdate2.Services[0]} services = []api.Service{serviceUpdate2.Services[0]}
handler.ValidateServices(t, services) handler.ValidateServices(t, services)
serviceUpdate4 := CreateServiceUpdate(SET, api.Service{TypeMeta: api.TypeMeta{ID: "foobar"}, Port: 99}) serviceUpdate4 := CreateServiceUpdate(SET, api.Service{TypeMeta: api.TypeMeta{Name: "foobar"}, Port: 99})
handler.Wait(1) handler.Wait(1)
channel <- serviceUpdate4 channel <- serviceUpdate4
services = []api.Service{serviceUpdate4.Services[0]} services = []api.Service{serviceUpdate4.Services[0]}
@@ -180,8 +180,8 @@ func TestNewMultipleSourcesServicesAddedAndNotified(t *testing.T) {
} }
handler := NewServiceHandlerMock() handler := NewServiceHandlerMock()
config.RegisterHandler(handler) config.RegisterHandler(handler)
serviceUpdate1 := CreateServiceUpdate(ADD, api.Service{TypeMeta: api.TypeMeta{ID: "foo"}, Port: 10}) serviceUpdate1 := CreateServiceUpdate(ADD, api.Service{TypeMeta: api.TypeMeta{Name: "foo"}, Port: 10})
serviceUpdate2 := CreateServiceUpdate(ADD, api.Service{TypeMeta: api.TypeMeta{ID: "bar"}, Port: 20}) serviceUpdate2 := CreateServiceUpdate(ADD, api.Service{TypeMeta: api.TypeMeta{Name: "bar"}, Port: 20})
handler.Wait(2) handler.Wait(2)
channelOne <- serviceUpdate1 channelOne <- serviceUpdate1
channelTwo <- serviceUpdate2 channelTwo <- serviceUpdate2
@@ -197,8 +197,8 @@ func TestNewMultipleSourcesServicesMultipleHandlersAddedAndNotified(t *testing.T
handler2 := NewServiceHandlerMock() handler2 := NewServiceHandlerMock()
config.RegisterHandler(handler) config.RegisterHandler(handler)
config.RegisterHandler(handler2) config.RegisterHandler(handler2)
serviceUpdate1 := CreateServiceUpdate(ADD, api.Service{TypeMeta: api.TypeMeta{ID: "foo"}, Port: 10}) serviceUpdate1 := CreateServiceUpdate(ADD, api.Service{TypeMeta: api.TypeMeta{Name: "foo"}, Port: 10})
serviceUpdate2 := CreateServiceUpdate(ADD, api.Service{TypeMeta: api.TypeMeta{ID: "bar"}, Port: 20}) serviceUpdate2 := CreateServiceUpdate(ADD, api.Service{TypeMeta: api.TypeMeta{Name: "bar"}, Port: 20})
handler.Wait(2) handler.Wait(2)
handler2.Wait(2) handler2.Wait(2)
channelOne <- serviceUpdate1 channelOne <- serviceUpdate1
@@ -217,11 +217,11 @@ func TestNewMultipleSourcesEndpointsMultipleHandlersAddedAndNotified(t *testing.
config.RegisterHandler(handler) config.RegisterHandler(handler)
config.RegisterHandler(handler2) config.RegisterHandler(handler2)
endpointsUpdate1 := CreateEndpointsUpdate(ADD, api.Endpoints{ endpointsUpdate1 := CreateEndpointsUpdate(ADD, api.Endpoints{
TypeMeta: api.TypeMeta{ID: "foo"}, TypeMeta: api.TypeMeta{Name: "foo"},
Endpoints: []string{"endpoint1", "endpoint2"}, Endpoints: []string{"endpoint1", "endpoint2"},
}) })
endpointsUpdate2 := CreateEndpointsUpdate(ADD, api.Endpoints{ endpointsUpdate2 := CreateEndpointsUpdate(ADD, api.Endpoints{
TypeMeta: api.TypeMeta{ID: "bar"}, TypeMeta: api.TypeMeta{Name: "bar"},
Endpoints: []string{"endpoint3", "endpoint4"}, Endpoints: []string{"endpoint3", "endpoint4"},
}) })
handler.Wait(2) handler.Wait(2)
@@ -243,11 +243,11 @@ func TestNewMultipleSourcesEndpointsMultipleHandlersAddRemoveSetAndNotified(t *t
config.RegisterHandler(handler) config.RegisterHandler(handler)
config.RegisterHandler(handler2) config.RegisterHandler(handler2)
endpointsUpdate1 := CreateEndpointsUpdate(ADD, api.Endpoints{ endpointsUpdate1 := CreateEndpointsUpdate(ADD, api.Endpoints{
TypeMeta: api.TypeMeta{ID: "foo"}, TypeMeta: api.TypeMeta{Name: "foo"},
Endpoints: []string{"endpoint1", "endpoint2"}, Endpoints: []string{"endpoint1", "endpoint2"},
}) })
endpointsUpdate2 := CreateEndpointsUpdate(ADD, api.Endpoints{ endpointsUpdate2 := CreateEndpointsUpdate(ADD, api.Endpoints{
TypeMeta: api.TypeMeta{ID: "bar"}, TypeMeta: api.TypeMeta{Name: "bar"},
Endpoints: []string{"endpoint3", "endpoint4"}, Endpoints: []string{"endpoint3", "endpoint4"},
}) })
handler.Wait(2) handler.Wait(2)
@@ -261,7 +261,7 @@ func TestNewMultipleSourcesEndpointsMultipleHandlersAddRemoveSetAndNotified(t *t
// Add one more // Add one more
endpointsUpdate3 := CreateEndpointsUpdate(ADD, api.Endpoints{ endpointsUpdate3 := CreateEndpointsUpdate(ADD, api.Endpoints{
TypeMeta: api.TypeMeta{ID: "foobar"}, TypeMeta: api.TypeMeta{Name: "foobar"},
Endpoints: []string{"endpoint5", "endpoint6"}, Endpoints: []string{"endpoint5", "endpoint6"},
}) })
handler.Wait(1) handler.Wait(1)
@@ -273,7 +273,7 @@ func TestNewMultipleSourcesEndpointsMultipleHandlersAddRemoveSetAndNotified(t *t
// Update the "foo" service with new endpoints // Update the "foo" service with new endpoints
endpointsUpdate1 = CreateEndpointsUpdate(ADD, api.Endpoints{ endpointsUpdate1 = CreateEndpointsUpdate(ADD, api.Endpoints{
TypeMeta: api.TypeMeta{ID: "foo"}, TypeMeta: api.TypeMeta{Name: "foo"},
Endpoints: []string{"endpoint77"}, Endpoints: []string{"endpoint77"},
}) })
handler.Wait(1) handler.Wait(1)
@@ -284,7 +284,7 @@ func TestNewMultipleSourcesEndpointsMultipleHandlersAddRemoveSetAndNotified(t *t
handler2.ValidateEndpoints(t, endpoints) handler2.ValidateEndpoints(t, endpoints)
// Remove "bar" service // Remove "bar" service
endpointsUpdate2 = CreateEndpointsUpdate(REMOVE, api.Endpoints{TypeMeta: api.TypeMeta{ID: "bar"}}) endpointsUpdate2 = CreateEndpointsUpdate(REMOVE, api.Endpoints{TypeMeta: api.TypeMeta{Name: "bar"}})
handler.Wait(1) handler.Wait(1)
handler2.Wait(1) handler2.Wait(1)
channelTwo <- endpointsUpdate2 channelTwo <- endpointsUpdate2

View File

@@ -140,15 +140,15 @@ func (s ConfigSourceEtcd) decodeServices(node *etcd.Node, retServices []api.Serv
// so we got a service we can handle, and now get endpoints // so we got a service we can handle, and now get endpoints
retServices = append(retServices, svc) retServices = append(retServices, svc)
// get the endpoints // get the endpoints
endpoints, err := s.GetEndpoints(svc.Namespace, svc.ID) endpoints, err := s.GetEndpoints(svc.Namespace, svc.Name)
if err != nil { if err != nil {
if tools.IsEtcdNotFound(err) { if tools.IsEtcdNotFound(err) {
glog.V(4).Infof("Unable to get endpoints for %s %s : %v", svc.Namespace, svc.ID, err) glog.V(4).Infof("Unable to get endpoints for %s %s : %v", svc.Namespace, svc.Name, err)
} }
glog.Errorf("Couldn't get endpoints for %s %s : %v skipping", svc.Namespace, svc.ID, err) glog.Errorf("Couldn't get endpoints for %s %s : %v skipping", svc.Namespace, svc.Name, err)
endpoints = api.Endpoints{} endpoints = api.Endpoints{}
} else { } else {
glog.V(3).Infof("Got service: %s %s on localport %d mapping to: %s", svc.Namespace, svc.ID, svc.Port, endpoints) glog.V(3).Infof("Got service: %s %s on localport %d mapping to: %s", svc.Namespace, svc.Name, svc.Port, endpoints)
} }
retEndpoints = append(retEndpoints, endpoints) retEndpoints = append(retEndpoints, endpoints)
} }
@@ -243,7 +243,7 @@ func (s ConfigSourceEtcd) ProcessChange(response *etcd.Response) {
parts := strings.Split(response.Node.Key[1:], "/") parts := strings.Split(response.Node.Key[1:], "/")
if len(parts) == 4 { if len(parts) == 4 {
glog.V(4).Infof("Deleting service: %s", parts[3]) glog.V(4).Infof("Deleting service: %s", parts[3])
serviceUpdate := ServiceUpdate{Op: REMOVE, Services: []api.Service{{TypeMeta: api.TypeMeta{ID: parts[3]}}}} serviceUpdate := ServiceUpdate{Op: REMOVE, Services: []api.Service{{TypeMeta: api.TypeMeta{Name: parts[3]}}}}
s.serviceChannel <- serviceUpdate s.serviceChannel <- serviceUpdate
return return
} }

View File

@@ -433,35 +433,35 @@ func (proxier *Proxier) OnUpdate(services []api.Service) {
glog.V(4).Infof("Received update notice: %+v", services) glog.V(4).Infof("Received update notice: %+v", services)
activeServices := util.StringSet{} activeServices := util.StringSet{}
for _, service := range services { for _, service := range services {
activeServices.Insert(service.ID) activeServices.Insert(service.Name)
info, exists := proxier.getServiceInfo(service.ID) info, exists := proxier.getServiceInfo(service.Name)
serviceIP := net.ParseIP(service.PortalIP) serviceIP := net.ParseIP(service.PortalIP)
// TODO: check health of the socket? What if ProxyLoop exited? // TODO: check health of the socket? What if ProxyLoop exited?
if exists && info.isActive() && info.portalPort == service.Port && info.portalIP.Equal(serviceIP) { if exists && info.isActive() && info.portalPort == service.Port && info.portalIP.Equal(serviceIP) {
continue continue
} }
if exists && (info.portalPort != service.Port || !info.portalIP.Equal(serviceIP)) { if exists && (info.portalPort != service.Port || !info.portalIP.Equal(serviceIP)) {
glog.V(4).Infof("Something changed for service %q: stopping it", service.ID) glog.V(4).Infof("Something changed for service %q: stopping it", service.Name)
err := proxier.closePortal(service.ID, info) err := proxier.closePortal(service.Name, info)
if err != nil { if err != nil {
glog.Errorf("Failed to close portal for %q: %s", service.ID, err) glog.Errorf("Failed to close portal for %q: %s", service.Name, err)
} }
err = proxier.stopProxy(service.ID, info) err = proxier.stopProxy(service.Name, info)
if err != nil { if err != nil {
glog.Errorf("Failed to stop service %q: %s", service.ID, err) glog.Errorf("Failed to stop service %q: %s", service.Name, err)
} }
} }
glog.V(1).Infof("Adding new service %q at %s:%d/%s (local :%d)", service.ID, serviceIP, service.Port, service.Protocol, service.ProxyPort) glog.V(1).Infof("Adding new service %q at %s:%d/%s (local :%d)", service.Name, serviceIP, service.Port, service.Protocol, service.ProxyPort)
info, err := proxier.addServiceOnPort(service.ID, service.Protocol, service.ProxyPort, udpIdleTimeout) info, err := proxier.addServiceOnPort(service.Name, service.Protocol, service.ProxyPort, udpIdleTimeout)
if err != nil { if err != nil {
glog.Errorf("Failed to start proxy for %q: %+v", service.ID, err) glog.Errorf("Failed to start proxy for %q: %+v", service.Name, err)
continue continue
} }
info.portalIP = serviceIP info.portalIP = serviceIP
info.portalPort = service.Port info.portalPort = service.Port
err = proxier.openPortal(service.ID, info) err = proxier.openPortal(service.Name, info)
if err != nil { if err != nil {
glog.Errorf("Failed to open portal for %q: %s", service.ID, err) glog.Errorf("Failed to open portal for %q: %s", service.Name, err)
} }
} }
proxier.mu.Lock() proxier.mu.Lock()

View File

@@ -163,7 +163,7 @@ func TestTCPProxy(t *testing.T) {
lb := NewLoadBalancerRR() lb := NewLoadBalancerRR()
lb.OnUpdate([]api.Endpoints{ lb.OnUpdate([]api.Endpoints{
{ {
TypeMeta: api.TypeMeta{ID: "echo"}, TypeMeta: api.TypeMeta{Name: "echo"},
Endpoints: []string{net.JoinHostPort("127.0.0.1", tcpServerPort)}, Endpoints: []string{net.JoinHostPort("127.0.0.1", tcpServerPort)},
}, },
}) })
@@ -181,7 +181,7 @@ func TestUDPProxy(t *testing.T) {
lb := NewLoadBalancerRR() lb := NewLoadBalancerRR()
lb.OnUpdate([]api.Endpoints{ lb.OnUpdate([]api.Endpoints{
{ {
TypeMeta: api.TypeMeta{ID: "echo"}, TypeMeta: api.TypeMeta{Name: "echo"},
Endpoints: []string{net.JoinHostPort("127.0.0.1", udpServerPort)}, Endpoints: []string{net.JoinHostPort("127.0.0.1", udpServerPort)},
}, },
}) })
@@ -208,7 +208,7 @@ func TestTCPProxyStop(t *testing.T) {
lb := NewLoadBalancerRR() lb := NewLoadBalancerRR()
lb.OnUpdate([]api.Endpoints{ lb.OnUpdate([]api.Endpoints{
{ {
TypeMeta: api.TypeMeta{ID: "echo"}, TypeMeta: api.TypeMeta{Name: "echo"},
Endpoints: []string{net.JoinHostPort("127.0.0.1", tcpServerPort)}, Endpoints: []string{net.JoinHostPort("127.0.0.1", tcpServerPort)},
}, },
}) })
@@ -236,7 +236,7 @@ func TestUDPProxyStop(t *testing.T) {
lb := NewLoadBalancerRR() lb := NewLoadBalancerRR()
lb.OnUpdate([]api.Endpoints{ lb.OnUpdate([]api.Endpoints{
{ {
TypeMeta: api.TypeMeta{ID: "echo"}, TypeMeta: api.TypeMeta{Name: "echo"},
Endpoints: []string{net.JoinHostPort("127.0.0.1", udpServerPort)}, Endpoints: []string{net.JoinHostPort("127.0.0.1", udpServerPort)},
}, },
}) })
@@ -264,7 +264,7 @@ func TestTCPProxyUpdateDelete(t *testing.T) {
lb := NewLoadBalancerRR() lb := NewLoadBalancerRR()
lb.OnUpdate([]api.Endpoints{ lb.OnUpdate([]api.Endpoints{
{ {
TypeMeta: api.TypeMeta{ID: "echo"}, TypeMeta: api.TypeMeta{Name: "echo"},
Endpoints: []string{net.JoinHostPort("127.0.0.1", tcpServerPort)}, Endpoints: []string{net.JoinHostPort("127.0.0.1", tcpServerPort)},
}, },
}) })
@@ -291,7 +291,7 @@ func TestUDPProxyUpdateDelete(t *testing.T) {
lb := NewLoadBalancerRR() lb := NewLoadBalancerRR()
lb.OnUpdate([]api.Endpoints{ lb.OnUpdate([]api.Endpoints{
{ {
TypeMeta: api.TypeMeta{ID: "echo"}, TypeMeta: api.TypeMeta{Name: "echo"},
Endpoints: []string{net.JoinHostPort("127.0.0.1", udpServerPort)}, Endpoints: []string{net.JoinHostPort("127.0.0.1", udpServerPort)},
}, },
}) })
@@ -318,7 +318,7 @@ func TestTCPProxyUpdateDeleteUpdate(t *testing.T) {
lb := NewLoadBalancerRR() lb := NewLoadBalancerRR()
lb.OnUpdate([]api.Endpoints{ lb.OnUpdate([]api.Endpoints{
{ {
TypeMeta: api.TypeMeta{ID: "echo"}, TypeMeta: api.TypeMeta{Name: "echo"},
Endpoints: []string{net.JoinHostPort("127.0.0.1", tcpServerPort)}, Endpoints: []string{net.JoinHostPort("127.0.0.1", tcpServerPort)},
}, },
}) })
@@ -340,7 +340,7 @@ func TestTCPProxyUpdateDeleteUpdate(t *testing.T) {
t.Fatalf(err.Error()) t.Fatalf(err.Error())
} }
p.OnUpdate([]api.Service{ p.OnUpdate([]api.Service{
{TypeMeta: api.TypeMeta{ID: "echo"}, Port: svcInfo.proxyPort, ProxyPort: svcInfo.proxyPort, Protocol: "TCP"}, {TypeMeta: api.TypeMeta{Name: "echo"}, Port: svcInfo.proxyPort, ProxyPort: svcInfo.proxyPort, Protocol: "TCP"},
}) })
testEchoTCP(t, "127.0.0.1", svcInfo.proxyPort) testEchoTCP(t, "127.0.0.1", svcInfo.proxyPort)
} }
@@ -349,7 +349,7 @@ func TestUDPProxyUpdateDeleteUpdate(t *testing.T) {
lb := NewLoadBalancerRR() lb := NewLoadBalancerRR()
lb.OnUpdate([]api.Endpoints{ lb.OnUpdate([]api.Endpoints{
{ {
TypeMeta: api.TypeMeta{ID: "echo"}, TypeMeta: api.TypeMeta{Name: "echo"},
Endpoints: []string{net.JoinHostPort("127.0.0.1", udpServerPort)}, Endpoints: []string{net.JoinHostPort("127.0.0.1", udpServerPort)},
}, },
}) })
@@ -371,7 +371,7 @@ func TestUDPProxyUpdateDeleteUpdate(t *testing.T) {
t.Fatalf(err.Error()) t.Fatalf(err.Error())
} }
p.OnUpdate([]api.Service{ p.OnUpdate([]api.Service{
{TypeMeta: api.TypeMeta{ID: "echo"}, Port: svcInfo.proxyPort, ProxyPort: svcInfo.proxyPort, Protocol: "UDP"}, {TypeMeta: api.TypeMeta{Name: "echo"}, Port: svcInfo.proxyPort, ProxyPort: svcInfo.proxyPort, Protocol: "UDP"},
}) })
testEchoUDP(t, "127.0.0.1", svcInfo.proxyPort) testEchoUDP(t, "127.0.0.1", svcInfo.proxyPort)
} }
@@ -380,7 +380,7 @@ func TestTCPProxyUpdatePort(t *testing.T) {
lb := NewLoadBalancerRR() lb := NewLoadBalancerRR()
lb.OnUpdate([]api.Endpoints{ lb.OnUpdate([]api.Endpoints{
{ {
TypeMeta: api.TypeMeta{ID: "echo"}, TypeMeta: api.TypeMeta{Name: "echo"},
Endpoints: []string{net.JoinHostPort("127.0.0.1", tcpServerPort)}, Endpoints: []string{net.JoinHostPort("127.0.0.1", tcpServerPort)},
}, },
}) })
@@ -406,7 +406,7 @@ func TestTCPProxyUpdatePort(t *testing.T) {
t.Errorf("expected difference, got %d %d", newPort, svcInfo.proxyPort) t.Errorf("expected difference, got %d %d", newPort, svcInfo.proxyPort)
} }
p.OnUpdate([]api.Service{ p.OnUpdate([]api.Service{
{TypeMeta: api.TypeMeta{ID: "echo"}, Port: newPort, ProxyPort: newPort, Protocol: "TCP"}, {TypeMeta: api.TypeMeta{Name: "echo"}, Port: newPort, ProxyPort: newPort, Protocol: "TCP"},
}) })
if err := waitForClosedPortTCP(p, svcInfo.proxyPort); err != nil { if err := waitForClosedPortTCP(p, svcInfo.proxyPort); err != nil {
t.Fatalf(err.Error()) t.Fatalf(err.Error())
@@ -425,7 +425,7 @@ func TestUDPProxyUpdatePort(t *testing.T) {
lb := NewLoadBalancerRR() lb := NewLoadBalancerRR()
lb.OnUpdate([]api.Endpoints{ lb.OnUpdate([]api.Endpoints{
{ {
TypeMeta: api.TypeMeta{ID: "echo"}, TypeMeta: api.TypeMeta{Name: "echo"},
Endpoints: []string{net.JoinHostPort("127.0.0.1", udpServerPort)}, Endpoints: []string{net.JoinHostPort("127.0.0.1", udpServerPort)},
}, },
}) })
@@ -451,7 +451,7 @@ func TestUDPProxyUpdatePort(t *testing.T) {
t.Errorf("expected difference, got %d %d", newPort, svcInfo.proxyPort) t.Errorf("expected difference, got %d %d", newPort, svcInfo.proxyPort)
} }
p.OnUpdate([]api.Service{ p.OnUpdate([]api.Service{
{TypeMeta: api.TypeMeta{ID: "echo"}, Port: newPort, ProxyPort: newPort, Protocol: "UDP"}, {TypeMeta: api.TypeMeta{Name: "echo"}, Port: newPort, ProxyPort: newPort, Protocol: "UDP"},
}) })
if err := waitForClosedPortUDP(p, svcInfo.proxyPort); err != nil { if err := waitForClosedPortUDP(p, svcInfo.proxyPort); err != nil {
t.Fatalf(err.Error()) t.Fatalf(err.Error())

View File

@@ -98,15 +98,15 @@ func (lb *LoadBalancerRR) OnUpdate(endpoints []api.Endpoints) {
defer lb.lock.Unlock() defer lb.lock.Unlock()
// Update endpoints for services. // Update endpoints for services.
for _, endpoint := range endpoints { for _, endpoint := range endpoints {
existingEndpoints, exists := lb.endpointsMap[endpoint.ID] existingEndpoints, exists := lb.endpointsMap[endpoint.Name]
validEndpoints := filterValidEndpoints(endpoint.Endpoints) validEndpoints := filterValidEndpoints(endpoint.Endpoints)
if !exists || !reflect.DeepEqual(existingEndpoints, validEndpoints) { if !exists || !reflect.DeepEqual(existingEndpoints, validEndpoints) {
glog.V(3).Infof("LoadBalancerRR: Setting endpoints for %s to %+v", endpoint.ID, endpoint.Endpoints) glog.V(3).Infof("LoadBalancerRR: Setting endpoints for %s to %+v", endpoint.Name, endpoint.Endpoints)
lb.endpointsMap[endpoint.ID] = validEndpoints lb.endpointsMap[endpoint.Name] = validEndpoints
// Reset the round-robin index. // Reset the round-robin index.
lb.rrIndex[endpoint.ID] = 0 lb.rrIndex[endpoint.Name] = 0
} }
registeredEndpoints[endpoint.ID] = true registeredEndpoints[endpoint.Name] = true
} }
// Remove endpoints missing from the update. // Remove endpoints missing from the update.
for k, v := range lb.endpointsMap { for k, v := range lb.endpointsMap {

View File

@@ -86,7 +86,7 @@ func TestLoadBalanceWorksWithSingleEndpoint(t *testing.T) {
} }
endpoints := make([]api.Endpoints, 1) endpoints := make([]api.Endpoints, 1)
endpoints[0] = api.Endpoints{ endpoints[0] = api.Endpoints{
TypeMeta: api.TypeMeta{ID: "foo"}, TypeMeta: api.TypeMeta{Name: "foo"},
Endpoints: []string{"endpoint1:40"}, Endpoints: []string{"endpoint1:40"},
} }
loadBalancer.OnUpdate(endpoints) loadBalancer.OnUpdate(endpoints)
@@ -104,7 +104,7 @@ func TestLoadBalanceWorksWithMultipleEndpoints(t *testing.T) {
} }
endpoints := make([]api.Endpoints, 1) endpoints := make([]api.Endpoints, 1)
endpoints[0] = api.Endpoints{ endpoints[0] = api.Endpoints{
TypeMeta: api.TypeMeta{ID: "foo"}, TypeMeta: api.TypeMeta{Name: "foo"},
Endpoints: []string{"endpoint:1", "endpoint:2", "endpoint:3"}, Endpoints: []string{"endpoint:1", "endpoint:2", "endpoint:3"},
} }
loadBalancer.OnUpdate(endpoints) loadBalancer.OnUpdate(endpoints)
@@ -122,7 +122,7 @@ func TestLoadBalanceWorksWithMultipleEndpointsAndUpdates(t *testing.T) {
} }
endpoints := make([]api.Endpoints, 1) endpoints := make([]api.Endpoints, 1)
endpoints[0] = api.Endpoints{ endpoints[0] = api.Endpoints{
TypeMeta: api.TypeMeta{ID: "foo"}, TypeMeta: api.TypeMeta{Name: "foo"},
Endpoints: []string{"endpoint:1", "endpoint:2", "endpoint:3"}, Endpoints: []string{"endpoint:1", "endpoint:2", "endpoint:3"},
} }
loadBalancer.OnUpdate(endpoints) loadBalancer.OnUpdate(endpoints)
@@ -133,7 +133,7 @@ func TestLoadBalanceWorksWithMultipleEndpointsAndUpdates(t *testing.T) {
expectEndpoint(t, loadBalancer, "foo", "endpoint:2") expectEndpoint(t, loadBalancer, "foo", "endpoint:2")
// Then update the configuration with one fewer endpoints, make sure // Then update the configuration with one fewer endpoints, make sure
// we start in the beginning again // we start in the beginning again
endpoints[0] = api.Endpoints{TypeMeta: api.TypeMeta{ID: "foo"}, endpoints[0] = api.Endpoints{TypeMeta: api.TypeMeta{Name: "foo"},
Endpoints: []string{"endpoint:8", "endpoint:9"}, Endpoints: []string{"endpoint:8", "endpoint:9"},
} }
loadBalancer.OnUpdate(endpoints) loadBalancer.OnUpdate(endpoints)
@@ -142,7 +142,7 @@ func TestLoadBalanceWorksWithMultipleEndpointsAndUpdates(t *testing.T) {
expectEndpoint(t, loadBalancer, "foo", "endpoint:8") expectEndpoint(t, loadBalancer, "foo", "endpoint:8")
expectEndpoint(t, loadBalancer, "foo", "endpoint:9") expectEndpoint(t, loadBalancer, "foo", "endpoint:9")
// Clear endpoints // Clear endpoints
endpoints[0] = api.Endpoints{TypeMeta: api.TypeMeta{ID: "foo"}, Endpoints: []string{}} endpoints[0] = api.Endpoints{TypeMeta: api.TypeMeta{Name: "foo"}, Endpoints: []string{}}
loadBalancer.OnUpdate(endpoints) loadBalancer.OnUpdate(endpoints)
endpoint, err = loadBalancer.NextEndpoint("foo", nil) endpoint, err = loadBalancer.NextEndpoint("foo", nil)
@@ -159,11 +159,11 @@ func TestLoadBalanceWorksWithServiceRemoval(t *testing.T) {
} }
endpoints := make([]api.Endpoints, 2) endpoints := make([]api.Endpoints, 2)
endpoints[0] = api.Endpoints{ endpoints[0] = api.Endpoints{
TypeMeta: api.TypeMeta{ID: "foo"}, TypeMeta: api.TypeMeta{Name: "foo"},
Endpoints: []string{"endpoint:1", "endpoint:2", "endpoint:3"}, Endpoints: []string{"endpoint:1", "endpoint:2", "endpoint:3"},
} }
endpoints[1] = api.Endpoints{ endpoints[1] = api.Endpoints{
TypeMeta: api.TypeMeta{ID: "bar"}, TypeMeta: api.TypeMeta{Name: "bar"},
Endpoints: []string{"endpoint:4", "endpoint:5"}, Endpoints: []string{"endpoint:4", "endpoint:5"},
} }
loadBalancer.OnUpdate(endpoints) loadBalancer.OnUpdate(endpoints)

View File

@@ -63,13 +63,13 @@ func (rs *REST) Create(ctx api.Context, obj runtime.Object) (<-chan runtime.Obje
return nil, errors.NewConflict("controller", controller.Namespace, fmt.Errorf("Controller.Namespace does not match the provided context")) return nil, errors.NewConflict("controller", controller.Namespace, fmt.Errorf("Controller.Namespace does not match the provided context"))
} }
if len(controller.ID) == 0 { if len(controller.Name) == 0 {
controller.ID = uuid.NewUUID().String() controller.Name = uuid.NewUUID().String()
} }
// Pod Manifest ID should be assigned by the pod API // Pod Manifest ID should be assigned by the pod API
controller.DesiredState.PodTemplate.DesiredState.Manifest.ID = "" controller.DesiredState.PodTemplate.DesiredState.Manifest.ID = ""
if errs := validation.ValidateReplicationController(controller); len(errs) > 0 { if errs := validation.ValidateReplicationController(controller); len(errs) > 0 {
return nil, errors.NewInvalid("replicationController", controller.ID, errs) return nil, errors.NewInvalid("replicationController", controller.Name, errs)
} }
controller.CreationTimestamp = util.Now() controller.CreationTimestamp = util.Now()
@@ -79,7 +79,7 @@ func (rs *REST) Create(ctx api.Context, obj runtime.Object) (<-chan runtime.Obje
if err != nil { if err != nil {
return nil, err return nil, err
} }
return rs.registry.GetController(ctx, controller.ID) return rs.registry.GetController(ctx, controller.Name)
}), nil }), nil
} }
@@ -136,14 +136,14 @@ func (rs *REST) Update(ctx api.Context, obj runtime.Object) (<-chan runtime.Obje
return nil, errors.NewConflict("controller", controller.Namespace, fmt.Errorf("Controller.Namespace does not match the provided context")) return nil, errors.NewConflict("controller", controller.Namespace, fmt.Errorf("Controller.Namespace does not match the provided context"))
} }
if errs := validation.ValidateReplicationController(controller); len(errs) > 0 { if errs := validation.ValidateReplicationController(controller); len(errs) > 0 {
return nil, errors.NewInvalid("replicationController", controller.ID, errs) return nil, errors.NewInvalid("replicationController", controller.Name, errs)
} }
return apiserver.MakeAsync(func() (runtime.Object, error) { return apiserver.MakeAsync(func() (runtime.Object, error) {
err := rs.registry.UpdateController(ctx, controller) err := rs.registry.UpdateController(ctx, controller)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return rs.registry.GetController(ctx, controller.ID) return rs.registry.GetController(ctx, controller.Name)
}), nil }), nil
} }

View File

@@ -75,12 +75,12 @@ func TestListControllerList(t *testing.T) {
Items: []api.ReplicationController{ Items: []api.ReplicationController{
{ {
TypeMeta: api.TypeMeta{ TypeMeta: api.TypeMeta{
ID: "foo", Name: "foo",
}, },
}, },
{ {
TypeMeta: api.TypeMeta{ TypeMeta: api.TypeMeta{
ID: "bar", Name: "bar",
}, },
}, },
}, },
@@ -99,10 +99,10 @@ func TestListControllerList(t *testing.T) {
if len(controllers.Items) != 2 { if len(controllers.Items) != 2 {
t.Errorf("Unexpected controller list: %#v", controllers) t.Errorf("Unexpected controller list: %#v", controllers)
} }
if controllers.Items[0].ID != "foo" { if controllers.Items[0].Name != "foo" {
t.Errorf("Unexpected controller: %#v", controllers.Items[0]) t.Errorf("Unexpected controller: %#v", controllers.Items[0])
} }
if controllers.Items[1].ID != "bar" { if controllers.Items[1].Name != "bar" {
t.Errorf("Unexpected controller: %#v", controllers.Items[1]) t.Errorf("Unexpected controller: %#v", controllers.Items[1])
} }
} }
@@ -114,7 +114,7 @@ func TestControllerDecode(t *testing.T) {
} }
controller := &api.ReplicationController{ controller := &api.ReplicationController{
TypeMeta: api.TypeMeta{ TypeMeta: api.TypeMeta{
ID: "foo", Name: "foo",
}, },
} }
body, err := latest.Codec.Encode(controller) body, err := latest.Codec.Encode(controller)
@@ -135,7 +135,7 @@ func TestControllerDecode(t *testing.T) {
func TestControllerParsing(t *testing.T) { func TestControllerParsing(t *testing.T) {
expectedController := api.ReplicationController{ expectedController := api.ReplicationController{
TypeMeta: api.TypeMeta{ TypeMeta: api.TypeMeta{
ID: "nginxController", Name: "nginxController",
}, },
DesiredState: api.ReplicationControllerState{ DesiredState: api.ReplicationControllerState{
Replicas: 2, Replicas: 2,
@@ -225,7 +225,7 @@ func TestCreateController(t *testing.T) {
Pods: &api.PodList{ Pods: &api.PodList{
Items: []api.Pod{ Items: []api.Pod{
{ {
TypeMeta: api.TypeMeta{ID: "foo"}, TypeMeta: api.TypeMeta{Name: "foo"},
Labels: map[string]string{"a": "b"}, Labels: map[string]string{"a": "b"},
}, },
}, },
@@ -237,7 +237,7 @@ func TestCreateController(t *testing.T) {
pollPeriod: time.Millisecond * 1, pollPeriod: time.Millisecond * 1,
} }
controller := &api.ReplicationController{ controller := &api.ReplicationController{
TypeMeta: api.TypeMeta{ID: "test"}, TypeMeta: api.TypeMeta{Name: "test"},
DesiredState: api.ReplicationControllerState{ DesiredState: api.ReplicationControllerState{
Replicas: 2, Replicas: 2,
ReplicaSelector: map[string]string{"a": "b"}, ReplicaSelector: map[string]string{"a": "b"},
@@ -270,13 +270,13 @@ func TestControllerStorageValidatesCreate(t *testing.T) {
} }
failureCases := map[string]api.ReplicationController{ failureCases := map[string]api.ReplicationController{
"empty ID": { "empty ID": {
TypeMeta: api.TypeMeta{ID: ""}, TypeMeta: api.TypeMeta{Name: ""},
DesiredState: api.ReplicationControllerState{ DesiredState: api.ReplicationControllerState{
ReplicaSelector: map[string]string{"bar": "baz"}, ReplicaSelector: map[string]string{"bar": "baz"},
}, },
}, },
"empty selector": { "empty selector": {
TypeMeta: api.TypeMeta{ID: "abc"}, TypeMeta: api.TypeMeta{Name: "abc"},
DesiredState: api.ReplicationControllerState{}, DesiredState: api.ReplicationControllerState{},
}, },
} }
@@ -301,13 +301,13 @@ func TestControllerStorageValidatesUpdate(t *testing.T) {
} }
failureCases := map[string]api.ReplicationController{ failureCases := map[string]api.ReplicationController{
"empty ID": { "empty ID": {
TypeMeta: api.TypeMeta{ID: ""}, TypeMeta: api.TypeMeta{Name: ""},
DesiredState: api.ReplicationControllerState{ DesiredState: api.ReplicationControllerState{
ReplicaSelector: map[string]string{"bar": "baz"}, ReplicaSelector: map[string]string{"bar": "baz"},
}, },
}, },
"empty selector": { "empty selector": {
TypeMeta: api.TypeMeta{ID: "abc"}, TypeMeta: api.TypeMeta{Name: "abc"},
DesiredState: api.ReplicationControllerState{}, DesiredState: api.ReplicationControllerState{},
}, },
} }
@@ -338,8 +338,8 @@ func TestFillCurrentState(t *testing.T) {
fakeLister := fakePodLister{ fakeLister := fakePodLister{
l: api.PodList{ l: api.PodList{
Items: []api.Pod{ Items: []api.Pod{
{TypeMeta: api.TypeMeta{ID: "foo"}}, {TypeMeta: api.TypeMeta{Name: "foo"}},
{TypeMeta: api.TypeMeta{ID: "bar"}}, {TypeMeta: api.TypeMeta{Name: "bar"}},
}, },
}, },
} }
@@ -368,7 +368,7 @@ func TestFillCurrentState(t *testing.T) {
func TestCreateControllerWithConflictingNamespace(t *testing.T) { func TestCreateControllerWithConflictingNamespace(t *testing.T) {
storage := REST{} storage := REST{}
controller := &api.ReplicationController{ controller := &api.ReplicationController{
TypeMeta: api.TypeMeta{ID: "test", Namespace: "not-default"}, TypeMeta: api.TypeMeta{Name: "test", Namespace: "not-default"},
} }
ctx := api.NewDefaultContext() ctx := api.NewDefaultContext()
@@ -386,7 +386,7 @@ func TestCreateControllerWithConflictingNamespace(t *testing.T) {
func TestUpdateControllerWithConflictingNamespace(t *testing.T) { func TestUpdateControllerWithConflictingNamespace(t *testing.T) {
storage := REST{} storage := REST{}
controller := &api.ReplicationController{ controller := &api.ReplicationController{
TypeMeta: api.TypeMeta{ID: "test", Namespace: "not-default"}, TypeMeta: api.TypeMeta{Name: "test", Namespace: "not-default"},
} }
ctx := api.NewDefaultContext() ctx := api.NewDefaultContext()

View File

@@ -65,7 +65,7 @@ func (rs *REST) Create(ctx api.Context, obj runtime.Object) (<-chan runtime.Obje
if !ok { if !ok {
return nil, fmt.Errorf("not an endpoints: %#v", obj) return nil, fmt.Errorf("not an endpoints: %#v", obj)
} }
if len(endpoints.ID) == 0 { if len(endpoints.Name) == 0 {
return nil, fmt.Errorf("id is required: %#v", obj) return nil, fmt.Errorf("id is required: %#v", obj)
} }
endpoints.CreationTimestamp = util.Now() endpoints.CreationTimestamp = util.Now()
@@ -74,7 +74,7 @@ func (rs *REST) Create(ctx api.Context, obj runtime.Object) (<-chan runtime.Obje
if err != nil { if err != nil {
return nil, err return nil, err
} }
return rs.registry.GetEndpoints(ctx, endpoints.ID) return rs.registry.GetEndpoints(ctx, endpoints.Name)
}), nil }), nil
} }
@@ -89,7 +89,7 @@ func (rs *REST) Update(ctx api.Context, obj runtime.Object) (<-chan runtime.Obje
if err != nil { if err != nil {
return nil, err return nil, err
} }
return rs.registry.GetEndpoints(ctx, endpoints.ID) return rs.registry.GetEndpoints(ctx, endpoints.Name)
}), nil }), nil
} }

View File

@@ -29,7 +29,7 @@ import (
func TestGetEndpoints(t *testing.T) { func TestGetEndpoints(t *testing.T) {
registry := &registrytest.ServiceRegistry{ registry := &registrytest.ServiceRegistry{
Endpoints: api.Endpoints{ Endpoints: api.Endpoints{
TypeMeta: api.TypeMeta{ID: "foo"}, TypeMeta: api.TypeMeta{Name: "foo"},
Endpoints: []string{"127.0.0.1:9000"}, Endpoints: []string{"127.0.0.1:9000"},
}, },
} }
@@ -59,7 +59,7 @@ func TestGetEndpointsMissingService(t *testing.T) {
// returns empty endpoints // returns empty endpoints
registry.Err = nil registry.Err = nil
registry.Service = &api.Service{ registry.Service = &api.Service{
TypeMeta: api.TypeMeta{ID: "foo"}, TypeMeta: api.TypeMeta{Name: "foo"},
} }
obj, err := storage.Get(ctx, "foo") obj, err := storage.Get(ctx, "foo")
if err != nil { if err != nil {
@@ -76,8 +76,8 @@ func TestEndpointsRegistryList(t *testing.T) {
registry.EndpointsList = api.EndpointsList{ registry.EndpointsList = api.EndpointsList{
TypeMeta: api.TypeMeta{ResourceVersion: "1"}, TypeMeta: api.TypeMeta{ResourceVersion: "1"},
Items: []api.Endpoints{ Items: []api.Endpoints{
{TypeMeta: api.TypeMeta{ID: "foo"}}, {TypeMeta: api.TypeMeta{Name: "foo"}},
{TypeMeta: api.TypeMeta{ID: "bar"}}, {TypeMeta: api.TypeMeta{Name: "bar"}},
}, },
} }
ctx := api.NewContext() ctx := api.NewContext()
@@ -86,10 +86,10 @@ func TestEndpointsRegistryList(t *testing.T) {
if len(sl.Items) != 2 { if len(sl.Items) != 2 {
t.Fatalf("Expected 2 endpoints, but got %v", len(sl.Items)) t.Fatalf("Expected 2 endpoints, but got %v", len(sl.Items))
} }
if e, a := "foo", sl.Items[0].ID; e != a { if e, a := "foo", sl.Items[0].Name; e != a {
t.Errorf("Expected %v, but got %v", e, a) t.Errorf("Expected %v, but got %v", e, a)
} }
if e, a := "bar", sl.Items[1].ID; e != a { if e, a := "bar", sl.Items[1].Name; e != a {
t.Errorf("Expected %v, but got %v", e, a) t.Errorf("Expected %v, but got %v", e, a)
} }
if sl.ResourceVersion != "1" { if sl.ResourceVersion != "1" {

View File

@@ -188,12 +188,12 @@ func (r *Registry) CreatePod(ctx api.Context, pod *api.Pod) error {
// DesiredState.Host == "" is a signal to the scheduler that this pod needs scheduling. // DesiredState.Host == "" is a signal to the scheduler that this pod needs scheduling.
pod.DesiredState.Status = api.PodRunning pod.DesiredState.Status = api.PodRunning
pod.DesiredState.Host = "" pod.DesiredState.Host = ""
key, err := makePodKey(ctx, pod.ID) key, err := makePodKey(ctx, pod.Name)
if err != nil { if err != nil {
return err return err
} }
err = r.CreateObj(key, pod, 0) err = r.CreateObj(key, pod, 0)
return etcderr.InterpretCreateError(err, "pod", pod.ID) return etcderr.InterpretCreateError(err, "pod", pod.Name)
} }
// ApplyBinding implements binding's registry // ApplyBinding implements binding's registry
@@ -214,7 +214,7 @@ func (r *Registry) setPodHostTo(ctx api.Context, podID, oldMachine, machine stri
return nil, fmt.Errorf("unexpected object: %#v", obj) return nil, fmt.Errorf("unexpected object: %#v", obj)
} }
if pod.DesiredState.Host != oldMachine { if pod.DesiredState.Host != oldMachine {
return nil, fmt.Errorf("pod %v is already assigned to host %v", pod.ID, pod.DesiredState.Host) return nil, fmt.Errorf("pod %v is already assigned to host %v", pod.Name, pod.DesiredState.Host)
} }
pod.DesiredState.Host = machine pod.DesiredState.Host = machine
finalPod = pod finalPod = pod
@@ -255,7 +255,7 @@ func (r *Registry) assignPod(ctx api.Context, podID string, machine string) erro
func (r *Registry) UpdatePod(ctx api.Context, pod *api.Pod) error { func (r *Registry) UpdatePod(ctx api.Context, pod *api.Pod) error {
var podOut api.Pod var podOut api.Pod
podKey, err := makePodKey(ctx, pod.ID) podKey, err := makePodKey(ctx, pod.Name)
if err != nil { if err != nil {
return err return err
} }
@@ -269,7 +269,7 @@ func (r *Registry) UpdatePod(ctx api.Context, pod *api.Pod) error {
// If it's already been scheduled, limit the types of updates we'll accept. // If it's already been scheduled, limit the types of updates we'll accept.
errs := validation.ValidatePodUpdate(pod, &podOut) errs := validation.ValidatePodUpdate(pod, &podOut)
if len(errs) != 0 { if len(errs) != 0 {
return errors.NewInvalid("Pod", pod.ID, errs) return errors.NewInvalid("Pod", pod.Name, errs)
} }
} }
// There's no race with the scheduler, because either this write will fail because the host // There's no race with the scheduler, because either this write will fail because the host
@@ -286,14 +286,14 @@ func (r *Registry) UpdatePod(ctx api.Context, pod *api.Pod) error {
return r.AtomicUpdate(containerKey, &api.ContainerManifestList{}, func(in runtime.Object) (runtime.Object, error) { return r.AtomicUpdate(containerKey, &api.ContainerManifestList{}, func(in runtime.Object) (runtime.Object, error) {
manifests := in.(*api.ContainerManifestList) manifests := in.(*api.ContainerManifestList)
for ix := range manifests.Items { for ix := range manifests.Items {
if manifests.Items[ix].ID == pod.ID { if manifests.Items[ix].ID == pod.Name {
manifests.Items[ix] = pod.DesiredState.Manifest manifests.Items[ix] = pod.DesiredState.Manifest
return manifests, nil return manifests, nil
} }
} }
// This really shouldn't happen // This really shouldn't happen
glog.Warningf("Couldn't find: %s in %#v", pod.ID, manifests) glog.Warningf("Couldn't find: %s in %#v", pod.Name, manifests)
return manifests, fmt.Errorf("Failed to update pod, couldn't find %s in %#v", pod.ID, manifests) return manifests, fmt.Errorf("Failed to update pod, couldn't find %s in %#v", pod.Name, manifests)
}) })
} }
@@ -326,7 +326,7 @@ func (r *Registry) DeletePod(ctx api.Context, podID string) error {
newPods := make([]api.BoundPod, 0, len(pods.Items)) newPods := make([]api.BoundPod, 0, len(pods.Items))
found := false found := false
for _, pod := range pods.Items { for _, pod := range pods.Items {
if pod.ID != podID { if pod.Name != podID {
newPods = append(newPods, pod) newPods = append(newPods, pod)
} else { } else {
found = true found = true
@@ -387,22 +387,22 @@ func (r *Registry) GetController(ctx api.Context, controllerID string) (*api.Rep
// CreateController creates a new ReplicationController. // CreateController creates a new ReplicationController.
func (r *Registry) CreateController(ctx api.Context, controller *api.ReplicationController) error { func (r *Registry) CreateController(ctx api.Context, controller *api.ReplicationController) error {
key, err := makeControllerKey(ctx, controller.ID) key, err := makeControllerKey(ctx, controller.Name)
if err != nil { if err != nil {
return err return err
} }
err = r.CreateObj(key, controller, 0) err = r.CreateObj(key, controller, 0)
return etcderr.InterpretCreateError(err, "replicationController", controller.ID) return etcderr.InterpretCreateError(err, "replicationController", controller.Name)
} }
// UpdateController replaces an existing ReplicationController. // UpdateController replaces an existing ReplicationController.
func (r *Registry) UpdateController(ctx api.Context, controller *api.ReplicationController) error { func (r *Registry) UpdateController(ctx api.Context, controller *api.ReplicationController) error {
key, err := makeControllerKey(ctx, controller.ID) key, err := makeControllerKey(ctx, controller.Name)
if err != nil { if err != nil {
return err return err
} }
err = r.SetObj(key, controller) err = r.SetObj(key, controller)
return etcderr.InterpretUpdateError(err, "replicationController", controller.ID) return etcderr.InterpretUpdateError(err, "replicationController", controller.Name)
} }
// DeleteController deletes a ReplicationController specified by its ID. // DeleteController deletes a ReplicationController specified by its ID.
@@ -434,12 +434,12 @@ func (r *Registry) ListServices(ctx api.Context) (*api.ServiceList, error) {
// CreateService creates a new Service. // CreateService creates a new Service.
func (r *Registry) CreateService(ctx api.Context, svc *api.Service) error { func (r *Registry) CreateService(ctx api.Context, svc *api.Service) error {
key, err := makeServiceKey(ctx, svc.ID) key, err := makeServiceKey(ctx, svc.Name)
if err != nil { if err != nil {
return err return err
} }
err = r.CreateObj(key, svc, 0) err = r.CreateObj(key, svc, 0)
return etcderr.InterpretCreateError(err, "service", svc.ID) return etcderr.InterpretCreateError(err, "service", svc.Name)
} }
// GetService obtains a Service specified by its name. // GetService obtains a Service specified by its name.
@@ -505,12 +505,12 @@ func (r *Registry) DeleteService(ctx api.Context, name string) error {
// UpdateService replaces an existing Service. // UpdateService replaces an existing Service.
func (r *Registry) UpdateService(ctx api.Context, svc *api.Service) error { func (r *Registry) UpdateService(ctx api.Context, svc *api.Service) error {
key, err := makeServiceKey(ctx, svc.ID) key, err := makeServiceKey(ctx, svc.Name)
if err != nil { if err != nil {
return err return err
} }
err = r.SetObj(key, svc) err = r.SetObj(key, svc)
return etcderr.InterpretUpdateError(err, "service", svc.ID) return etcderr.InterpretUpdateError(err, "service", svc.Name)
} }
// WatchServices begins watching for new, changed, or deleted service configurations. // WatchServices begins watching for new, changed, or deleted service configurations.
@@ -544,8 +544,8 @@ func (r *Registry) ListEndpoints(ctx api.Context) (*api.EndpointsList, error) {
} }
// UpdateEndpoints update Endpoints of a Service. // UpdateEndpoints update Endpoints of a Service.
func (r *Registry) UpdateEndpoints(ctx api.Context, e *api.Endpoints) error { func (r *Registry) UpdateEndpoints(ctx api.Context, endpoints *api.Endpoints) error {
key, err := makeServiceEndpointsKey(ctx, e.ID) key, err := makeServiceEndpointsKey(ctx, endpoints.Name)
if err != nil { if err != nil {
return err return err
} }
@@ -553,9 +553,9 @@ func (r *Registry) UpdateEndpoints(ctx api.Context, e *api.Endpoints) error {
err = r.AtomicUpdate(key, &api.Endpoints{}, err = r.AtomicUpdate(key, &api.Endpoints{},
func(input runtime.Object) (runtime.Object, error) { func(input runtime.Object) (runtime.Object, error) {
// TODO: racy - label query is returning different results for two simultaneous updaters // TODO: racy - label query is returning different results for two simultaneous updaters
return e, nil return endpoints, nil
}) })
return etcderr.InterpretUpdateError(err, "endpoints", e.ID) return etcderr.InterpretUpdateError(err, "endpoints", endpoints.Name)
} }
// WatchEndpoints begins watching for new, changed, or deleted endpoint configurations. // WatchEndpoints begins watching for new, changed, or deleted endpoint configurations.
@@ -592,8 +592,8 @@ func (r *Registry) ListMinions(ctx api.Context) (*api.MinionList, error) {
func (r *Registry) CreateMinion(ctx api.Context, minion *api.Minion) error { func (r *Registry) CreateMinion(ctx api.Context, minion *api.Minion) error {
// TODO: Add some validations. // TODO: Add some validations.
err := r.CreateObj(makeMinionKey(minion.ID), minion, 0) err := r.CreateObj(makeMinionKey(minion.Name), minion, 0)
return etcderr.InterpretCreateError(err, "minion", minion.ID) return etcderr.InterpretCreateError(err, "minion", minion.Name)
} }
func (r *Registry) GetMinion(ctx api.Context, minionID string) (*api.Minion, error) { func (r *Registry) GetMinion(ctx api.Context, minionID string) (*api.Minion, error) {
@@ -601,7 +601,7 @@ func (r *Registry) GetMinion(ctx api.Context, minionID string) (*api.Minion, err
key := makeMinionKey(minionID) key := makeMinionKey(minionID)
err := r.ExtractObj(key, &minion, false) err := r.ExtractObj(key, &minion, false)
if err != nil { if err != nil {
return nil, etcderr.InterpretGetError(err, "minion", minion.ID) return nil, etcderr.InterpretGetError(err, "minion", minion.Name)
} }
return &minion, nil return &minion, nil
} }

View File

@@ -87,8 +87,8 @@ func TestEtcdGetPodDifferentNamespace(t *testing.T) {
key1, _ := makePodKey(ctx1, "foo") key1, _ := makePodKey(ctx1, "foo")
key2, _ := makePodKey(ctx2, "foo") key2, _ := makePodKey(ctx2, "foo")
fakeClient.Set(key1, runtime.EncodeOrDie(latest.Codec, &api.Pod{TypeMeta: api.TypeMeta{Namespace: "default", ID: "foo"}}), 0) fakeClient.Set(key1, runtime.EncodeOrDie(latest.Codec, &api.Pod{TypeMeta: api.TypeMeta{Namespace: "default", Name: "foo"}}), 0)
fakeClient.Set(key2, runtime.EncodeOrDie(latest.Codec, &api.Pod{TypeMeta: api.TypeMeta{Namespace: "other", ID: "foo"}}), 0) fakeClient.Set(key2, runtime.EncodeOrDie(latest.Codec, &api.Pod{TypeMeta: api.TypeMeta{Namespace: "other", Name: "foo"}}), 0)
registry := NewTestEtcdRegistry(fakeClient) registry := NewTestEtcdRegistry(fakeClient)
@@ -96,7 +96,7 @@ func TestEtcdGetPodDifferentNamespace(t *testing.T) {
if err != nil { if err != nil {
t.Errorf("unexpected error: %v", err) t.Errorf("unexpected error: %v", err)
} }
if pod1.ID != "foo" { if pod1.Name != "foo" {
t.Errorf("Unexpected pod: %#v", pod1) t.Errorf("Unexpected pod: %#v", pod1)
} }
if pod1.Namespace != "default" { if pod1.Namespace != "default" {
@@ -107,7 +107,7 @@ func TestEtcdGetPodDifferentNamespace(t *testing.T) {
if err != nil { if err != nil {
t.Errorf("unexpected error: %v", err) t.Errorf("unexpected error: %v", err)
} }
if pod2.ID != "foo" { if pod2.Name != "foo" {
t.Errorf("Unexpected pod: %#v", pod2) t.Errorf("Unexpected pod: %#v", pod2)
} }
if pod2.Namespace != "other" { if pod2.Namespace != "other" {
@@ -120,14 +120,14 @@ func TestEtcdGetPod(t *testing.T) {
ctx := api.NewDefaultContext() ctx := api.NewDefaultContext()
fakeClient := tools.NewFakeEtcdClient(t) fakeClient := tools.NewFakeEtcdClient(t)
key, _ := makePodKey(ctx, "foo") key, _ := makePodKey(ctx, "foo")
fakeClient.Set(key, runtime.EncodeOrDie(latest.Codec, &api.Pod{TypeMeta: api.TypeMeta{ID: "foo"}}), 0) fakeClient.Set(key, runtime.EncodeOrDie(latest.Codec, &api.Pod{TypeMeta: api.TypeMeta{Name: "foo"}}), 0)
registry := NewTestEtcdRegistry(fakeClient) registry := NewTestEtcdRegistry(fakeClient)
pod, err := registry.GetPod(ctx, "foo") pod, err := registry.GetPod(ctx, "foo")
if err != nil { if err != nil {
t.Errorf("unexpected error: %v", err) t.Errorf("unexpected error: %v", err)
} }
if pod.ID != "foo" { if pod.Name != "foo" {
t.Errorf("Unexpected pod: %#v", pod) t.Errorf("Unexpected pod: %#v", pod)
} }
} }
@@ -164,7 +164,7 @@ func TestEtcdCreatePod(t *testing.T) {
registry := NewTestEtcdRegistry(fakeClient) registry := NewTestEtcdRegistry(fakeClient)
err := registry.CreatePod(ctx, &api.Pod{ err := registry.CreatePod(ctx, &api.Pod{
TypeMeta: api.TypeMeta{ TypeMeta: api.TypeMeta{
ID: "foo", Name: "foo",
}, },
DesiredState: api.PodState{ DesiredState: api.PodState{
Manifest: api.ContainerManifest{ Manifest: api.ContainerManifest{
@@ -196,7 +196,7 @@ func TestEtcdCreatePod(t *testing.T) {
t.Errorf("unexpected error: %v", err) t.Errorf("unexpected error: %v", err)
} }
if pod.ID != "foo" { if pod.Name != "foo" {
t.Errorf("Unexpected pod: %#v %s", pod, resp.Node.Value) t.Errorf("Unexpected pod: %#v %s", pod, resp.Node.Value)
} }
var boundPods api.BoundPods var boundPods api.BoundPods
@@ -206,7 +206,7 @@ func TestEtcdCreatePod(t *testing.T) {
} }
err = latest.Codec.DecodeInto([]byte(resp.Node.Value), &boundPods) err = latest.Codec.DecodeInto([]byte(resp.Node.Value), &boundPods)
if len(boundPods.Items) != 1 || boundPods.Items[0].ID != "foo" { if len(boundPods.Items) != 1 || boundPods.Items[0].Name != "foo" {
t.Errorf("Unexpected boundPod list: %#v", boundPods) t.Errorf("Unexpected boundPod list: %#v", boundPods)
} }
} }
@@ -217,7 +217,7 @@ func TestEtcdCreatePodFailsWithoutNamespace(t *testing.T) {
registry := NewTestEtcdRegistry(fakeClient) registry := NewTestEtcdRegistry(fakeClient)
err := registry.CreatePod(api.NewContext(), &api.Pod{ err := registry.CreatePod(api.NewContext(), &api.Pod{
TypeMeta: api.TypeMeta{ TypeMeta: api.TypeMeta{
ID: "foo", Name: "foo",
}, },
DesiredState: api.PodState{ DesiredState: api.PodState{
Manifest: api.ContainerManifest{ Manifest: api.ContainerManifest{
@@ -242,7 +242,7 @@ func TestEtcdCreatePodAlreadyExisting(t *testing.T) {
fakeClient.Data[key] = tools.EtcdResponseWithError{ fakeClient.Data[key] = tools.EtcdResponseWithError{
R: &etcd.Response{ R: &etcd.Response{
Node: &etcd.Node{ Node: &etcd.Node{
Value: runtime.EncodeOrDie(latest.Codec, &api.Pod{TypeMeta: api.TypeMeta{ID: "foo"}}), Value: runtime.EncodeOrDie(latest.Codec, &api.Pod{TypeMeta: api.TypeMeta{Name: "foo"}}),
}, },
}, },
E: nil, E: nil,
@@ -250,7 +250,7 @@ func TestEtcdCreatePodAlreadyExisting(t *testing.T) {
registry := NewTestEtcdRegistry(fakeClient) registry := NewTestEtcdRegistry(fakeClient)
err := registry.CreatePod(ctx, &api.Pod{ err := registry.CreatePod(ctx, &api.Pod{
TypeMeta: api.TypeMeta{ TypeMeta: api.TypeMeta{
ID: "foo", Name: "foo",
}, },
}) })
if !errors.IsAlreadyExists(err) { if !errors.IsAlreadyExists(err) {
@@ -278,7 +278,7 @@ func TestEtcdCreatePodWithContainersError(t *testing.T) {
registry := NewTestEtcdRegistry(fakeClient) registry := NewTestEtcdRegistry(fakeClient)
err := registry.CreatePod(ctx, &api.Pod{ err := registry.CreatePod(ctx, &api.Pod{
TypeMeta: api.TypeMeta{ TypeMeta: api.TypeMeta{
ID: "foo", Name: "foo",
}, },
}) })
if err != nil { if err != nil {
@@ -320,7 +320,7 @@ func TestEtcdCreatePodWithContainersNotFound(t *testing.T) {
registry := NewTestEtcdRegistry(fakeClient) registry := NewTestEtcdRegistry(fakeClient)
err := registry.CreatePod(ctx, &api.Pod{ err := registry.CreatePod(ctx, &api.Pod{
TypeMeta: api.TypeMeta{ TypeMeta: api.TypeMeta{
ID: "foo", Name: "foo",
}, },
DesiredState: api.PodState{ DesiredState: api.PodState{
Manifest: api.ContainerManifest{ Manifest: api.ContainerManifest{
@@ -353,7 +353,7 @@ func TestEtcdCreatePodWithContainersNotFound(t *testing.T) {
t.Errorf("unexpected error: %v", err) t.Errorf("unexpected error: %v", err)
} }
if pod.ID != "foo" { if pod.Name != "foo" {
t.Errorf("Unexpected pod: %#v %s", pod, resp.Node.Value) t.Errorf("Unexpected pod: %#v %s", pod, resp.Node.Value)
} }
var boundPods api.BoundPods var boundPods api.BoundPods
@@ -363,7 +363,7 @@ func TestEtcdCreatePodWithContainersNotFound(t *testing.T) {
} }
err = latest.Codec.DecodeInto([]byte(resp.Node.Value), &boundPods) err = latest.Codec.DecodeInto([]byte(resp.Node.Value), &boundPods)
if len(boundPods.Items) != 1 || boundPods.Items[0].ID != "foo" { if len(boundPods.Items) != 1 || boundPods.Items[0].Name != "foo" {
t.Errorf("Unexpected boundPod list: %#v", boundPods) t.Errorf("Unexpected boundPod list: %#v", boundPods)
} }
} }
@@ -381,13 +381,13 @@ func TestEtcdCreatePodWithExistingContainers(t *testing.T) {
} }
fakeClient.Set("/registry/nodes/machine/boundpods", runtime.EncodeOrDie(latest.Codec, &api.BoundPods{ fakeClient.Set("/registry/nodes/machine/boundpods", runtime.EncodeOrDie(latest.Codec, &api.BoundPods{
Items: []api.BoundPod{ Items: []api.BoundPod{
{TypeMeta: api.TypeMeta{ID: "bar"}}, {TypeMeta: api.TypeMeta{Name: "bar"}},
}, },
}), 0) }), 0)
registry := NewTestEtcdRegistry(fakeClient) registry := NewTestEtcdRegistry(fakeClient)
err := registry.CreatePod(ctx, &api.Pod{ err := registry.CreatePod(ctx, &api.Pod{
TypeMeta: api.TypeMeta{ TypeMeta: api.TypeMeta{
ID: "foo", Name: "foo",
}, },
DesiredState: api.PodState{ DesiredState: api.PodState{
Manifest: api.ContainerManifest{ Manifest: api.ContainerManifest{
@@ -420,7 +420,7 @@ func TestEtcdCreatePodWithExistingContainers(t *testing.T) {
t.Errorf("unexpected error: %v", err) t.Errorf("unexpected error: %v", err)
} }
if pod.ID != "foo" { if pod.Name != "foo" {
t.Errorf("Unexpected pod: %#v %s", pod, resp.Node.Value) t.Errorf("Unexpected pod: %#v %s", pod, resp.Node.Value)
} }
var boundPods api.BoundPods var boundPods api.BoundPods
@@ -430,7 +430,7 @@ func TestEtcdCreatePodWithExistingContainers(t *testing.T) {
} }
err = latest.Codec.DecodeInto([]byte(resp.Node.Value), &boundPods) err = latest.Codec.DecodeInto([]byte(resp.Node.Value), &boundPods)
if len(boundPods.Items) != 2 || boundPods.Items[1].ID != "foo" { if len(boundPods.Items) != 2 || boundPods.Items[1].Name != "foo" {
t.Errorf("Unexpected boundPod list: %#v", boundPods) t.Errorf("Unexpected boundPod list: %#v", boundPods)
} }
} }
@@ -448,7 +448,7 @@ func TestEtcdUpdatePodNotFound(t *testing.T) {
registry := NewTestEtcdRegistry(fakeClient) registry := NewTestEtcdRegistry(fakeClient)
podIn := api.Pod{ podIn := api.Pod{
TypeMeta: api.TypeMeta{ID: "foo", ResourceVersion: "1"}, TypeMeta: api.TypeMeta{Name: "foo", ResourceVersion: "1"},
Labels: map[string]string{ Labels: map[string]string{
"foo": "bar", "foo": "bar",
}, },
@@ -466,12 +466,12 @@ func TestEtcdUpdatePodNotScheduled(t *testing.T) {
key, _ := makePodKey(ctx, "foo") key, _ := makePodKey(ctx, "foo")
fakeClient.Set(key, runtime.EncodeOrDie(latest.Codec, &api.Pod{ fakeClient.Set(key, runtime.EncodeOrDie(latest.Codec, &api.Pod{
TypeMeta: api.TypeMeta{ID: "foo"}, TypeMeta: api.TypeMeta{Name: "foo"},
}), 1) }), 1)
registry := NewTestEtcdRegistry(fakeClient) registry := NewTestEtcdRegistry(fakeClient)
podIn := api.Pod{ podIn := api.Pod{
TypeMeta: api.TypeMeta{ID: "foo", ResourceVersion: "1"}, TypeMeta: api.TypeMeta{Name: "foo", ResourceVersion: "1"},
Labels: map[string]string{ Labels: map[string]string{
"foo": "bar", "foo": "bar",
}, },
@@ -498,7 +498,7 @@ func TestEtcdUpdatePodScheduled(t *testing.T) {
key, _ := makePodKey(ctx, "foo") key, _ := makePodKey(ctx, "foo")
fakeClient.Set(key, runtime.EncodeOrDie(latest.Codec, &api.Pod{ fakeClient.Set(key, runtime.EncodeOrDie(latest.Codec, &api.Pod{
TypeMeta: api.TypeMeta{ID: "foo"}, TypeMeta: api.TypeMeta{Name: "foo"},
DesiredState: api.PodState{ DesiredState: api.PodState{
Host: "machine", Host: "machine",
Manifest: api.ContainerManifest{ Manifest: api.ContainerManifest{
@@ -536,7 +536,7 @@ func TestEtcdUpdatePodScheduled(t *testing.T) {
registry := NewTestEtcdRegistry(fakeClient) registry := NewTestEtcdRegistry(fakeClient)
podIn := api.Pod{ podIn := api.Pod{
TypeMeta: api.TypeMeta{ID: "foo", ResourceVersion: "1"}, TypeMeta: api.TypeMeta{Name: "foo", ResourceVersion: "1"},
DesiredState: api.PodState{ DesiredState: api.PodState{
Manifest: api.ContainerManifest{ Manifest: api.ContainerManifest{
ID: "foo", ID: "foo",
@@ -584,12 +584,12 @@ func TestEtcdDeletePod(t *testing.T) {
key, _ := makePodKey(ctx, "foo") key, _ := makePodKey(ctx, "foo")
fakeClient.Set(key, runtime.EncodeOrDie(latest.Codec, &api.Pod{ fakeClient.Set(key, runtime.EncodeOrDie(latest.Codec, &api.Pod{
TypeMeta: api.TypeMeta{ID: "foo"}, TypeMeta: api.TypeMeta{Name: "foo"},
DesiredState: api.PodState{Host: "machine"}, DesiredState: api.PodState{Host: "machine"},
}), 0) }), 0)
fakeClient.Set("/registry/nodes/machine/boundpods", runtime.EncodeOrDie(latest.Codec, &api.BoundPods{ fakeClient.Set("/registry/nodes/machine/boundpods", runtime.EncodeOrDie(latest.Codec, &api.BoundPods{
Items: []api.BoundPod{ Items: []api.BoundPod{
{TypeMeta: api.TypeMeta{ID: "foo"}}, {TypeMeta: api.TypeMeta{Name: "foo"}},
}, },
}), 0) }), 0)
registry := NewTestEtcdRegistry(fakeClient) registry := NewTestEtcdRegistry(fakeClient)
@@ -620,13 +620,13 @@ func TestEtcdDeletePodMultipleContainers(t *testing.T) {
fakeClient.TestIndex = true fakeClient.TestIndex = true
key, _ := makePodKey(ctx, "foo") key, _ := makePodKey(ctx, "foo")
fakeClient.Set(key, runtime.EncodeOrDie(latest.Codec, &api.Pod{ fakeClient.Set(key, runtime.EncodeOrDie(latest.Codec, &api.Pod{
TypeMeta: api.TypeMeta{ID: "foo"}, TypeMeta: api.TypeMeta{Name: "foo"},
DesiredState: api.PodState{Host: "machine"}, DesiredState: api.PodState{Host: "machine"},
}), 0) }), 0)
fakeClient.Set("/registry/nodes/machine/boundpods", runtime.EncodeOrDie(latest.Codec, &api.BoundPods{ fakeClient.Set("/registry/nodes/machine/boundpods", runtime.EncodeOrDie(latest.Codec, &api.BoundPods{
Items: []api.BoundPod{ Items: []api.BoundPod{
{TypeMeta: api.TypeMeta{ID: "foo"}}, {TypeMeta: api.TypeMeta{Name: "foo"}},
{TypeMeta: api.TypeMeta{ID: "bar"}}, {TypeMeta: api.TypeMeta{Name: "bar"}},
}, },
}), 0) }), 0)
registry := NewTestEtcdRegistry(fakeClient) registry := NewTestEtcdRegistry(fakeClient)
@@ -650,7 +650,7 @@ func TestEtcdDeletePodMultipleContainers(t *testing.T) {
if len(boundPods.Items) != 1 { if len(boundPods.Items) != 1 {
t.Fatalf("Unexpected boundPod set: %#v, expected empty", boundPods) t.Fatalf("Unexpected boundPod set: %#v, expected empty", boundPods)
} }
if boundPods.Items[0].ID != "bar" { if boundPods.Items[0].Name != "bar" {
t.Errorf("Deleted wrong boundPod: %#v", boundPods) t.Errorf("Deleted wrong boundPod: %#v", boundPods)
} }
} }
@@ -706,13 +706,13 @@ func TestEtcdListPods(t *testing.T) {
Nodes: []*etcd.Node{ Nodes: []*etcd.Node{
{ {
Value: runtime.EncodeOrDie(latest.Codec, &api.Pod{ Value: runtime.EncodeOrDie(latest.Codec, &api.Pod{
TypeMeta: api.TypeMeta{ID: "foo"}, TypeMeta: api.TypeMeta{Name: "foo"},
DesiredState: api.PodState{Host: "machine"}, DesiredState: api.PodState{Host: "machine"},
}), }),
}, },
{ {
Value: runtime.EncodeOrDie(latest.Codec, &api.Pod{ Value: runtime.EncodeOrDie(latest.Codec, &api.Pod{
TypeMeta: api.TypeMeta{ID: "bar"}, TypeMeta: api.TypeMeta{Name: "bar"},
DesiredState: api.PodState{Host: "machine"}, DesiredState: api.PodState{Host: "machine"},
}), }),
}, },
@@ -727,7 +727,7 @@ func TestEtcdListPods(t *testing.T) {
t.Errorf("unexpected error: %v", err) t.Errorf("unexpected error: %v", err)
} }
if len(pods.Items) != 2 || pods.Items[0].ID != "foo" || pods.Items[1].ID != "bar" { if len(pods.Items) != 2 || pods.Items[0].Name != "foo" || pods.Items[1].Name != "bar" {
t.Errorf("Unexpected pod list: %#v", pods) t.Errorf("Unexpected pod list: %#v", pods)
} }
if pods.Items[0].CurrentState.Host != "machine" || if pods.Items[0].CurrentState.Host != "machine" ||
@@ -783,10 +783,10 @@ func TestEtcdListControllers(t *testing.T) {
Node: &etcd.Node{ Node: &etcd.Node{
Nodes: []*etcd.Node{ Nodes: []*etcd.Node{
{ {
Value: runtime.EncodeOrDie(latest.Codec, &api.ReplicationController{TypeMeta: api.TypeMeta{ID: "foo"}}), Value: runtime.EncodeOrDie(latest.Codec, &api.ReplicationController{TypeMeta: api.TypeMeta{Name: "foo"}}),
}, },
{ {
Value: runtime.EncodeOrDie(latest.Codec, &api.ReplicationController{TypeMeta: api.TypeMeta{ID: "bar"}}), Value: runtime.EncodeOrDie(latest.Codec, &api.ReplicationController{TypeMeta: api.TypeMeta{Name: "bar"}}),
}, },
}, },
}, },
@@ -799,7 +799,7 @@ func TestEtcdListControllers(t *testing.T) {
t.Errorf("unexpected error: %v", err) t.Errorf("unexpected error: %v", err)
} }
if len(controllers.Items) != 2 || controllers.Items[0].ID != "foo" || controllers.Items[1].ID != "bar" { if len(controllers.Items) != 2 || controllers.Items[0].Name != "foo" || controllers.Items[1].Name != "bar" {
t.Errorf("Unexpected controller list: %#v", controllers) t.Errorf("Unexpected controller list: %#v", controllers)
} }
} }
@@ -814,8 +814,8 @@ func TestEtcdGetControllerDifferentNamespace(t *testing.T) {
key1, _ := makeControllerKey(ctx1, "foo") key1, _ := makeControllerKey(ctx1, "foo")
key2, _ := makeControllerKey(ctx2, "foo") key2, _ := makeControllerKey(ctx2, "foo")
fakeClient.Set(key1, runtime.EncodeOrDie(latest.Codec, &api.ReplicationController{TypeMeta: api.TypeMeta{Namespace: "default", ID: "foo"}}), 0) fakeClient.Set(key1, runtime.EncodeOrDie(latest.Codec, &api.ReplicationController{TypeMeta: api.TypeMeta{Namespace: "default", Name: "foo"}}), 0)
fakeClient.Set(key2, runtime.EncodeOrDie(latest.Codec, &api.ReplicationController{TypeMeta: api.TypeMeta{Namespace: "other", ID: "foo"}}), 0) fakeClient.Set(key2, runtime.EncodeOrDie(latest.Codec, &api.ReplicationController{TypeMeta: api.TypeMeta{Namespace: "other", Name: "foo"}}), 0)
registry := NewTestEtcdRegistry(fakeClient) registry := NewTestEtcdRegistry(fakeClient)
@@ -823,7 +823,7 @@ func TestEtcdGetControllerDifferentNamespace(t *testing.T) {
if err != nil { if err != nil {
t.Errorf("unexpected error: %v", err) t.Errorf("unexpected error: %v", err)
} }
if ctrl1.ID != "foo" { if ctrl1.Name != "foo" {
t.Errorf("Unexpected controller: %#v", ctrl1) t.Errorf("Unexpected controller: %#v", ctrl1)
} }
if ctrl1.Namespace != "default" { if ctrl1.Namespace != "default" {
@@ -834,7 +834,7 @@ func TestEtcdGetControllerDifferentNamespace(t *testing.T) {
if err != nil { if err != nil {
t.Errorf("unexpected error: %v", err) t.Errorf("unexpected error: %v", err)
} }
if ctrl2.ID != "foo" { if ctrl2.Name != "foo" {
t.Errorf("Unexpected controller: %#v", ctrl2) t.Errorf("Unexpected controller: %#v", ctrl2)
} }
if ctrl2.Namespace != "other" { if ctrl2.Namespace != "other" {
@@ -847,14 +847,14 @@ func TestEtcdGetController(t *testing.T) {
ctx := api.NewDefaultContext() ctx := api.NewDefaultContext()
fakeClient := tools.NewFakeEtcdClient(t) fakeClient := tools.NewFakeEtcdClient(t)
key, _ := makeControllerKey(ctx, "foo") key, _ := makeControllerKey(ctx, "foo")
fakeClient.Set(key, runtime.EncodeOrDie(latest.Codec, &api.ReplicationController{TypeMeta: api.TypeMeta{ID: "foo"}}), 0) fakeClient.Set(key, runtime.EncodeOrDie(latest.Codec, &api.ReplicationController{TypeMeta: api.TypeMeta{Name: "foo"}}), 0)
registry := NewTestEtcdRegistry(fakeClient) registry := NewTestEtcdRegistry(fakeClient)
ctrl, err := registry.GetController(ctx, "foo") ctrl, err := registry.GetController(ctx, "foo")
if err != nil { if err != nil {
t.Errorf("unexpected error: %v", err) t.Errorf("unexpected error: %v", err)
} }
if ctrl.ID != "foo" { if ctrl.Name != "foo" {
t.Errorf("Unexpected controller: %#v", ctrl) t.Errorf("Unexpected controller: %#v", ctrl)
} }
} }
@@ -904,7 +904,7 @@ func TestEtcdCreateController(t *testing.T) {
key, _ := makeControllerKey(ctx, "foo") key, _ := makeControllerKey(ctx, "foo")
err := registry.CreateController(ctx, &api.ReplicationController{ err := registry.CreateController(ctx, &api.ReplicationController{
TypeMeta: api.TypeMeta{ TypeMeta: api.TypeMeta{
ID: "foo", Name: "foo",
}, },
}) })
if err != nil { if err != nil {
@@ -920,7 +920,7 @@ func TestEtcdCreateController(t *testing.T) {
t.Errorf("unexpected error: %v", err) t.Errorf("unexpected error: %v", err)
} }
if ctrl.ID != "foo" { if ctrl.Name != "foo" {
t.Errorf("Unexpected pod: %#v %s", ctrl, resp.Node.Value) t.Errorf("Unexpected pod: %#v %s", ctrl, resp.Node.Value)
} }
} }
@@ -929,12 +929,12 @@ func TestEtcdCreateControllerAlreadyExisting(t *testing.T) {
ctx := api.NewDefaultContext() ctx := api.NewDefaultContext()
fakeClient := tools.NewFakeEtcdClient(t) fakeClient := tools.NewFakeEtcdClient(t)
key, _ := makeControllerKey(ctx, "foo") key, _ := makeControllerKey(ctx, "foo")
fakeClient.Set(key, runtime.EncodeOrDie(latest.Codec, &api.ReplicationController{TypeMeta: api.TypeMeta{ID: "foo"}}), 0) fakeClient.Set(key, runtime.EncodeOrDie(latest.Codec, &api.ReplicationController{TypeMeta: api.TypeMeta{Name: "foo"}}), 0)
registry := NewTestEtcdRegistry(fakeClient) registry := NewTestEtcdRegistry(fakeClient)
err := registry.CreateController(ctx, &api.ReplicationController{ err := registry.CreateController(ctx, &api.ReplicationController{
TypeMeta: api.TypeMeta{ TypeMeta: api.TypeMeta{
ID: "foo", Name: "foo",
}, },
}) })
if !errors.IsAlreadyExists(err) { if !errors.IsAlreadyExists(err) {
@@ -947,10 +947,10 @@ func TestEtcdUpdateController(t *testing.T) {
fakeClient := tools.NewFakeEtcdClient(t) fakeClient := tools.NewFakeEtcdClient(t)
fakeClient.TestIndex = true fakeClient.TestIndex = true
key, _ := makeControllerKey(ctx, "foo") key, _ := makeControllerKey(ctx, "foo")
resp, _ := fakeClient.Set(key, runtime.EncodeOrDie(latest.Codec, &api.ReplicationController{TypeMeta: api.TypeMeta{ID: "foo"}}), 0) resp, _ := fakeClient.Set(key, runtime.EncodeOrDie(latest.Codec, &api.ReplicationController{TypeMeta: api.TypeMeta{Name: "foo"}}), 0)
registry := NewTestEtcdRegistry(fakeClient) registry := NewTestEtcdRegistry(fakeClient)
err := registry.UpdateController(ctx, &api.ReplicationController{ err := registry.UpdateController(ctx, &api.ReplicationController{
TypeMeta: api.TypeMeta{ID: "foo", ResourceVersion: strconv.FormatUint(resp.Node.ModifiedIndex, 10)}, TypeMeta: api.TypeMeta{Name: "foo", ResourceVersion: strconv.FormatUint(resp.Node.ModifiedIndex, 10)},
DesiredState: api.ReplicationControllerState{ DesiredState: api.ReplicationControllerState{
Replicas: 2, Replicas: 2,
}, },
@@ -974,10 +974,10 @@ func TestEtcdListServices(t *testing.T) {
Node: &etcd.Node{ Node: &etcd.Node{
Nodes: []*etcd.Node{ Nodes: []*etcd.Node{
{ {
Value: runtime.EncodeOrDie(latest.Codec, &api.Service{TypeMeta: api.TypeMeta{ID: "foo"}}), Value: runtime.EncodeOrDie(latest.Codec, &api.Service{TypeMeta: api.TypeMeta{Name: "foo"}}),
}, },
{ {
Value: runtime.EncodeOrDie(latest.Codec, &api.Service{TypeMeta: api.TypeMeta{ID: "bar"}}), Value: runtime.EncodeOrDie(latest.Codec, &api.Service{TypeMeta: api.TypeMeta{Name: "bar"}}),
}, },
}, },
}, },
@@ -990,7 +990,7 @@ func TestEtcdListServices(t *testing.T) {
t.Errorf("unexpected error: %v", err) t.Errorf("unexpected error: %v", err)
} }
if len(services.Items) != 2 || services.Items[0].ID != "foo" || services.Items[1].ID != "bar" { if len(services.Items) != 2 || services.Items[0].Name != "foo" || services.Items[1].Name != "bar" {
t.Errorf("Unexpected service list: %#v", services) t.Errorf("Unexpected service list: %#v", services)
} }
} }
@@ -1000,7 +1000,7 @@ func TestEtcdCreateService(t *testing.T) {
fakeClient := tools.NewFakeEtcdClient(t) fakeClient := tools.NewFakeEtcdClient(t)
registry := NewTestEtcdRegistry(fakeClient) registry := NewTestEtcdRegistry(fakeClient)
err := registry.CreateService(ctx, &api.Service{ err := registry.CreateService(ctx, &api.Service{
TypeMeta: api.TypeMeta{ID: "foo"}, TypeMeta: api.TypeMeta{Name: "foo"},
}) })
if err != nil { if err != nil {
t.Errorf("unexpected error: %v", err) t.Errorf("unexpected error: %v", err)
@@ -1018,7 +1018,7 @@ func TestEtcdCreateService(t *testing.T) {
t.Errorf("unexpected error: %v", err) t.Errorf("unexpected error: %v", err)
} }
if service.ID != "foo" { if service.Name != "foo" {
t.Errorf("Unexpected service: %#v %s", service, resp.Node.Value) t.Errorf("Unexpected service: %#v %s", service, resp.Node.Value)
} }
} }
@@ -1027,10 +1027,10 @@ func TestEtcdCreateServiceAlreadyExisting(t *testing.T) {
ctx := api.NewDefaultContext() ctx := api.NewDefaultContext()
fakeClient := tools.NewFakeEtcdClient(t) fakeClient := tools.NewFakeEtcdClient(t)
key, _ := makeServiceKey(ctx, "foo") key, _ := makeServiceKey(ctx, "foo")
fakeClient.Set(key, runtime.EncodeOrDie(latest.Codec, &api.Service{TypeMeta: api.TypeMeta{ID: "foo"}}), 0) fakeClient.Set(key, runtime.EncodeOrDie(latest.Codec, &api.Service{TypeMeta: api.TypeMeta{Name: "foo"}}), 0)
registry := NewTestEtcdRegistry(fakeClient) registry := NewTestEtcdRegistry(fakeClient)
err := registry.CreateService(ctx, &api.Service{ err := registry.CreateService(ctx, &api.Service{
TypeMeta: api.TypeMeta{ID: "foo"}, TypeMeta: api.TypeMeta{Name: "foo"},
}) })
if !errors.IsAlreadyExists(err) { if !errors.IsAlreadyExists(err) {
t.Errorf("expected already exists err, got %#v", err) t.Errorf("expected already exists err, got %#v", err)
@@ -1047,8 +1047,8 @@ func TestEtcdGetServiceDifferentNamespace(t *testing.T) {
key1, _ := makeServiceKey(ctx1, "foo") key1, _ := makeServiceKey(ctx1, "foo")
key2, _ := makeServiceKey(ctx2, "foo") key2, _ := makeServiceKey(ctx2, "foo")
fakeClient.Set(key1, runtime.EncodeOrDie(latest.Codec, &api.Service{TypeMeta: api.TypeMeta{Namespace: "default", ID: "foo"}}), 0) fakeClient.Set(key1, runtime.EncodeOrDie(latest.Codec, &api.Service{TypeMeta: api.TypeMeta{Namespace: "default", Name: "foo"}}), 0)
fakeClient.Set(key2, runtime.EncodeOrDie(latest.Codec, &api.Service{TypeMeta: api.TypeMeta{Namespace: "other", ID: "foo"}}), 0) fakeClient.Set(key2, runtime.EncodeOrDie(latest.Codec, &api.Service{TypeMeta: api.TypeMeta{Namespace: "other", Name: "foo"}}), 0)
registry := NewTestEtcdRegistry(fakeClient) registry := NewTestEtcdRegistry(fakeClient)
@@ -1056,7 +1056,7 @@ func TestEtcdGetServiceDifferentNamespace(t *testing.T) {
if err != nil { if err != nil {
t.Errorf("unexpected error: %v", err) t.Errorf("unexpected error: %v", err)
} }
if service1.ID != "foo" { if service1.Name != "foo" {
t.Errorf("Unexpected service: %#v", service1) t.Errorf("Unexpected service: %#v", service1)
} }
if service1.Namespace != "default" { if service1.Namespace != "default" {
@@ -1067,7 +1067,7 @@ func TestEtcdGetServiceDifferentNamespace(t *testing.T) {
if err != nil { if err != nil {
t.Errorf("unexpected error: %v", err) t.Errorf("unexpected error: %v", err)
} }
if service2.ID != "foo" { if service2.Name != "foo" {
t.Errorf("Unexpected service: %#v", service2) t.Errorf("Unexpected service: %#v", service2)
} }
if service2.Namespace != "other" { if service2.Namespace != "other" {
@@ -1080,14 +1080,14 @@ func TestEtcdGetService(t *testing.T) {
ctx := api.NewDefaultContext() ctx := api.NewDefaultContext()
fakeClient := tools.NewFakeEtcdClient(t) fakeClient := tools.NewFakeEtcdClient(t)
key, _ := makeServiceKey(ctx, "foo") key, _ := makeServiceKey(ctx, "foo")
fakeClient.Set(key, runtime.EncodeOrDie(latest.Codec, &api.Service{TypeMeta: api.TypeMeta{ID: "foo"}}), 0) fakeClient.Set(key, runtime.EncodeOrDie(latest.Codec, &api.Service{TypeMeta: api.TypeMeta{Name: "foo"}}), 0)
registry := NewTestEtcdRegistry(fakeClient) registry := NewTestEtcdRegistry(fakeClient)
service, err := registry.GetService(ctx, "foo") service, err := registry.GetService(ctx, "foo")
if err != nil { if err != nil {
t.Errorf("unexpected error: %v", err) t.Errorf("unexpected error: %v", err)
} }
if service.ID != "foo" { if service.Name != "foo" {
t.Errorf("Unexpected service: %#v", service) t.Errorf("Unexpected service: %#v", service)
} }
} }
@@ -1136,10 +1136,10 @@ func TestEtcdUpdateService(t *testing.T) {
fakeClient := tools.NewFakeEtcdClient(t) fakeClient := tools.NewFakeEtcdClient(t)
fakeClient.TestIndex = true fakeClient.TestIndex = true
key, _ := makeServiceKey(ctx, "foo") key, _ := makeServiceKey(ctx, "foo")
resp, _ := fakeClient.Set(key, runtime.EncodeOrDie(latest.Codec, &api.Service{TypeMeta: api.TypeMeta{ID: "foo"}}), 0) resp, _ := fakeClient.Set(key, runtime.EncodeOrDie(latest.Codec, &api.Service{TypeMeta: api.TypeMeta{Name: "foo"}}), 0)
registry := NewTestEtcdRegistry(fakeClient) registry := NewTestEtcdRegistry(fakeClient)
testService := api.Service{ testService := api.Service{
TypeMeta: api.TypeMeta{ID: "foo", ResourceVersion: strconv.FormatUint(resp.Node.ModifiedIndex, 10)}, TypeMeta: api.TypeMeta{Name: "foo", ResourceVersion: strconv.FormatUint(resp.Node.ModifiedIndex, 10)},
Labels: map[string]string{ Labels: map[string]string{
"baz": "bar", "baz": "bar",
}, },
@@ -1174,10 +1174,10 @@ func TestEtcdListEndpoints(t *testing.T) {
Node: &etcd.Node{ Node: &etcd.Node{
Nodes: []*etcd.Node{ Nodes: []*etcd.Node{
{ {
Value: runtime.EncodeOrDie(latest.Codec, &api.Endpoints{TypeMeta: api.TypeMeta{ID: "foo"}, Endpoints: []string{"127.0.0.1:8345"}}), Value: runtime.EncodeOrDie(latest.Codec, &api.Endpoints{TypeMeta: api.TypeMeta{Name: "foo"}, Endpoints: []string{"127.0.0.1:8345"}}),
}, },
{ {
Value: runtime.EncodeOrDie(latest.Codec, &api.Endpoints{TypeMeta: api.TypeMeta{ID: "bar"}}), Value: runtime.EncodeOrDie(latest.Codec, &api.Endpoints{TypeMeta: api.TypeMeta{Name: "bar"}}),
}, },
}, },
}, },
@@ -1190,7 +1190,7 @@ func TestEtcdListEndpoints(t *testing.T) {
t.Errorf("unexpected error: %v", err) t.Errorf("unexpected error: %v", err)
} }
if len(services.Items) != 2 || services.Items[0].ID != "foo" || services.Items[1].ID != "bar" { if len(services.Items) != 2 || services.Items[0].Name != "foo" || services.Items[1].Name != "bar" {
t.Errorf("Unexpected endpoints list: %#v", services) t.Errorf("Unexpected endpoints list: %#v", services)
} }
} }
@@ -1200,7 +1200,7 @@ func TestEtcdGetEndpoints(t *testing.T) {
fakeClient := tools.NewFakeEtcdClient(t) fakeClient := tools.NewFakeEtcdClient(t)
registry := NewTestEtcdRegistry(fakeClient) registry := NewTestEtcdRegistry(fakeClient)
endpoints := &api.Endpoints{ endpoints := &api.Endpoints{
TypeMeta: api.TypeMeta{ID: "foo"}, TypeMeta: api.TypeMeta{Name: "foo"},
Endpoints: []string{"127.0.0.1:34855"}, Endpoints: []string{"127.0.0.1:34855"},
} }
@@ -1223,7 +1223,7 @@ func TestEtcdUpdateEndpoints(t *testing.T) {
fakeClient.TestIndex = true fakeClient.TestIndex = true
registry := NewTestEtcdRegistry(fakeClient) registry := NewTestEtcdRegistry(fakeClient)
endpoints := api.Endpoints{ endpoints := api.Endpoints{
TypeMeta: api.TypeMeta{ID: "foo"}, TypeMeta: api.TypeMeta{Name: "foo"},
Endpoints: []string{"baz", "bar"}, Endpoints: []string{"baz", "bar"},
} }
@@ -1392,12 +1392,12 @@ func TestEtcdListMinions(t *testing.T) {
Nodes: []*etcd.Node{ Nodes: []*etcd.Node{
{ {
Value: runtime.EncodeOrDie(latest.Codec, &api.Minion{ Value: runtime.EncodeOrDie(latest.Codec, &api.Minion{
TypeMeta: api.TypeMeta{ID: "foo"}, TypeMeta: api.TypeMeta{Name: "foo"},
}), }),
}, },
{ {
Value: runtime.EncodeOrDie(latest.Codec, &api.Minion{ Value: runtime.EncodeOrDie(latest.Codec, &api.Minion{
TypeMeta: api.TypeMeta{ID: "bar"}, TypeMeta: api.TypeMeta{Name: "bar"},
}), }),
}, },
}, },
@@ -1411,7 +1411,7 @@ func TestEtcdListMinions(t *testing.T) {
t.Errorf("unexpected error: %v", err) t.Errorf("unexpected error: %v", err)
} }
if len(minions.Items) != 2 || minions.Items[0].ID != "foo" || minions.Items[1].ID != "bar" { if len(minions.Items) != 2 || minions.Items[0].Name != "foo" || minions.Items[1].Name != "bar" {
t.Errorf("Unexpected minion list: %#v", minions) t.Errorf("Unexpected minion list: %#v", minions)
} }
} }
@@ -1421,7 +1421,7 @@ func TestEtcdCreateMinion(t *testing.T) {
fakeClient := tools.NewFakeEtcdClient(t) fakeClient := tools.NewFakeEtcdClient(t)
registry := NewTestEtcdRegistry(fakeClient) registry := NewTestEtcdRegistry(fakeClient)
err := registry.CreateMinion(ctx, &api.Minion{ err := registry.CreateMinion(ctx, &api.Minion{
TypeMeta: api.TypeMeta{ID: "foo"}, TypeMeta: api.TypeMeta{Name: "foo"},
}) })
if err != nil { if err != nil {
t.Errorf("unexpected error: %v", err) t.Errorf("unexpected error: %v", err)
@@ -1438,7 +1438,7 @@ func TestEtcdCreateMinion(t *testing.T) {
t.Errorf("unexpected error: %v", err) t.Errorf("unexpected error: %v", err)
} }
if minion.ID != "foo" { if minion.Name != "foo" {
t.Errorf("Unexpected minion: %#v %s", minion, resp.Node.Value) t.Errorf("Unexpected minion: %#v %s", minion, resp.Node.Value)
} }
} }
@@ -1446,14 +1446,14 @@ func TestEtcdCreateMinion(t *testing.T) {
func TestEtcdGetMinion(t *testing.T) { func TestEtcdGetMinion(t *testing.T) {
ctx := api.NewContext() ctx := api.NewContext()
fakeClient := tools.NewFakeEtcdClient(t) fakeClient := tools.NewFakeEtcdClient(t)
fakeClient.Set("/registry/minions/foo", runtime.EncodeOrDie(latest.Codec, &api.Minion{TypeMeta: api.TypeMeta{ID: "foo"}}), 0) fakeClient.Set("/registry/minions/foo", runtime.EncodeOrDie(latest.Codec, &api.Minion{TypeMeta: api.TypeMeta{Name: "foo"}}), 0)
registry := NewTestEtcdRegistry(fakeClient) registry := NewTestEtcdRegistry(fakeClient)
minion, err := registry.GetMinion(ctx, "foo") minion, err := registry.GetMinion(ctx, "foo")
if err != nil { if err != nil {
t.Errorf("unexpected error: %v", err) t.Errorf("unexpected error: %v", err)
} }
if minion.ID != "foo" { if minion.Name != "foo" {
t.Errorf("Unexpected minion: %#v", minion) t.Errorf("Unexpected minion: %#v", minion)
} }
} }

View File

@@ -42,11 +42,11 @@ func NewTestEventEtcdRegistry(t *testing.T) (*tools.FakeEtcdClient, generic.Regi
func TestEventCreate(t *testing.T) { func TestEventCreate(t *testing.T) {
eventA := &api.Event{ eventA := &api.Event{
TypeMeta: api.TypeMeta{ID: "foo"}, TypeMeta: api.TypeMeta{Name: "foo"},
Reason: "forTesting", Reason: "forTesting",
} }
eventB := &api.Event{ eventB := &api.Event{
TypeMeta: api.TypeMeta{ID: "foo"}, TypeMeta: api.TypeMeta{Name: "foo"},
Reason: "forTesting", Reason: "forTesting",
} }

View File

@@ -49,11 +49,11 @@ func (rs *REST) Create(ctx api.Context, obj runtime.Object) (<-chan runtime.Obje
event.CreationTimestamp = util.Now() event.CreationTimestamp = util.Now()
return apiserver.MakeAsync(func() (runtime.Object, error) { return apiserver.MakeAsync(func() (runtime.Object, error) {
err := rs.registry.Create(ctx, event.ID, event) err := rs.registry.Create(ctx, event.Name, event)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return rs.registry.Get(ctx, event.ID) return rs.registry.Get(ctx, event.Name)
}), nil }), nil
} }

View File

@@ -40,7 +40,7 @@ func NewTestREST() (testRegistry, *REST) {
func TestRESTCreate(t *testing.T) { func TestRESTCreate(t *testing.T) {
_, rest := NewTestREST() _, rest := NewTestREST()
eventA := &api.Event{ eventA := &api.Event{
TypeMeta: api.TypeMeta{ID: "foo"}, TypeMeta: api.TypeMeta{Name: "foo"},
Reason: "forTesting", Reason: "forTesting",
} }
c, err := rest.Create(api.NewContext(), eventA) c, err := rest.Create(api.NewContext(), eventA)
@@ -55,7 +55,7 @@ func TestRESTCreate(t *testing.T) {
func TestRESTDelete(t *testing.T) { func TestRESTDelete(t *testing.T) {
_, rest := NewTestREST() _, rest := NewTestREST()
eventA := &api.Event{ eventA := &api.Event{
TypeMeta: api.TypeMeta{ID: "foo"}, TypeMeta: api.TypeMeta{Name: "foo"},
Reason: "forTesting", Reason: "forTesting",
} }
c, err := rest.Create(api.NewContext(), eventA) c, err := rest.Create(api.NewContext(), eventA)
@@ -63,7 +63,7 @@ func TestRESTDelete(t *testing.T) {
t.Fatalf("Unexpected error %v", err) t.Fatalf("Unexpected error %v", err)
} }
<-c <-c
c, err = rest.Delete(api.NewContext(), eventA.ID) c, err = rest.Delete(api.NewContext(), eventA.Name)
if err != nil { if err != nil {
t.Fatalf("Unexpected error %v", err) t.Fatalf("Unexpected error %v", err)
} }
@@ -75,7 +75,7 @@ func TestRESTDelete(t *testing.T) {
func TestRESTGet(t *testing.T) { func TestRESTGet(t *testing.T) {
_, rest := NewTestREST() _, rest := NewTestREST()
eventA := &api.Event{ eventA := &api.Event{
TypeMeta: api.TypeMeta{ID: "foo"}, TypeMeta: api.TypeMeta{Name: "foo"},
Reason: "forTesting", Reason: "forTesting",
} }
c, err := rest.Create(api.NewContext(), eventA) c, err := rest.Create(api.NewContext(), eventA)
@@ -83,7 +83,7 @@ func TestRESTGet(t *testing.T) {
t.Fatalf("Unexpected error %v", err) t.Fatalf("Unexpected error %v", err)
} }
<-c <-c
got, err := rest.Get(api.NewContext(), eventA.ID) got, err := rest.Get(api.NewContext(), eventA.Name)
if err != nil { if err != nil {
t.Fatalf("Unexpected error %v", err) t.Fatalf("Unexpected error %v", err)
} }
@@ -131,7 +131,7 @@ func TestRESTgetAttrs(t *testing.T) {
func TestRESTUpdate(t *testing.T) { func TestRESTUpdate(t *testing.T) {
_, rest := NewTestREST() _, rest := NewTestREST()
eventA := &api.Event{ eventA := &api.Event{
TypeMeta: api.TypeMeta{ID: "foo"}, TypeMeta: api.TypeMeta{Name: "foo"},
Reason: "forTesting", Reason: "forTesting",
} }
c, err := rest.Create(api.NewContext(), eventA) c, err := rest.Create(api.NewContext(), eventA)

View File

@@ -60,7 +60,7 @@ func (sm SetMatcher) Matches(obj runtime.Object) (bool, error) {
if !ok { if !ok {
return false, fmt.Errorf("wrong object") return false, fmt.Errorf("wrong object")
} }
return sm.Has(pod.ID), nil return sm.Has(pod.Name), nil
} }
// EverythingMatcher matches everything // EverythingMatcher matches everything
@@ -72,11 +72,11 @@ func (EverythingMatcher) Matches(obj runtime.Object) (bool, error) {
func TestEtcdList(t *testing.T) { func TestEtcdList(t *testing.T) {
podA := &api.Pod{ podA := &api.Pod{
TypeMeta: api.TypeMeta{ID: "foo"}, TypeMeta: api.TypeMeta{Name: "foo"},
DesiredState: api.PodState{Host: "machine"}, DesiredState: api.PodState{Host: "machine"},
} }
podB := &api.Pod{ podB := &api.Pod{
TypeMeta: api.TypeMeta{ID: "bar"}, TypeMeta: api.TypeMeta{Name: "bar"},
DesiredState: api.PodState{Host: "machine"}, DesiredState: api.PodState{Host: "machine"},
} }
@@ -154,11 +154,11 @@ func TestEtcdList(t *testing.T) {
func TestEtcdCreate(t *testing.T) { func TestEtcdCreate(t *testing.T) {
podA := &api.Pod{ podA := &api.Pod{
TypeMeta: api.TypeMeta{ID: "foo"}, TypeMeta: api.TypeMeta{Name: "foo"},
DesiredState: api.PodState{Host: "machine"}, DesiredState: api.PodState{Host: "machine"},
} }
podB := &api.Pod{ podB := &api.Pod{
TypeMeta: api.TypeMeta{ID: "foo"}, TypeMeta: api.TypeMeta{Name: "foo"},
DesiredState: api.PodState{Host: "machine2"}, DesiredState: api.PodState{Host: "machine2"},
} }
@@ -217,11 +217,11 @@ func TestEtcdCreate(t *testing.T) {
func TestEtcdUpdate(t *testing.T) { func TestEtcdUpdate(t *testing.T) {
podA := &api.Pod{ podA := &api.Pod{
TypeMeta: api.TypeMeta{ID: "foo"}, TypeMeta: api.TypeMeta{Name: "foo"},
DesiredState: api.PodState{Host: "machine"}, DesiredState: api.PodState{Host: "machine"},
} }
podB := &api.Pod{ podB := &api.Pod{
TypeMeta: api.TypeMeta{ID: "foo", ResourceVersion: "1"}, TypeMeta: api.TypeMeta{Name: "foo", ResourceVersion: "1"},
DesiredState: api.PodState{Host: "machine2"}, DesiredState: api.PodState{Host: "machine2"},
} }
@@ -292,7 +292,7 @@ func TestEtcdUpdate(t *testing.T) {
func TestEtcdGet(t *testing.T) { func TestEtcdGet(t *testing.T) {
podA := &api.Pod{ podA := &api.Pod{
TypeMeta: api.TypeMeta{ID: "foo", ResourceVersion: "1"}, TypeMeta: api.TypeMeta{Name: "foo", ResourceVersion: "1"},
DesiredState: api.PodState{Host: "machine"}, DesiredState: api.PodState{Host: "machine"},
} }
@@ -348,7 +348,7 @@ func TestEtcdGet(t *testing.T) {
func TestEtcdDelete(t *testing.T) { func TestEtcdDelete(t *testing.T) {
podA := &api.Pod{ podA := &api.Pod{
TypeMeta: api.TypeMeta{ID: "foo", ResourceVersion: "1"}, TypeMeta: api.TypeMeta{Name: "foo", ResourceVersion: "1"},
DesiredState: api.PodState{Host: "machine"}, DesiredState: api.PodState{Host: "machine"},
} }
@@ -404,7 +404,7 @@ func TestEtcdDelete(t *testing.T) {
func TestEtcdWatch(t *testing.T) { func TestEtcdWatch(t *testing.T) {
podA := &api.Pod{ podA := &api.Pod{
TypeMeta: api.TypeMeta{ID: "foo", ResourceVersion: "1"}, TypeMeta: api.TypeMeta{Name: "foo", ResourceVersion: "1"},
DesiredState: api.PodState{Host: "machine"}, DesiredState: api.PodState{Host: "machine"},
} }
respWithPodA := &etcd.Response{ respWithPodA := &etcd.Response{

View File

@@ -73,7 +73,7 @@ func (r *HealthyRegistry) ListMinions(ctx api.Context) (currentMinions *api.Mini
return result, err return result, err
} }
for _, minion := range list.Items { for _, minion := range list.Items {
status, err := health.DoHTTPCheck(r.makeMinionURL(minion.ID), r.client) status, err := health.DoHTTPCheck(r.makeMinionURL(minion.Name), r.client)
if err != nil { if err != nil {
glog.V(1).Infof("%#v failed health check with error: %s", minion, err) glog.V(1).Infof("%#v failed health check with error: %s", minion, err)
continue continue

View File

@@ -55,7 +55,7 @@ func TestBasicDelegation(t *testing.T) {
t.Errorf("Expected %v, Got %v", mockMinionRegistry.Minions, list) t.Errorf("Expected %v, Got %v", mockMinionRegistry.Minions, list)
} }
err = healthy.CreateMinion(ctx, &api.Minion{ err = healthy.CreateMinion(ctx, &api.Minion{
TypeMeta: api.TypeMeta{ID: "foo"}, TypeMeta: api.TypeMeta{Name: "foo"},
}) })
if err != nil { if err != nil {
t.Errorf("unexpected error: %v", err) t.Errorf("unexpected error: %v", err)

View File

@@ -50,7 +50,7 @@ func (rs *REST) Create(ctx api.Context, obj runtime.Object) (<-chan runtime.Obje
if !ok { if !ok {
return nil, fmt.Errorf("not a minion: %#v", obj) return nil, fmt.Errorf("not a minion: %#v", obj)
} }
if minion.ID == "" { if minion.Name == "" {
return nil, fmt.Errorf("ID should not be empty: %#v", minion) return nil, fmt.Errorf("ID should not be empty: %#v", minion)
} }
@@ -61,7 +61,7 @@ func (rs *REST) Create(ctx api.Context, obj runtime.Object) (<-chan runtime.Obje
if err != nil { if err != nil {
return nil, err return nil, err
} }
minion, err := rs.registry.GetMinion(ctx, minion.ID) minion, err := rs.registry.GetMinion(ctx, minion.Name)
if minion == nil { if minion == nil {
return nil, ErrDoesNotExist return nil, ErrDoesNotExist
} }
@@ -106,7 +106,7 @@ func (rs *REST) Update(ctx api.Context, minion runtime.Object) (<-chan runtime.O
} }
func (rs *REST) toApiMinion(name string) *api.Minion { func (rs *REST) toApiMinion(name string) *api.Minion {
return &api.Minion{TypeMeta: api.TypeMeta{ID: name}} return &api.Minion{TypeMeta: api.TypeMeta{Name: name}}
} }
// ResourceLocation returns a URL to which one can send traffic for the specified minion. // ResourceLocation returns a URL to which one can send traffic for the specified minion.
@@ -117,7 +117,7 @@ func (rs *REST) ResourceLocation(ctx api.Context, id string) (string, error) {
} }
host := minion.HostIP host := minion.HostIP
if host == "" { if host == "" {
host = minion.ID host = minion.Name
} }
// TODO: Minion webservers should be secure! // TODO: Minion webservers should be secure!
return "http://" + net.JoinHostPort(host, strconv.Itoa(ports.KubeletPort)), nil return "http://" + net.JoinHostPort(host, strconv.Itoa(ports.KubeletPort)), nil

View File

@@ -27,25 +27,25 @@ import (
func TestMinionREST(t *testing.T) { func TestMinionREST(t *testing.T) {
ms := NewREST(registrytest.NewMinionRegistry([]string{"foo", "bar"}, api.NodeResources{})) ms := NewREST(registrytest.NewMinionRegistry([]string{"foo", "bar"}, api.NodeResources{}))
ctx := api.NewContext() ctx := api.NewContext()
if obj, err := ms.Get(ctx, "foo"); err != nil || obj.(*api.Minion).ID != "foo" { if obj, err := ms.Get(ctx, "foo"); err != nil || obj.(*api.Minion).Name != "foo" {
t.Errorf("missing expected object") t.Errorf("missing expected object")
} }
if obj, err := ms.Get(ctx, "bar"); err != nil || obj.(*api.Minion).ID != "bar" { if obj, err := ms.Get(ctx, "bar"); err != nil || obj.(*api.Minion).Name != "bar" {
t.Errorf("missing expected object") t.Errorf("missing expected object")
} }
if _, err := ms.Get(ctx, "baz"); err != ErrDoesNotExist { if _, err := ms.Get(ctx, "baz"); err != ErrDoesNotExist {
t.Errorf("has unexpected object") t.Errorf("has unexpected object")
} }
c, err := ms.Create(ctx, &api.Minion{TypeMeta: api.TypeMeta{ID: "baz"}}) c, err := ms.Create(ctx, &api.Minion{TypeMeta: api.TypeMeta{Name: "baz"}})
if err != nil { if err != nil {
t.Errorf("insert failed") t.Errorf("insert failed")
} }
obj := <-c obj := <-c
if m, ok := obj.(*api.Minion); !ok || m.ID != "baz" { if m, ok := obj.(*api.Minion); !ok || m.Name != "baz" {
t.Errorf("insert return value was weird: %#v", obj) t.Errorf("insert return value was weird: %#v", obj)
} }
if obj, err := ms.Get(ctx, "baz"); err != nil || obj.(*api.Minion).ID != "baz" { if obj, err := ms.Get(ctx, "baz"); err != nil || obj.(*api.Minion).Name != "baz" {
t.Errorf("insert didn't actually insert") t.Errorf("insert didn't actually insert")
} }
@@ -72,9 +72,9 @@ func TestMinionREST(t *testing.T) {
} }
expect := []api.Minion{ expect := []api.Minion{
{ {
TypeMeta: api.TypeMeta{ID: "foo"}, TypeMeta: api.TypeMeta{Name: "foo"},
}, { }, {
TypeMeta: api.TypeMeta{ID: "baz"}, TypeMeta: api.TypeMeta{Name: "baz"},
}, },
} }
nodeList := list.(*api.MinionList) nodeList := list.(*api.MinionList)
@@ -85,7 +85,7 @@ func TestMinionREST(t *testing.T) {
func contains(nodes *api.MinionList, nodeID string) bool { func contains(nodes *api.MinionList, nodeID string) bool {
for _, node := range nodes.Items { for _, node := range nodes.Items {
if node.ID == nodeID { if node.Name == nodeID {
return true return true
} }
} }

View File

@@ -32,7 +32,7 @@ func TestMakeBoundPodNoServices(t *testing.T) {
} }
pod, err := factory.MakeBoundPod("machine", &api.Pod{ pod, err := factory.MakeBoundPod("machine", &api.Pod{
TypeMeta: api.TypeMeta{ID: "foobar"}, TypeMeta: api.TypeMeta{Name: "foobar"},
DesiredState: api.PodState{ DesiredState: api.PodState{
Manifest: api.ContainerManifest{ Manifest: api.ContainerManifest{
Containers: []api.Container{ Containers: []api.Container{
@@ -51,8 +51,8 @@ func TestMakeBoundPodNoServices(t *testing.T) {
if len(container.Env) != 0 { if len(container.Env) != 0 {
t.Errorf("Expected zero env vars, got: %#v", pod) t.Errorf("Expected zero env vars, got: %#v", pod)
} }
if pod.ID != "foobar" { if pod.Name != "foobar" {
t.Errorf("Failed to assign ID to pod: %#v", pod.ID) t.Errorf("Failed to assign ID to pod: %#v", pod.Name)
} }
} }
@@ -61,7 +61,7 @@ func TestMakeBoundPodServices(t *testing.T) {
List: api.ServiceList{ List: api.ServiceList{
Items: []api.Service{ Items: []api.Service{
{ {
TypeMeta: api.TypeMeta{ID: "test"}, TypeMeta: api.TypeMeta{Name: "test"},
Port: 8080, Port: 8080,
ContainerPort: util.IntOrString{ ContainerPort: util.IntOrString{
Kind: util.IntstrInt, Kind: util.IntstrInt,
@@ -137,7 +137,7 @@ func TestMakeBoundPodServicesExistingEnvVar(t *testing.T) {
List: api.ServiceList{ List: api.ServiceList{
Items: []api.Service{ Items: []api.Service{
{ {
TypeMeta: api.TypeMeta{ID: "test"}, TypeMeta: api.TypeMeta{Name: "test"},
Port: 8080, Port: 8080,
ContainerPort: util.IntOrString{ ContainerPort: util.IntOrString{
Kind: util.IntstrInt, Kind: util.IntstrInt,

View File

@@ -94,12 +94,12 @@ func (rs *REST) Create(ctx api.Context, obj runtime.Object) (<-chan runtime.Obje
return nil, errors.NewConflict("pod", pod.Namespace, fmt.Errorf("Pod.Namespace does not match the provided context")) return nil, errors.NewConflict("pod", pod.Namespace, fmt.Errorf("Pod.Namespace does not match the provided context"))
} }
pod.DesiredState.Manifest.UUID = uuid.NewUUID().String() pod.DesiredState.Manifest.UUID = uuid.NewUUID().String()
if len(pod.ID) == 0 { if len(pod.Name) == 0 {
pod.ID = pod.DesiredState.Manifest.UUID pod.Name = pod.DesiredState.Manifest.UUID
} }
pod.DesiredState.Manifest.ID = pod.ID pod.DesiredState.Manifest.ID = pod.Name
if errs := validation.ValidatePod(pod); len(errs) > 0 { if errs := validation.ValidatePod(pod); len(errs) > 0 {
return nil, errors.NewInvalid("pod", pod.ID, errs) return nil, errors.NewInvalid("pod", pod.Name, errs)
} }
pod.CreationTimestamp = util.Now() pod.CreationTimestamp = util.Now()
@@ -107,7 +107,7 @@ func (rs *REST) Create(ctx api.Context, obj runtime.Object) (<-chan runtime.Obje
if err := rs.registry.CreatePod(ctx, pod); err != nil { if err := rs.registry.CreatePod(ctx, pod); err != nil {
return nil, err return nil, err
} }
return rs.registry.GetPod(ctx, pod.ID) return rs.registry.GetPod(ctx, pod.Name)
}), nil }), nil
} }
@@ -141,7 +141,7 @@ func (rs *REST) Get(ctx api.Context, id string) (runtime.Object, error) {
func (rs *REST) podToSelectableFields(pod *api.Pod) labels.Set { func (rs *REST) podToSelectableFields(pod *api.Pod) labels.Set {
return labels.Set{ return labels.Set{
"ID": pod.ID, "ID": pod.Name,
"DesiredState.Status": string(pod.DesiredState.Status), "DesiredState.Status": string(pod.DesiredState.Status),
"DesiredState.Host": pod.DesiredState.Host, "DesiredState.Host": pod.DesiredState.Host,
} }
@@ -190,13 +190,13 @@ func (rs *REST) Update(ctx api.Context, obj runtime.Object) (<-chan runtime.Obje
return nil, errors.NewConflict("pod", pod.Namespace, fmt.Errorf("Pod.Namespace does not match the provided context")) return nil, errors.NewConflict("pod", pod.Namespace, fmt.Errorf("Pod.Namespace does not match the provided context"))
} }
if errs := validation.ValidatePod(pod); len(errs) > 0 { if errs := validation.ValidatePod(pod); len(errs) > 0 {
return nil, errors.NewInvalid("pod", pod.ID, errs) return nil, errors.NewInvalid("pod", pod.Name, errs)
} }
return apiserver.MakeAsync(func() (runtime.Object, error) { return apiserver.MakeAsync(func() (runtime.Object, error) {
if err := rs.registry.UpdatePod(ctx, pod); err != nil { if err := rs.registry.UpdatePod(ctx, pod); err != nil {
return nil, err return nil, err
} }
return rs.registry.GetPod(ctx, pod.ID) return rs.registry.GetPod(ctx, pod.Name)
}), nil }), nil
} }
@@ -208,13 +208,13 @@ func (rs *REST) fillPodInfo(pod *api.Pod) {
// Get cached info for the list currently. // Get cached info for the list currently.
// TODO: Optionally use fresh info // TODO: Optionally use fresh info
if rs.podCache != nil { if rs.podCache != nil {
info, err := rs.podCache.GetPodInfo(pod.CurrentState.Host, pod.Namespace, pod.ID) info, err := rs.podCache.GetPodInfo(pod.CurrentState.Host, pod.Namespace, pod.Name)
if err != nil { if err != nil {
if err != client.ErrPodInfoNotAvailable { if err != client.ErrPodInfoNotAvailable {
glog.Errorf("Error getting container info from cache: %#v", err) glog.Errorf("Error getting container info from cache: %#v", err)
} }
if rs.podInfoGetter != nil { if rs.podInfoGetter != nil {
info, err = rs.podInfoGetter.GetPodInfo(pod.CurrentState.Host, pod.Namespace, pod.ID) info, err = rs.podInfoGetter.GetPodInfo(pod.CurrentState.Host, pod.Namespace, pod.Name)
} }
if err != nil { if err != nil {
if err != client.ErrPodInfoNotAvailable { if err != client.ErrPodInfoNotAvailable {
@@ -232,7 +232,7 @@ func (rs *REST) fillPodInfo(pod *api.Pod) {
glog.Warningf("No network settings: %#v", netContainerInfo) glog.Warningf("No network settings: %#v", netContainerInfo)
} }
} else { } else {
glog.Warningf("Couldn't find network container for %s in %v", pod.ID, info) glog.Warningf("Couldn't find network container for %s in %v", pod.Name, info)
} }
} }
} }
@@ -280,7 +280,7 @@ func getPodStatus(pod *api.Pod, minions client.MinionInterface) (api.PodStatus,
} }
found := false found := false
for _, minion := range res.Items { for _, minion := range res.Items {
if minion.ID == pod.CurrentState.Host { if minion.Name == pod.CurrentState.Host {
found = true found = true
break break
} }

View File

@@ -95,10 +95,10 @@ func TestCreatePodSetsIds(t *testing.T) {
} }
expectApiStatusError(t, ch, podRegistry.Err.Error()) expectApiStatusError(t, ch, podRegistry.Err.Error())
if len(podRegistry.Pod.ID) == 0 { if len(podRegistry.Pod.Name) == 0 {
t.Errorf("Expected pod ID to be set, Got %#v", pod) t.Errorf("Expected pod ID to be set, Got %#v", pod)
} }
if podRegistry.Pod.DesiredState.Manifest.ID != podRegistry.Pod.ID { if podRegistry.Pod.DesiredState.Manifest.ID != podRegistry.Pod.Name {
t.Errorf("Expected manifest ID to be equal to pod ID, Got %#v", pod) t.Errorf("Expected manifest ID to be equal to pod ID, Got %#v", pod)
} }
} }
@@ -176,12 +176,12 @@ func TestListPodList(t *testing.T) {
Items: []api.Pod{ Items: []api.Pod{
{ {
TypeMeta: api.TypeMeta{ TypeMeta: api.TypeMeta{
ID: "foo", Name: "foo",
}, },
}, },
{ {
TypeMeta: api.TypeMeta{ TypeMeta: api.TypeMeta{
ID: "bar", Name: "bar",
}, },
}, },
}, },
@@ -201,10 +201,10 @@ func TestListPodList(t *testing.T) {
if len(pods.Items) != 2 { if len(pods.Items) != 2 {
t.Errorf("Unexpected pod list: %#v", pods) t.Errorf("Unexpected pod list: %#v", pods)
} }
if pods.Items[0].ID != "foo" { if pods.Items[0].Name != "foo" {
t.Errorf("Unexpected pod: %#v", pods.Items[0]) t.Errorf("Unexpected pod: %#v", pods.Items[0])
} }
if pods.Items[1].ID != "bar" { if pods.Items[1].Name != "bar" {
t.Errorf("Unexpected pod: %#v", pods.Items[1]) t.Errorf("Unexpected pod: %#v", pods.Items[1])
} }
} }
@@ -214,18 +214,18 @@ func TestListPodListSelection(t *testing.T) {
podRegistry.Pods = &api.PodList{ podRegistry.Pods = &api.PodList{
Items: []api.Pod{ Items: []api.Pod{
{ {
TypeMeta: api.TypeMeta{ID: "foo"}, TypeMeta: api.TypeMeta{Name: "foo"},
}, { }, {
TypeMeta: api.TypeMeta{ID: "bar"}, TypeMeta: api.TypeMeta{Name: "bar"},
DesiredState: api.PodState{Host: "barhost"}, DesiredState: api.PodState{Host: "barhost"},
}, { }, {
TypeMeta: api.TypeMeta{ID: "baz"}, TypeMeta: api.TypeMeta{Name: "baz"},
DesiredState: api.PodState{Status: "bazstatus"}, DesiredState: api.PodState{Status: "bazstatus"},
}, { }, {
TypeMeta: api.TypeMeta{ID: "qux"}, TypeMeta: api.TypeMeta{Name: "qux"},
Labels: map[string]string{"label": "qux"}, Labels: map[string]string{"label": "qux"},
}, { }, {
TypeMeta: api.TypeMeta{ID: "zot"}, TypeMeta: api.TypeMeta{Name: "zot"},
}, },
}, },
} }
@@ -284,10 +284,10 @@ func TestListPodListSelection(t *testing.T) {
t.Errorf("%v: Expected %v, got %v", index, e, a) t.Errorf("%v: Expected %v, got %v", index, e, a)
} }
for _, pod := range pods.Items { for _, pod := range pods.Items {
if !item.expectedIDs.Has(pod.ID) { if !item.expectedIDs.Has(pod.Name) {
t.Errorf("%v: Unexpected pod %v", index, pod.ID) t.Errorf("%v: Unexpected pod %v", index, pod.Name)
} }
t.Logf("%v: Got pod ID: %v", index, pod.ID) t.Logf("%v: Got pod Name: %v", index, pod.Name)
} }
} }
} }
@@ -299,7 +299,7 @@ func TestPodDecode(t *testing.T) {
} }
expected := &api.Pod{ expected := &api.Pod{
TypeMeta: api.TypeMeta{ TypeMeta: api.TypeMeta{
ID: "foo", Name: "foo",
}, },
} }
body, err := latest.Codec.Encode(expected) body, err := latest.Codec.Encode(expected)
@@ -319,7 +319,7 @@ func TestPodDecode(t *testing.T) {
func TestGetPod(t *testing.T) { func TestGetPod(t *testing.T) {
podRegistry := registrytest.NewPodRegistry(nil) podRegistry := registrytest.NewPodRegistry(nil)
podRegistry.Pod = &api.Pod{TypeMeta: api.TypeMeta{ID: "foo"}} podRegistry.Pod = &api.Pod{TypeMeta: api.TypeMeta{Name: "foo"}}
storage := REST{ storage := REST{
registry: podRegistry, registry: podRegistry,
ipCache: ipCache{}, ipCache: ipCache{},
@@ -340,7 +340,7 @@ func TestGetPod(t *testing.T) {
func TestGetPodCloud(t *testing.T) { func TestGetPodCloud(t *testing.T) {
fakeCloud := &fake_cloud.FakeCloud{} fakeCloud := &fake_cloud.FakeCloud{}
podRegistry := registrytest.NewPodRegistry(nil) podRegistry := registrytest.NewPodRegistry(nil)
podRegistry.Pod = &api.Pod{TypeMeta: api.TypeMeta{ID: "foo"}, CurrentState: api.PodState{Host: "machine"}} podRegistry.Pod = &api.Pod{TypeMeta: api.TypeMeta{Name: "foo"}, CurrentState: api.PodState{Host: "machine"}}
clock := &fakeClock{t: time.Now()} clock := &fakeClock{t: time.Now()}
@@ -386,7 +386,7 @@ func TestMakePodStatus(t *testing.T) {
Minions: api.MinionList{ Minions: api.MinionList{
Items: []api.Minion{ Items: []api.Minion{
{ {
TypeMeta: api.TypeMeta{ID: "machine"}, TypeMeta: api.TypeMeta{Name: "machine"},
}, },
}, },
}, },
@@ -561,7 +561,7 @@ func TestPodStorageValidatesUpdate(t *testing.T) {
func TestCreatePod(t *testing.T) { func TestCreatePod(t *testing.T) {
podRegistry := registrytest.NewPodRegistry(nil) podRegistry := registrytest.NewPodRegistry(nil)
podRegistry.Pod = &api.Pod{ podRegistry.Pod = &api.Pod{
TypeMeta: api.TypeMeta{ID: "foo"}, TypeMeta: api.TypeMeta{Name: "foo"},
CurrentState: api.PodState{ CurrentState: api.PodState{
Host: "machine", Host: "machine",
}, },
@@ -576,7 +576,7 @@ func TestCreatePod(t *testing.T) {
}, },
} }
pod := &api.Pod{ pod := &api.Pod{
TypeMeta: api.TypeMeta{ID: "foo"}, TypeMeta: api.TypeMeta{Name: "foo"},
DesiredState: desiredState, DesiredState: desiredState,
} }
ctx := api.NewDefaultContext() ctx := api.NewDefaultContext()
@@ -656,7 +656,7 @@ func TestFillPodInfoNoData(t *testing.T) {
func TestCreatePodWithConflictingNamespace(t *testing.T) { func TestCreatePodWithConflictingNamespace(t *testing.T) {
storage := REST{} storage := REST{}
pod := &api.Pod{ pod := &api.Pod{
TypeMeta: api.TypeMeta{ID: "test", Namespace: "not-default"}, TypeMeta: api.TypeMeta{Name: "test", Namespace: "not-default"},
} }
ctx := api.NewDefaultContext() ctx := api.NewDefaultContext()
@@ -674,7 +674,7 @@ func TestCreatePodWithConflictingNamespace(t *testing.T) {
func TestUpdatePodWithConflictingNamespace(t *testing.T) { func TestUpdatePodWithConflictingNamespace(t *testing.T) {
storage := REST{} storage := REST{}
pod := &api.Pod{ pod := &api.Pod{
TypeMeta: api.TypeMeta{ID: "test", Namespace: "not-default"}, TypeMeta: api.TypeMeta{Name: "test", Namespace: "not-default"},
} }
ctx := api.NewDefaultContext() ctx := api.NewDefaultContext()

View File

@@ -34,7 +34,7 @@ func MakeMinionList(minions []string, nodeResources api.NodeResources) *api.Mini
Items: make([]api.Minion, len(minions)), Items: make([]api.Minion, len(minions)),
} }
for i := range minions { for i := range minions {
list.Items[i].ID = minions[i] list.Items[i].Name = minions[i]
list.Items[i].NodeResources = nodeResources list.Items[i].NodeResources = nodeResources
} }
return &list return &list
@@ -55,7 +55,7 @@ func (r *MinionRegistry) ListMinions(ctx api.Context) (*api.MinionList, error) {
func (r *MinionRegistry) CreateMinion(ctx api.Context, minion *api.Minion) error { func (r *MinionRegistry) CreateMinion(ctx api.Context, minion *api.Minion) error {
r.Lock() r.Lock()
defer r.Unlock() defer r.Unlock()
r.Minion = minion.ID r.Minion = minion.Name
r.Minions.Items = append(r.Minions.Items, *minion) r.Minions.Items = append(r.Minions.Items, *minion)
return r.Err return r.Err
} }
@@ -64,7 +64,7 @@ func (r *MinionRegistry) GetMinion(ctx api.Context, minionID string) (*api.Minio
r.Lock() r.Lock()
defer r.Unlock() defer r.Unlock()
for _, node := range r.Minions.Items { for _, node := range r.Minions.Items {
if node.ID == minionID { if node.Name == minionID {
return &node, r.Err return &node, r.Err
} }
} }
@@ -76,8 +76,8 @@ func (r *MinionRegistry) DeleteMinion(ctx api.Context, minionID string) error {
defer r.Unlock() defer r.Unlock()
var newList []api.Minion var newList []api.Minion
for _, node := range r.Minions.Items { for _, node := range r.Minions.Items {
if node.ID != minionID { if node.Name != minionID {
newList = append(newList, api.Minion{TypeMeta: api.TypeMeta{ID: node.ID}}) newList = append(newList, api.Minion{TypeMeta: api.TypeMeta{Name: node.Name}})
} }
} }
r.Minions.Items = newList r.Minions.Items = newList

View File

@@ -82,7 +82,7 @@ func (r *ServiceRegistry) UpdateService(ctx api.Context, svc *api.Service) error
r.mu.Lock() r.mu.Lock()
defer r.mu.Unlock() defer r.mu.Unlock()
r.UpdatedID = svc.ID r.UpdatedID = svc.Name
r.Service = svc r.Service = svc
return r.Err return r.Err
} }

View File

@@ -67,40 +67,40 @@ func reloadIPsFromStorage(ipa *ipAllocator, registry Registry) {
return return
} }
for i := range services.Items { for i := range services.Items {
s := &services.Items[i] service := &services.Items[i]
if s.PortalIP == "" { if service.PortalIP == "" {
glog.Warningf("service %q has no PortalIP", s.ID) glog.Warningf("service %q has no PortalIP", service.Name)
continue continue
} }
if err := ipa.Allocate(net.ParseIP(s.PortalIP)); err != nil { if err := ipa.Allocate(net.ParseIP(service.PortalIP)); err != nil {
// This is really bad. // This is really bad.
glog.Errorf("service %q PortalIP %s could not be allocated: %s", s.ID, s.PortalIP, err) glog.Errorf("service %q PortalIP %s could not be allocated: %s", service.Name, service.PortalIP, err)
} }
} }
} }
func (rs *REST) Create(ctx api.Context, obj runtime.Object) (<-chan runtime.Object, error) { func (rs *REST) Create(ctx api.Context, obj runtime.Object) (<-chan runtime.Object, error) {
srv := obj.(*api.Service) service := obj.(*api.Service)
if !api.ValidNamespace(ctx, &srv.TypeMeta) { if !api.ValidNamespace(ctx, &service.TypeMeta) {
return nil, errors.NewConflict("service", srv.Namespace, fmt.Errorf("Service.Namespace does not match the provided context")) return nil, errors.NewConflict("service", service.Namespace, fmt.Errorf("Service.Namespace does not match the provided context"))
} }
if errs := validation.ValidateService(srv); len(errs) > 0 { if errs := validation.ValidateService(service); len(errs) > 0 {
return nil, errors.NewInvalid("service", srv.ID, errs) return nil, errors.NewInvalid("service", service.Name, errs)
} }
srv.CreationTimestamp = util.Now() service.CreationTimestamp = util.Now()
if ip, err := rs.portalMgr.AllocateNext(); err != nil { if ip, err := rs.portalMgr.AllocateNext(); err != nil {
return nil, err return nil, err
} else { } else {
srv.PortalIP = ip.String() service.PortalIP = ip.String()
} }
return apiserver.MakeAsync(func() (runtime.Object, error) { return apiserver.MakeAsync(func() (runtime.Object, error) {
// TODO: Consider moving this to a rectification loop, so that we make/remove external load balancers // TODO: Consider moving this to a rectification loop, so that we make/remove external load balancers
// correctly no matter what http operations happen. // correctly no matter what http operations happen.
srv.ProxyPort = 0 service.ProxyPort = 0
if srv.CreateExternalLoadBalancer { if service.CreateExternalLoadBalancer {
if rs.cloud == nil { if rs.cloud == nil {
return nil, fmt.Errorf("requested an external service, but no cloud provider supplied.") return nil, fmt.Errorf("requested an external service, but no cloud provider supplied.")
} }
@@ -120,26 +120,26 @@ func (rs *REST) Create(ctx api.Context, obj runtime.Object) (<-chan runtime.Obje
if err != nil { if err != nil {
return nil, err return nil, err
} }
err = balancer.CreateTCPLoadBalancer(srv.ID, zone.Region, srv.Port, hostsFromMinionList(hosts)) err = balancer.CreateTCPLoadBalancer(service.Name, zone.Region, service.Port, hostsFromMinionList(hosts))
if err != nil { if err != nil {
return nil, err return nil, err
} }
// External load-balancers require a known port for the service proxy. // External load-balancers require a known port for the service proxy.
// TODO: If we end up brokering HostPorts between Pods and Services, this can be any port. // TODO: If we end up brokering HostPorts between Pods and Services, this can be any port.
srv.ProxyPort = srv.Port service.ProxyPort = service.Port
} }
err := rs.registry.CreateService(ctx, srv) err := rs.registry.CreateService(ctx, service)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return rs.registry.GetService(ctx, srv.ID) return rs.registry.GetService(ctx, service.Name)
}), nil }), nil
} }
func hostsFromMinionList(list *api.MinionList) []string { func hostsFromMinionList(list *api.MinionList) []string {
result := make([]string, len(list.Items)) result := make([]string, len(list.Items))
for ix := range list.Items { for ix := range list.Items {
result[ix] = list.Items[ix].ID result[ix] = list.Items[ix].Name
} }
return result return result
} }
@@ -157,11 +157,11 @@ func (rs *REST) Delete(ctx api.Context, id string) (<-chan runtime.Object, error
} }
func (rs *REST) Get(ctx api.Context, id string) (runtime.Object, error) { func (rs *REST) Get(ctx api.Context, id string) (runtime.Object, error) {
s, err := rs.registry.GetService(ctx, id) service, err := rs.registry.GetService(ctx, id)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return s, err return service, err
} }
// TODO: implement field selector? // TODO: implement field selector?
@@ -200,10 +200,10 @@ func GetServiceEnvironmentVariables(ctx api.Context, registry Registry, machine
} }
for _, service := range services.Items { for _, service := range services.Items {
// Host // Host
name := makeEnvVariableName(service.ID) + "_SERVICE_HOST" name := makeEnvVariableName(service.Name) + "_SERVICE_HOST"
result = append(result, api.EnvVar{Name: name, Value: service.PortalIP}) result = append(result, api.EnvVar{Name: name, Value: service.PortalIP})
// Port // Port
name = makeEnvVariableName(service.ID) + "_SERVICE_PORT" name = makeEnvVariableName(service.Name) + "_SERVICE_PORT"
result = append(result, api.EnvVar{Name: name, Value: strconv.Itoa(service.Port)}) result = append(result, api.EnvVar{Name: name, Value: strconv.Itoa(service.Port)})
// Docker-compatible vars. // Docker-compatible vars.
result = append(result, makeLinkVariables(service)...) result = append(result, makeLinkVariables(service)...)
@@ -212,27 +212,27 @@ func GetServiceEnvironmentVariables(ctx api.Context, registry Registry, machine
} }
func (rs *REST) Update(ctx api.Context, obj runtime.Object) (<-chan runtime.Object, error) { func (rs *REST) Update(ctx api.Context, obj runtime.Object) (<-chan runtime.Object, error) {
srv := obj.(*api.Service) service := obj.(*api.Service)
if !api.ValidNamespace(ctx, &srv.TypeMeta) { if !api.ValidNamespace(ctx, &service.TypeMeta) {
return nil, errors.NewConflict("service", srv.Namespace, fmt.Errorf("Service.Namespace does not match the provided context")) return nil, errors.NewConflict("service", service.Namespace, fmt.Errorf("Service.Namespace does not match the provided context"))
} }
if errs := validation.ValidateService(srv); len(errs) > 0 { if errs := validation.ValidateService(service); len(errs) > 0 {
return nil, errors.NewInvalid("service", srv.ID, errs) return nil, errors.NewInvalid("service", service.Name, errs)
} }
return apiserver.MakeAsync(func() (runtime.Object, error) { return apiserver.MakeAsync(func() (runtime.Object, error) {
cur, err := rs.registry.GetService(ctx, srv.ID) cur, err := rs.registry.GetService(ctx, service.Name)
if err != nil { if err != nil {
return nil, err return nil, err
} }
// Copy over non-user fields. // Copy over non-user fields.
srv.PortalIP = cur.PortalIP service.PortalIP = cur.PortalIP
srv.ProxyPort = cur.ProxyPort service.ProxyPort = cur.ProxyPort
// TODO: check to see if external load balancer status changed // TODO: check to see if external load balancer status changed
err = rs.registry.UpdateService(ctx, srv) err = rs.registry.UpdateService(ctx, service)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return rs.registry.GetService(ctx, srv.ID) return rs.registry.GetService(ctx, service.Name)
}), nil }), nil
} }
@@ -270,7 +270,7 @@ func (rs *REST) deleteExternalLoadBalancer(service *api.Service) error {
if err != nil { if err != nil {
return err return err
} }
if err := balancer.DeleteTCPLoadBalancer(service.TypeMeta.ID, zone.Region); err != nil { if err := balancer.DeleteTCPLoadBalancer(service.Name, zone.Region); err != nil {
return err return err
} }
return nil return nil
@@ -281,7 +281,7 @@ func makeEnvVariableName(str string) string {
} }
func makeLinkVariables(service api.Service) []api.EnvVar { func makeLinkVariables(service api.Service) []api.EnvVar {
prefix := makeEnvVariableName(service.ID) prefix := makeEnvVariableName(service.Name)
protocol := string(api.ProtocolTCP) protocol := string(api.ProtocolTCP)
if service.Protocol != "" { if service.Protocol != "" {
protocol = string(service.Protocol) protocol = string(service.Protocol)

View File

@@ -46,15 +46,15 @@ func TestServiceRegistryCreate(t *testing.T) {
storage := NewREST(registry, fakeCloud, registrytest.NewMinionRegistry(machines, api.NodeResources{}), makeIPNet(t)) storage := NewREST(registry, fakeCloud, registrytest.NewMinionRegistry(machines, api.NodeResources{}), makeIPNet(t))
svc := &api.Service{ svc := &api.Service{
Port: 6502, Port: 6502,
TypeMeta: api.TypeMeta{ID: "foo"}, TypeMeta: api.TypeMeta{Name: "foo"},
Selector: map[string]string{"bar": "baz"}, Selector: map[string]string{"bar": "baz"},
} }
ctx := api.NewDefaultContext() ctx := api.NewDefaultContext()
c, _ := storage.Create(ctx, svc) c, _ := storage.Create(ctx, svc)
created_svc := <-c created_svc := <-c
created_service := created_svc.(*api.Service) created_service := created_svc.(*api.Service)
if created_service.ID != "foo" { if created_service.Name != "foo" {
t.Errorf("Expected foo, but got %v", created_service.ID) t.Errorf("Expected foo, but got %v", created_service.Name)
} }
if created_service.CreationTimestamp.IsZero() { if created_service.CreationTimestamp.IsZero() {
t.Errorf("Expected timestamp to be set, got: %v", created_service.CreationTimestamp) t.Errorf("Expected timestamp to be set, got: %v", created_service.CreationTimestamp)
@@ -68,12 +68,12 @@ func TestServiceRegistryCreate(t *testing.T) {
if len(fakeCloud.Calls) != 0 { if len(fakeCloud.Calls) != 0 {
t.Errorf("Unexpected call(s): %#v", fakeCloud.Calls) t.Errorf("Unexpected call(s): %#v", fakeCloud.Calls)
} }
srv, err := registry.GetService(ctx, svc.ID) srv, err := registry.GetService(ctx, svc.Name)
if err != nil { if err != nil {
t.Errorf("unexpected error: %v", err) t.Errorf("unexpected error: %v", err)
} }
if srv == nil { if srv == nil {
t.Errorf("Failed to find service: %s", svc.ID) t.Errorf("Failed to find service: %s", svc.Name)
} }
} }
@@ -83,11 +83,11 @@ func TestServiceStorageValidatesCreate(t *testing.T) {
failureCases := map[string]api.Service{ failureCases := map[string]api.Service{
"empty ID": { "empty ID": {
Port: 6502, Port: 6502,
TypeMeta: api.TypeMeta{ID: ""}, TypeMeta: api.TypeMeta{Name: ""},
Selector: map[string]string{"bar": "baz"}, Selector: map[string]string{"bar": "baz"},
}, },
"empty selector": { "empty selector": {
TypeMeta: api.TypeMeta{ID: "foo"}, TypeMeta: api.TypeMeta{Name: "foo"},
Selector: map[string]string{}, Selector: map[string]string{},
}, },
} }
@@ -109,13 +109,13 @@ func TestServiceRegistryUpdate(t *testing.T) {
registry := registrytest.NewServiceRegistry() registry := registrytest.NewServiceRegistry()
registry.CreateService(ctx, &api.Service{ registry.CreateService(ctx, &api.Service{
Port: 6502, Port: 6502,
TypeMeta: api.TypeMeta{ID: "foo"}, TypeMeta: api.TypeMeta{Name: "foo"},
Selector: map[string]string{"bar": "baz1"}, Selector: map[string]string{"bar": "baz1"},
}) })
storage := NewREST(registry, nil, nil, makeIPNet(t)) storage := NewREST(registry, nil, nil, makeIPNet(t))
c, err := storage.Update(ctx, &api.Service{ c, err := storage.Update(ctx, &api.Service{
Port: 6502, Port: 6502,
TypeMeta: api.TypeMeta{ID: "foo"}, TypeMeta: api.TypeMeta{Name: "foo"},
Selector: map[string]string{"bar": "baz2"}, Selector: map[string]string{"bar": "baz2"},
}) })
if c == nil { if c == nil {
@@ -126,8 +126,8 @@ func TestServiceRegistryUpdate(t *testing.T) {
} }
updated_svc := <-c updated_svc := <-c
updated_service := updated_svc.(*api.Service) updated_service := updated_svc.(*api.Service)
if updated_service.ID != "foo" { if updated_service.Name != "foo" {
t.Errorf("Expected foo, but got %v", updated_service.ID) t.Errorf("Expected foo, but got %v", updated_service.Name)
} }
if e, a := "foo", registry.UpdatedID; e != a { if e, a := "foo", registry.UpdatedID; e != a {
t.Errorf("Expected %v, but got %v", e, a) t.Errorf("Expected %v, but got %v", e, a)
@@ -139,19 +139,19 @@ func TestServiceStorageValidatesUpdate(t *testing.T) {
registry := registrytest.NewServiceRegistry() registry := registrytest.NewServiceRegistry()
registry.CreateService(ctx, &api.Service{ registry.CreateService(ctx, &api.Service{
Port: 6502, Port: 6502,
TypeMeta: api.TypeMeta{ID: "foo"}, TypeMeta: api.TypeMeta{Name: "foo"},
Selector: map[string]string{"bar": "baz"}, Selector: map[string]string{"bar": "baz"},
}) })
storage := NewREST(registry, nil, nil, makeIPNet(t)) storage := NewREST(registry, nil, nil, makeIPNet(t))
failureCases := map[string]api.Service{ failureCases := map[string]api.Service{
"empty ID": { "empty ID": {
Port: 6502, Port: 6502,
TypeMeta: api.TypeMeta{ID: ""}, TypeMeta: api.TypeMeta{Name: ""},
Selector: map[string]string{"bar": "baz"}, Selector: map[string]string{"bar": "baz"},
}, },
"empty selector": { "empty selector": {
Port: 6502, Port: 6502,
TypeMeta: api.TypeMeta{ID: "foo"}, TypeMeta: api.TypeMeta{Name: "foo"},
Selector: map[string]string{}, Selector: map[string]string{},
}, },
} }
@@ -174,7 +174,7 @@ func TestServiceRegistryExternalService(t *testing.T) {
storage := NewREST(registry, fakeCloud, registrytest.NewMinionRegistry(machines, api.NodeResources{}), makeIPNet(t)) storage := NewREST(registry, fakeCloud, registrytest.NewMinionRegistry(machines, api.NodeResources{}), makeIPNet(t))
svc := &api.Service{ svc := &api.Service{
Port: 6502, Port: 6502,
TypeMeta: api.TypeMeta{ID: "foo"}, TypeMeta: api.TypeMeta{Name: "foo"},
Selector: map[string]string{"bar": "baz"}, Selector: map[string]string{"bar": "baz"},
CreateExternalLoadBalancer: true, CreateExternalLoadBalancer: true,
} }
@@ -183,12 +183,12 @@ func TestServiceRegistryExternalService(t *testing.T) {
if len(fakeCloud.Calls) != 2 || fakeCloud.Calls[0] != "get-zone" || fakeCloud.Calls[1] != "create" { if len(fakeCloud.Calls) != 2 || fakeCloud.Calls[0] != "get-zone" || fakeCloud.Calls[1] != "create" {
t.Errorf("Unexpected call(s): %#v", fakeCloud.Calls) t.Errorf("Unexpected call(s): %#v", fakeCloud.Calls)
} }
srv, err := registry.GetService(ctx, svc.ID) srv, err := registry.GetService(ctx, svc.Name)
if err != nil { if err != nil {
t.Errorf("Unexpected error: %v", err) t.Errorf("Unexpected error: %v", err)
} }
if srv == nil { if srv == nil {
t.Errorf("Failed to find service: %s", svc.ID) t.Errorf("Failed to find service: %s", svc.Name)
} }
} }
@@ -201,7 +201,7 @@ func TestServiceRegistryExternalServiceError(t *testing.T) {
storage := NewREST(registry, fakeCloud, registrytest.NewMinionRegistry(machines, api.NodeResources{}), makeIPNet(t)) storage := NewREST(registry, fakeCloud, registrytest.NewMinionRegistry(machines, api.NodeResources{}), makeIPNet(t))
svc := &api.Service{ svc := &api.Service{
Port: 6502, Port: 6502,
TypeMeta: api.TypeMeta{ID: "foo"}, TypeMeta: api.TypeMeta{Name: "foo"},
Selector: map[string]string{"bar": "baz"}, Selector: map[string]string{"bar": "baz"},
CreateExternalLoadBalancer: true, CreateExternalLoadBalancer: true,
} }
@@ -223,11 +223,11 @@ func TestServiceRegistryDelete(t *testing.T) {
machines := []string{"foo", "bar", "baz"} machines := []string{"foo", "bar", "baz"}
storage := NewREST(registry, fakeCloud, registrytest.NewMinionRegistry(machines, api.NodeResources{}), makeIPNet(t)) storage := NewREST(registry, fakeCloud, registrytest.NewMinionRegistry(machines, api.NodeResources{}), makeIPNet(t))
svc := &api.Service{ svc := &api.Service{
TypeMeta: api.TypeMeta{ID: "foo"}, TypeMeta: api.TypeMeta{Name: "foo"},
Selector: map[string]string{"bar": "baz"}, Selector: map[string]string{"bar": "baz"},
} }
registry.CreateService(ctx, svc) registry.CreateService(ctx, svc)
c, _ := storage.Delete(ctx, svc.ID) c, _ := storage.Delete(ctx, svc.Name)
<-c <-c
if len(fakeCloud.Calls) != 0 { if len(fakeCloud.Calls) != 0 {
t.Errorf("Unexpected call(s): %#v", fakeCloud.Calls) t.Errorf("Unexpected call(s): %#v", fakeCloud.Calls)
@@ -244,12 +244,12 @@ func TestServiceRegistryDeleteExternal(t *testing.T) {
machines := []string{"foo", "bar", "baz"} machines := []string{"foo", "bar", "baz"}
storage := NewREST(registry, fakeCloud, registrytest.NewMinionRegistry(machines, api.NodeResources{}), makeIPNet(t)) storage := NewREST(registry, fakeCloud, registrytest.NewMinionRegistry(machines, api.NodeResources{}), makeIPNet(t))
svc := &api.Service{ svc := &api.Service{
TypeMeta: api.TypeMeta{ID: "foo"}, TypeMeta: api.TypeMeta{Name: "foo"},
Selector: map[string]string{"bar": "baz"}, Selector: map[string]string{"bar": "baz"},
CreateExternalLoadBalancer: true, CreateExternalLoadBalancer: true,
} }
registry.CreateService(ctx, svc) registry.CreateService(ctx, svc)
c, _ := storage.Delete(ctx, svc.ID) c, _ := storage.Delete(ctx, svc.Name)
<-c <-c
if len(fakeCloud.Calls) != 2 || fakeCloud.Calls[0] != "get-zone" || fakeCloud.Calls[1] != "delete" { if len(fakeCloud.Calls) != 2 || fakeCloud.Calls[0] != "get-zone" || fakeCloud.Calls[1] != "delete" {
t.Errorf("Unexpected call(s): %#v", fakeCloud.Calls) t.Errorf("Unexpected call(s): %#v", fakeCloud.Calls)
@@ -265,21 +265,21 @@ func TestServiceRegistryMakeLinkVariables(t *testing.T) {
registry.List = api.ServiceList{ registry.List = api.ServiceList{
Items: []api.Service{ Items: []api.Service{
{ {
TypeMeta: api.TypeMeta{ID: "foo-bar"}, TypeMeta: api.TypeMeta{Name: "foo-bar"},
Selector: map[string]string{"bar": "baz"}, Selector: map[string]string{"bar": "baz"},
Port: 8080, Port: 8080,
Protocol: "TCP", Protocol: "TCP",
PortalIP: "1.2.3.4", PortalIP: "1.2.3.4",
}, },
{ {
TypeMeta: api.TypeMeta{ID: "abc-123"}, TypeMeta: api.TypeMeta{Name: "abc-123"},
Selector: map[string]string{"bar": "baz"}, Selector: map[string]string{"bar": "baz"},
Port: 8081, Port: 8081,
Protocol: "UDP", Protocol: "UDP",
PortalIP: "5.6.7.8", PortalIP: "5.6.7.8",
}, },
{ {
TypeMeta: api.TypeMeta{ID: "q-u-u-x"}, TypeMeta: api.TypeMeta{Name: "q-u-u-x"},
Selector: map[string]string{"bar": "baz"}, Selector: map[string]string{"bar": "baz"},
Port: 8082, Port: 8082,
Protocol: "", Protocol: "",
@@ -333,7 +333,7 @@ func TestServiceRegistryGet(t *testing.T) {
machines := []string{"foo", "bar", "baz"} machines := []string{"foo", "bar", "baz"}
storage := NewREST(registry, fakeCloud, registrytest.NewMinionRegistry(machines, api.NodeResources{}), makeIPNet(t)) storage := NewREST(registry, fakeCloud, registrytest.NewMinionRegistry(machines, api.NodeResources{}), makeIPNet(t))
registry.CreateService(ctx, &api.Service{ registry.CreateService(ctx, &api.Service{
TypeMeta: api.TypeMeta{ID: "foo"}, TypeMeta: api.TypeMeta{Name: "foo"},
Selector: map[string]string{"bar": "baz"}, Selector: map[string]string{"bar": "baz"},
}) })
storage.Get(ctx, "foo") storage.Get(ctx, "foo")
@@ -353,7 +353,7 @@ func TestServiceRegistryResourceLocation(t *testing.T) {
machines := []string{"foo", "bar", "baz"} machines := []string{"foo", "bar", "baz"}
storage := NewREST(registry, fakeCloud, registrytest.NewMinionRegistry(machines, api.NodeResources{}), makeIPNet(t)) storage := NewREST(registry, fakeCloud, registrytest.NewMinionRegistry(machines, api.NodeResources{}), makeIPNet(t))
registry.CreateService(ctx, &api.Service{ registry.CreateService(ctx, &api.Service{
TypeMeta: api.TypeMeta{ID: "foo"}, TypeMeta: api.TypeMeta{Name: "foo"},
Selector: map[string]string{"bar": "baz"}, Selector: map[string]string{"bar": "baz"},
}) })
redirector := apiserver.Redirector(storage) redirector := apiserver.Redirector(storage)
@@ -382,11 +382,11 @@ func TestServiceRegistryList(t *testing.T) {
machines := []string{"foo", "bar", "baz"} machines := []string{"foo", "bar", "baz"}
storage := NewREST(registry, fakeCloud, registrytest.NewMinionRegistry(machines, api.NodeResources{}), makeIPNet(t)) storage := NewREST(registry, fakeCloud, registrytest.NewMinionRegistry(machines, api.NodeResources{}), makeIPNet(t))
registry.CreateService(ctx, &api.Service{ registry.CreateService(ctx, &api.Service{
TypeMeta: api.TypeMeta{ID: "foo"}, TypeMeta: api.TypeMeta{Name: "foo"},
Selector: map[string]string{"bar": "baz"}, Selector: map[string]string{"bar": "baz"},
}) })
registry.CreateService(ctx, &api.Service{ registry.CreateService(ctx, &api.Service{
TypeMeta: api.TypeMeta{ID: "foo2"}, TypeMeta: api.TypeMeta{Name: "foo2"},
Selector: map[string]string{"bar2": "baz2"}, Selector: map[string]string{"bar2": "baz2"},
}) })
registry.List.ResourceVersion = "1" registry.List.ResourceVersion = "1"
@@ -398,10 +398,10 @@ func TestServiceRegistryList(t *testing.T) {
if len(sl.Items) != 2 { if len(sl.Items) != 2 {
t.Fatalf("Expected 2 services, but got %v", len(sl.Items)) t.Fatalf("Expected 2 services, but got %v", len(sl.Items))
} }
if e, a := "foo", sl.Items[0].ID; e != a { if e, a := "foo", sl.Items[0].Name; e != a {
t.Errorf("Expected %v, but got %v", e, a) t.Errorf("Expected %v, but got %v", e, a)
} }
if e, a := "foo2", sl.Items[1].ID; e != a { if e, a := "foo2", sl.Items[1].Name; e != a {
t.Errorf("Expected %v, but got %v", e, a) t.Errorf("Expected %v, but got %v", e, a)
} }
if sl.ResourceVersion != "1" { if sl.ResourceVersion != "1" {
@@ -417,15 +417,15 @@ func TestServiceRegistryIPAllocation(t *testing.T) {
svc1 := &api.Service{ svc1 := &api.Service{
Port: 6502, Port: 6502,
TypeMeta: api.TypeMeta{ID: "foo"}, TypeMeta: api.TypeMeta{Name: "foo"},
Selector: map[string]string{"bar": "baz"}, Selector: map[string]string{"bar": "baz"},
} }
ctx := api.NewDefaultContext() ctx := api.NewDefaultContext()
c1, _ := rest.Create(ctx, svc1) c1, _ := rest.Create(ctx, svc1)
created_svc1 := <-c1 created_svc1 := <-c1
created_service_1 := created_svc1.(*api.Service) created_service_1 := created_svc1.(*api.Service)
if created_service_1.ID != "foo" { if created_service_1.Name != "foo" {
t.Errorf("Expected foo, but got %v", created_service_1.ID) t.Errorf("Expected foo, but got %v", created_service_1.Name)
} }
if created_service_1.PortalIP != "1.2.3.1" { if created_service_1.PortalIP != "1.2.3.1" {
t.Errorf("Unexpected PortalIP: %s", created_service_1.PortalIP) t.Errorf("Unexpected PortalIP: %s", created_service_1.PortalIP)
@@ -433,15 +433,15 @@ func TestServiceRegistryIPAllocation(t *testing.T) {
svc2 := &api.Service{ svc2 := &api.Service{
Port: 6502, Port: 6502,
TypeMeta: api.TypeMeta{ID: "bar"}, TypeMeta: api.TypeMeta{Name: "bar"},
Selector: map[string]string{"bar": "baz"}, Selector: map[string]string{"bar": "baz"},
} }
ctx = api.NewDefaultContext() ctx = api.NewDefaultContext()
c2, _ := rest.Create(ctx, svc2) c2, _ := rest.Create(ctx, svc2)
created_svc2 := <-c2 created_svc2 := <-c2
created_service_2 := created_svc2.(*api.Service) created_service_2 := created_svc2.(*api.Service)
if created_service_2.ID != "bar" { if created_service_2.Name != "bar" {
t.Errorf("Expected bar, but got %v", created_service_2.ID) t.Errorf("Expected bar, but got %v", created_service_2.Name)
} }
if created_service_2.PortalIP != "1.2.3.2" { // new IP if created_service_2.PortalIP != "1.2.3.2" { // new IP
t.Errorf("Unexpected PortalIP: %s", created_service_2.PortalIP) t.Errorf("Unexpected PortalIP: %s", created_service_2.PortalIP)
@@ -456,34 +456,34 @@ func TestServiceRegistryIPReallocation(t *testing.T) {
svc1 := &api.Service{ svc1 := &api.Service{
Port: 6502, Port: 6502,
TypeMeta: api.TypeMeta{ID: "foo"}, TypeMeta: api.TypeMeta{Name: "foo"},
Selector: map[string]string{"bar": "baz"}, Selector: map[string]string{"bar": "baz"},
} }
ctx := api.NewDefaultContext() ctx := api.NewDefaultContext()
c1, _ := rest.Create(ctx, svc1) c1, _ := rest.Create(ctx, svc1)
created_svc1 := <-c1 created_svc1 := <-c1
created_service_1 := created_svc1.(*api.Service) created_service_1 := created_svc1.(*api.Service)
if created_service_1.ID != "foo" { if created_service_1.Name != "foo" {
t.Errorf("Expected foo, but got %v", created_service_1.ID) t.Errorf("Expected foo, but got %v", created_service_1.Name)
} }
if created_service_1.PortalIP != "1.2.3.1" { if created_service_1.PortalIP != "1.2.3.1" {
t.Errorf("Unexpected PortalIP: %s", created_service_1.PortalIP) t.Errorf("Unexpected PortalIP: %s", created_service_1.PortalIP)
} }
c, _ := rest.Delete(ctx, created_service_1.ID) c, _ := rest.Delete(ctx, created_service_1.Name)
<-c <-c
svc2 := &api.Service{ svc2 := &api.Service{
Port: 6502, Port: 6502,
TypeMeta: api.TypeMeta{ID: "bar"}, TypeMeta: api.TypeMeta{Name: "bar"},
Selector: map[string]string{"bar": "baz"}, Selector: map[string]string{"bar": "baz"},
} }
ctx = api.NewDefaultContext() ctx = api.NewDefaultContext()
c2, _ := rest.Create(ctx, svc2) c2, _ := rest.Create(ctx, svc2)
created_svc2 := <-c2 created_svc2 := <-c2
created_service_2 := created_svc2.(*api.Service) created_service_2 := created_svc2.(*api.Service)
if created_service_2.ID != "bar" { if created_service_2.Name != "bar" {
t.Errorf("Expected bar, but got %v", created_service_2.ID) t.Errorf("Expected bar, but got %v", created_service_2.Name)
} }
if created_service_2.PortalIP != "1.2.3.1" { // same IP as before if created_service_2.PortalIP != "1.2.3.1" { // same IP as before
t.Errorf("Unexpected PortalIP: %s", created_service_2.PortalIP) t.Errorf("Unexpected PortalIP: %s", created_service_2.PortalIP)
@@ -498,7 +498,7 @@ func TestServiceRegistryIPUpdate(t *testing.T) {
svc := &api.Service{ svc := &api.Service{
Port: 6502, Port: 6502,
TypeMeta: api.TypeMeta{ID: "foo"}, TypeMeta: api.TypeMeta{Name: "foo"},
Selector: map[string]string{"bar": "baz"}, Selector: map[string]string{"bar": "baz"},
} }
ctx := api.NewDefaultContext() ctx := api.NewDefaultContext()
@@ -543,7 +543,7 @@ func TestServiceRegistryIPExternalLoadBalancer(t *testing.T) {
svc := &api.Service{ svc := &api.Service{
Port: 6502, Port: 6502,
TypeMeta: api.TypeMeta{ID: "foo"}, TypeMeta: api.TypeMeta{Name: "foo"},
Selector: map[string]string{"bar": "baz"}, Selector: map[string]string{"bar": "baz"},
CreateExternalLoadBalancer: true, CreateExternalLoadBalancer: true,
} }
@@ -570,7 +570,7 @@ func TestServiceRegistryIPReloadFromStorage(t *testing.T) {
svc := &api.Service{ svc := &api.Service{
Port: 6502, Port: 6502,
TypeMeta: api.TypeMeta{ID: "foo"}, TypeMeta: api.TypeMeta{Name: "foo"},
Selector: map[string]string{"bar": "baz"}, Selector: map[string]string{"bar": "baz"},
} }
ctx := api.NewDefaultContext() ctx := api.NewDefaultContext()
@@ -578,7 +578,7 @@ func TestServiceRegistryIPReloadFromStorage(t *testing.T) {
<-c <-c
svc = &api.Service{ svc = &api.Service{
Port: 6502, Port: 6502,
TypeMeta: api.TypeMeta{ID: "foo"}, TypeMeta: api.TypeMeta{Name: "foo"},
Selector: map[string]string{"bar": "baz"}, Selector: map[string]string{"bar": "baz"},
} }
c, _ = rest1.Create(ctx, svc) c, _ = rest1.Create(ctx, svc)
@@ -589,7 +589,7 @@ func TestServiceRegistryIPReloadFromStorage(t *testing.T) {
svc = &api.Service{ svc = &api.Service{
Port: 6502, Port: 6502,
TypeMeta: api.TypeMeta{ID: "foo"}, TypeMeta: api.TypeMeta{Name: "foo"},
Selector: map[string]string{"bar": "baz"}, Selector: map[string]string{"bar": "baz"},
} }
c, _ = rest2.Create(ctx, svc) c, _ = rest2.Create(ctx, svc)
@@ -603,7 +603,7 @@ func TestServiceRegistryIPReloadFromStorage(t *testing.T) {
func TestCreateServiceWithConflictingNamespace(t *testing.T) { func TestCreateServiceWithConflictingNamespace(t *testing.T) {
storage := REST{} storage := REST{}
service := &api.Service{ service := &api.Service{
TypeMeta: api.TypeMeta{ID: "test", Namespace: "not-default"}, TypeMeta: api.TypeMeta{Name: "test", Namespace: "not-default"},
} }
ctx := api.NewDefaultContext() ctx := api.NewDefaultContext()
@@ -621,7 +621,7 @@ func TestCreateServiceWithConflictingNamespace(t *testing.T) {
func TestUpdateServiceWithConflictingNamespace(t *testing.T) { func TestUpdateServiceWithConflictingNamespace(t *testing.T) {
storage := REST{} storage := REST{}
service := &api.Service{ service := &api.Service{
TypeMeta: api.TypeMeta{ID: "test", Namespace: "not-default"}, TypeMeta: api.TypeMeta{Name: "test", Namespace: "not-default"},
} }
ctx := api.NewDefaultContext() ctx := api.NewDefaultContext()

View File

@@ -48,10 +48,10 @@ func TestEmbeddedObject(t *testing.T) {
s.AddKnownTypeWithName("v1test", "EmbeddedTest", &EmbeddedTestExternal{}) s.AddKnownTypeWithName("v1test", "EmbeddedTest", &EmbeddedTestExternal{})
outer := &EmbeddedTest{ outer := &EmbeddedTest{
TypeMeta: runtime.TypeMeta{ID: "outer"}, TypeMeta: runtime.TypeMeta{Name: "outer"},
Object: runtime.EmbeddedObject{ Object: runtime.EmbeddedObject{
&EmbeddedTest{ &EmbeddedTest{
TypeMeta: runtime.TypeMeta{ID: "inner"}, TypeMeta: runtime.TypeMeta{Name: "inner"},
}, },
}, },
} }
@@ -79,7 +79,7 @@ func TestEmbeddedObject(t *testing.T) {
if err != nil { if err != nil {
t.Fatalf("Unexpected decode error %v", err) t.Fatalf("Unexpected decode error %v", err)
} }
if externalViaJSON.Kind == "" || externalViaJSON.APIVersion == "" || externalViaJSON.ID != "outer" { if externalViaJSON.Kind == "" || externalViaJSON.APIVersion == "" || externalViaJSON.Name != "outer" {
t.Errorf("Expected objects to have type info set, got %#v", externalViaJSON) t.Errorf("Expected objects to have type info set, got %#v", externalViaJSON)
} }
if !reflect.DeepEqual(externalViaJSON.EmptyObject.RawJSON, []byte("null")) || len(externalViaJSON.Object.RawJSON) == 0 { if !reflect.DeepEqual(externalViaJSON.EmptyObject.RawJSON, []byte("null")) || len(externalViaJSON.Object.RawJSON) == 0 {

View File

@@ -29,9 +29,9 @@ import (
func TestExtractList(t *testing.T) { func TestExtractList(t *testing.T) {
pl := &api.PodList{ pl := &api.PodList{
Items: []api.Pod{ Items: []api.Pod{
{TypeMeta: api.TypeMeta{ID: "1"}}, {TypeMeta: api.TypeMeta{Name: "1"}},
{TypeMeta: api.TypeMeta{ID: "2"}}, {TypeMeta: api.TypeMeta{Name: "2"}},
{TypeMeta: api.TypeMeta{ID: "3"}}, {TypeMeta: api.TypeMeta{Name: "3"}},
}, },
} }
list, err := runtime.ExtractList(pl) list, err := runtime.ExtractList(pl)
@@ -42,7 +42,7 @@ func TestExtractList(t *testing.T) {
t.Fatalf("Expected %v, got %v", e, a) t.Fatalf("Expected %v, got %v", e, a)
} }
for i := range list { for i := range list {
if e, a := list[i].(*api.Pod).ID, pl.Items[i].ID; e != a { if e, a := list[i].(*api.Pod).Name, pl.Items[i].Name; e != a {
t.Fatalf("Expected %v, got %v", e, a) t.Fatalf("Expected %v, got %v", e, a)
} }
} }
@@ -51,9 +51,9 @@ func TestExtractList(t *testing.T) {
func TestSetList(t *testing.T) { func TestSetList(t *testing.T) {
pl := &api.PodList{} pl := &api.PodList{}
list := []runtime.Object{ list := []runtime.Object{
&api.Pod{TypeMeta: api.TypeMeta{ID: "1"}}, &api.Pod{TypeMeta: api.TypeMeta{Name: "1"}},
&api.Pod{TypeMeta: api.TypeMeta{ID: "2"}}, &api.Pod{TypeMeta: api.TypeMeta{Name: "2"}},
&api.Pod{TypeMeta: api.TypeMeta{ID: "3"}}, &api.Pod{TypeMeta: api.TypeMeta{Name: "3"}},
} }
err := runtime.SetList(pl, list) err := runtime.SetList(pl, list)
if err != nil { if err != nil {
@@ -63,7 +63,7 @@ func TestSetList(t *testing.T) {
t.Fatalf("Expected %v, got %v", e, a) t.Fatalf("Expected %v, got %v", e, a)
} }
for i := range list { for i := range list {
if e, a := list[i].(*api.Pod).ID, pl.Items[i].ID; e != a { if e, a := list[i].(*api.Pod).Name, pl.Items[i].Name; e != a {
t.Fatalf("Expected %v, got %v", e, a) t.Fatalf("Expected %v, got %v", e, a)
} }
} }

View File

@@ -195,7 +195,7 @@ func fieldPtr(v reflect.Value, fieldName string, dest interface{}) error {
// Returns an error if this isn't the case. // Returns an error if this isn't the case.
func newGenericTypeMeta(v reflect.Value) (genericTypeMeta, error) { func newGenericTypeMeta(v reflect.Value) (genericTypeMeta, error) {
g := genericTypeMeta{} g := genericTypeMeta{}
if err := fieldPtr(v, "ID", &g.id); err != nil { if err := fieldPtr(v, "Name", &g.id); err != nil {
return g, err return g, err
} }
if err := fieldPtr(v, "APIVersion", &g.apiVersion); err != nil { if err := fieldPtr(v, "APIVersion", &g.apiVersion); err != nil {

View File

@@ -26,14 +26,14 @@ import (
func TestGenericTypeMeta(t *testing.T) { func TestGenericTypeMeta(t *testing.T) {
type TypeMeta struct { type TypeMeta struct {
Kind string `json:"kind,omitempty" yaml:"kind,omitempty"` Kind string `json:"kind,omitempty" yaml:"kind,omitempty"`
ID string `json:"id,omitempty" yaml:"id,omitempty"` Name string `json:"name,omitempty" yaml:"name,omitempty"`
CreationTimestamp util.Time `json:"creationTimestamp,omitempty" yaml:"creationTimestamp,omitempty"` CreationTimestamp util.Time `json:"creationTimestamp,omitempty" yaml:"creationTimestamp,omitempty"`
SelfLink string `json:"selfLink,omitempty" yaml:"selfLink,omitempty"` SelfLink string `json:"selfLink,omitempty" yaml:"selfLink,omitempty"`
ResourceVersion string `json:"resourceVersion,omitempty" yaml:"resourceVersion,omitempty"` ResourceVersion string `json:"resourceVersion,omitempty" yaml:"resourceVersion,omitempty"`
APIVersion string `json:"apiVersion,omitempty" yaml:"apiVersion,omitempty"` APIVersion string `json:"apiVersion,omitempty" yaml:"apiVersion,omitempty"`
} }
j := TypeMeta{ j := TypeMeta{
ID: "foo", Name: "foo",
APIVersion: "a", APIVersion: "a",
Kind: "b", Kind: "b",
ResourceVersion: "1", ResourceVersion: "1",
@@ -68,7 +68,7 @@ func TestGenericTypeMeta(t *testing.T) {
jbi.SetSelfLink("google.com") jbi.SetSelfLink("google.com")
// Prove that jbi changes the original object. // Prove that jbi changes the original object.
if e, a := "bar", j.ID; e != a { if e, a := "bar", j.Name; e != a {
t.Errorf("expected %v, got %v", e, a) t.Errorf("expected %v, got %v", e, a)
} }
if e, a := "c", j.APIVersion; e != a { if e, a := "c", j.APIVersion; e != a {

View File

@@ -36,7 +36,7 @@ import (
// //
type TypeMeta struct { type TypeMeta struct {
Kind string `json:"kind,omitempty" yaml:"kind,omitempty"` Kind string `json:"kind,omitempty" yaml:"kind,omitempty"`
ID string `json:"id,omitempty" yaml:"id,omitempty"` Name string `json:"name,omitempty" yaml:"name,omitempty"`
CreationTimestamp util.Time `json:"creationTimestamp,omitempty" yaml:"creationTimestamp,omitempty"` CreationTimestamp util.Time `json:"creationTimestamp,omitempty" yaml:"creationTimestamp,omitempty"`
SelfLink string `json:"selfLink,omitempty" yaml:"selfLink,omitempty"` SelfLink string `json:"selfLink,omitempty" yaml:"selfLink,omitempty"`
ResourceVersion string `json:"resourceVersion,omitempty" yaml:"resourceVersion,omitempty"` ResourceVersion string `json:"resourceVersion,omitempty" yaml:"resourceVersion,omitempty"`

View File

@@ -72,7 +72,7 @@ func findNodesThatFit(pod api.Pod, podLister PodLister, predicates []FitPredicat
for _, node := range nodes.Items { for _, node := range nodes.Items {
fits := true fits := true
for _, predicate := range predicates { for _, predicate := range predicates {
fit, err := predicate(pod, machineToPods[node.ID], node.ID) fit, err := predicate(pod, machineToPods[node.Name], node.Name)
if err != nil { if err != nil {
return api.MinionList{}, err return api.MinionList{}, err
} }
@@ -111,7 +111,7 @@ func EqualPriority(pod api.Pod, podLister PodLister, minionLister MinionLister)
} }
for _, minion := range nodes.Items { for _, minion := range nodes.Items {
result = append(result, HostPriority{ result = append(result, HostPriority{
host: minion.ID, host: minion.Name,
score: 1, score: 1,
}) })
} }

View File

@@ -34,7 +34,7 @@ func truePredicate(pod api.Pod, existingPods []api.Pod, node string) (bool, erro
} }
func matchesPredicate(pod api.Pod, existingPods []api.Pod, node string) (bool, error) { func matchesPredicate(pod api.Pod, existingPods []api.Pod, node string) (bool, error) {
return pod.ID == node, nil return pod.Name == node, nil
} }
func numericPriority(pod api.Pod, podLister PodLister, minionLister MinionLister) (HostPriorityList, error) { func numericPriority(pod api.Pod, podLister PodLister, minionLister MinionLister) (HostPriorityList, error) {
@@ -46,12 +46,12 @@ func numericPriority(pod api.Pod, podLister PodLister, minionLister MinionLister
return nil, err return nil, err
} }
for _, minion := range nodes.Items { for _, minion := range nodes.Items {
score, err := strconv.Atoi(minion.ID) score, err := strconv.Atoi(minion.Name)
if err != nil { if err != nil {
return nil, err return nil, err
} }
result = append(result, HostPriority{ result = append(result, HostPriority{
host: minion.ID, host: minion.Name,
score: score, score: score,
}) })
} }
@@ -63,7 +63,7 @@ func makeMinionList(nodeNames []string) api.MinionList {
Items: make([]api.Minion, len(nodeNames)), Items: make([]api.Minion, len(nodeNames)),
} }
for ix := range nodeNames { for ix := range nodeNames {
result.Items[ix].ID = nodeNames[ix] result.Items[ix].Name = nodeNames[ix]
} }
return result return result
} }
@@ -95,7 +95,7 @@ func TestGenericScheduler(t *testing.T) {
predicates: []FitPredicate{matchesPredicate}, predicates: []FitPredicate{matchesPredicate},
prioritizer: EqualPriority, prioritizer: EqualPriority,
nodes: []string{"machine1", "machine2"}, nodes: []string{"machine1", "machine2"},
pod: api.Pod{TypeMeta: api.TypeMeta{ID: "machine2"}}, pod: api.Pod{TypeMeta: api.TypeMeta{Name: "machine2"}},
expectedHost: "machine2", expectedHost: "machine2",
}, },
{ {
@@ -108,7 +108,7 @@ func TestGenericScheduler(t *testing.T) {
predicates: []FitPredicate{matchesPredicate}, predicates: []FitPredicate{matchesPredicate},
prioritizer: numericPriority, prioritizer: numericPriority,
nodes: []string{"3", "2", "1"}, nodes: []string{"3", "2", "1"},
pod: api.Pod{TypeMeta: api.TypeMeta{ID: "2"}}, pod: api.Pod{TypeMeta: api.TypeMeta{Name: "2"}},
expectedHost: "2", expectedHost: "2",
}, },
{ {

View File

@@ -36,7 +36,7 @@ type StaticNodeInfo struct {
func (nodes StaticNodeInfo) GetNodeInfo(nodeID string) (*api.Minion, error) { func (nodes StaticNodeInfo) GetNodeInfo(nodeID string) (*api.Minion, error) {
for ix := range nodes.Items { for ix := range nodes.Items {
if nodes.Items[ix].ID == nodeID { if nodes.Items[ix].Name == nodeID {
return &nodes.Items[ix], nil return &nodes.Items[ix], nil
} }
} }

View File

@@ -47,7 +47,7 @@ func calculateOccupancy(node api.Minion, pods []api.Pod) HostPriority {
glog.V(4).Infof("Least Requested Priority, AbsoluteRequested: (%d, %d) Percentage:(%d\\%m, %d\\%)", totalCPU, totalMemory, percentageCPU, percentageMemory) glog.V(4).Infof("Least Requested Priority, AbsoluteRequested: (%d, %d) Percentage:(%d\\%m, %d\\%)", totalCPU, totalMemory, percentageCPU, percentageMemory)
return HostPriority{ return HostPriority{
host: node.ID, host: node.Name,
score: int((percentageCPU + percentageMemory) / 2), score: int((percentageCPU + percentageMemory) / 2),
} }
} }
@@ -65,7 +65,7 @@ func LeastRequestedPriority(pod api.Pod, podLister PodLister, minionLister Minio
list := HostPriorityList{} list := HostPriorityList{}
for _, node := range nodes.Items { for _, node := range nodes.Items {
list = append(list, calculateOccupancy(node, podsToMachines[node.ID])) list = append(list, calculateOccupancy(node, podsToMachines[node.Name]))
} }
return list, nil return list, nil
} }

View File

@@ -27,7 +27,7 @@ import (
func makeMinion(node string, cpu, memory int) api.Minion { func makeMinion(node string, cpu, memory int) api.Minion {
return api.Minion{ return api.Minion{
TypeMeta: api.TypeMeta{ID: node}, TypeMeta: api.TypeMeta{Name: node},
NodeResources: api.NodeResources{ NodeResources: api.NodeResources{
Capacity: api.ResourceList{ Capacity: api.ResourceList{
resources.CPU: util.NewIntOrStringFromInt(cpu), resources.CPU: util.NewIntOrStringFromInt(cpu),

View File

@@ -44,7 +44,7 @@ func CalculateSpreadPriority(pod api.Pod, podLister PodLister, minionLister Mini
result := []HostPriority{} result := []HostPriority{}
for _, minion := range minions.Items { for _, minion := range minions.Items {
result = append(result, HostPriority{host: minion.ID, score: counts[minion.ID]}) result = append(result, HostPriority{host: minion.Name, score: counts[minion.Name]})
} }
return result, nil return result, nil
} }

View File

@@ -72,13 +72,13 @@ func (e *EndpointController) SyncServiceEndpoints() error {
} }
endpoints = append(endpoints, net.JoinHostPort(pod.CurrentState.PodIP, strconv.Itoa(port))) endpoints = append(endpoints, net.JoinHostPort(pod.CurrentState.PodIP, strconv.Itoa(port)))
} }
currentEndpoints, err := e.client.GetEndpoints(nsCtx, service.ID) currentEndpoints, err := e.client.GetEndpoints(nsCtx, service.Name)
if err != nil { if err != nil {
// TODO this is brittle as all get out, refactor the client libraries to return a structured error. // TODO this is brittle as all get out, refactor the client libraries to return a structured error.
if errors.IsNotFound(err) { if errors.IsNotFound(err) {
currentEndpoints = &api.Endpoints{ currentEndpoints = &api.Endpoints{
TypeMeta: api.TypeMeta{ TypeMeta: api.TypeMeta{
ID: service.ID, Name: service.Name,
}, },
} }
} else { } else {
@@ -96,7 +96,7 @@ func (e *EndpointController) SyncServiceEndpoints() error {
} else { } else {
// Pre-existing // Pre-existing
if endpointsEqual(currentEndpoints, endpoints) { if endpointsEqual(currentEndpoints, endpoints) {
glog.V(2).Infof("endpoints are equal for %s, skipping update", service.ID) glog.V(2).Infof("endpoints are equal for %s, skipping update", service.Name)
continue continue
} }
_, err = e.client.UpdateEndpoints(nsCtx, newEndpoints) _, err = e.client.UpdateEndpoints(nsCtx, newEndpoints)

View File

@@ -35,7 +35,7 @@ func newPodList(count int) api.PodList {
for i := 0; i < count; i++ { for i := 0; i < count; i++ {
pods = append(pods, api.Pod{ pods = append(pods, api.Pod{
TypeMeta: api.TypeMeta{ TypeMeta: api.TypeMeta{
ID: fmt.Sprintf("pod%d", i), Name: fmt.Sprintf("pod%d", i),
APIVersion: testapi.Version(), APIVersion: testapi.Version(),
}, },
DesiredState: api.PodState{ DesiredState: api.PodState{
@@ -181,7 +181,7 @@ func TestSyncEndpointsItemsPreexisting(t *testing.T) {
serviceList := api.ServiceList{ serviceList := api.ServiceList{
Items: []api.Service{ Items: []api.Service{
{ {
TypeMeta: api.TypeMeta{ID: "foo"}, TypeMeta: api.TypeMeta{Name: "foo"},
Selector: map[string]string{ Selector: map[string]string{
"foo": "bar", "foo": "bar",
}, },
@@ -193,7 +193,7 @@ func TestSyncEndpointsItemsPreexisting(t *testing.T) {
serverResponse{http.StatusOK, serviceList}, serverResponse{http.StatusOK, serviceList},
serverResponse{http.StatusOK, api.Endpoints{ serverResponse{http.StatusOK, api.Endpoints{
TypeMeta: api.TypeMeta{ TypeMeta: api.TypeMeta{
ID: "foo", Name: "foo",
ResourceVersion: "1", ResourceVersion: "1",
}, },
Endpoints: []string{"6.7.8.9:1000"}, Endpoints: []string{"6.7.8.9:1000"},
@@ -205,7 +205,7 @@ func TestSyncEndpointsItemsPreexisting(t *testing.T) {
} }
data := runtime.EncodeOrDie(testapi.Codec(), &api.Endpoints{ data := runtime.EncodeOrDie(testapi.Codec(), &api.Endpoints{
TypeMeta: api.TypeMeta{ TypeMeta: api.TypeMeta{
ID: "foo", Name: "foo",
ResourceVersion: "1", ResourceVersion: "1",
}, },
Endpoints: []string{"1.2.3.4:8080"}, Endpoints: []string{"1.2.3.4:8080"},
@@ -217,7 +217,7 @@ func TestSyncEndpointsItemsPreexistingIdentical(t *testing.T) {
serviceList := api.ServiceList{ serviceList := api.ServiceList{
Items: []api.Service{ Items: []api.Service{
{ {
TypeMeta: api.TypeMeta{ID: "foo"}, TypeMeta: api.TypeMeta{Name: "foo"},
Selector: map[string]string{ Selector: map[string]string{
"foo": "bar", "foo": "bar",
}, },
@@ -245,7 +245,7 @@ func TestSyncEndpointsItems(t *testing.T) {
serviceList := api.ServiceList{ serviceList := api.ServiceList{
Items: []api.Service{ Items: []api.Service{
{ {
TypeMeta: api.TypeMeta{ID: "foo"}, TypeMeta: api.TypeMeta{Name: "foo"},
Selector: map[string]string{ Selector: map[string]string{
"foo": "bar", "foo": "bar",
}, },

View File

@@ -73,15 +73,15 @@ func TestExtractToList(t *testing.T) {
Node: &etcd.Node{ Node: &etcd.Node{
Nodes: []*etcd.Node{ Nodes: []*etcd.Node{
{ {
Value: `{"id":"foo"}`, Value: `{"name":"foo"}`,
ModifiedIndex: 1, ModifiedIndex: 1,
}, },
{ {
Value: `{"id":"bar"}`, Value: `{"name":"bar"}`,
ModifiedIndex: 2, ModifiedIndex: 2,
}, },
{ {
Value: `{"id":"baz"}`, Value: `{"name":"baz"}`,
ModifiedIndex: 3, ModifiedIndex: 3,
}, },
}, },
@@ -91,9 +91,9 @@ func TestExtractToList(t *testing.T) {
expect := api.PodList{ expect := api.PodList{
TypeMeta: api.TypeMeta{ResourceVersion: "10"}, TypeMeta: api.TypeMeta{ResourceVersion: "10"},
Items: []api.Pod{ Items: []api.Pod{
{TypeMeta: api.TypeMeta{ID: "foo", ResourceVersion: "1"}}, {TypeMeta: api.TypeMeta{Name: "foo", ResourceVersion: "1"}},
{TypeMeta: api.TypeMeta{ID: "bar", ResourceVersion: "2"}}, {TypeMeta: api.TypeMeta{Name: "bar", ResourceVersion: "2"}},
{TypeMeta: api.TypeMeta{ID: "baz", ResourceVersion: "3"}}, {TypeMeta: api.TypeMeta{Name: "baz", ResourceVersion: "3"}},
}, },
} }
@@ -117,21 +117,21 @@ func TestExtractToListAcrossDirectories(t *testing.T) {
Node: &etcd.Node{ Node: &etcd.Node{
Nodes: []*etcd.Node{ Nodes: []*etcd.Node{
{ {
Value: `{"id": "directory1"}`, Value: `{"name": "directory1"}`,
Dir: true, Dir: true,
Nodes: []*etcd.Node{ Nodes: []*etcd.Node{
{ {
Value: `{"id":"foo"}`, Value: `{"name":"foo"}`,
ModifiedIndex: 1, ModifiedIndex: 1,
}, },
}, },
}, },
{ {
Value: `{"id": "directory2"}`, Value: `{"name": "directory2"}`,
Dir: true, Dir: true,
Nodes: []*etcd.Node{ Nodes: []*etcd.Node{
{ {
Value: `{"id":"bar"}`, Value: `{"name":"bar"}`,
ModifiedIndex: 2, ModifiedIndex: 2,
}, },
}, },
@@ -143,8 +143,8 @@ func TestExtractToListAcrossDirectories(t *testing.T) {
expect := api.PodList{ expect := api.PodList{
TypeMeta: api.TypeMeta{ResourceVersion: "10"}, TypeMeta: api.TypeMeta{ResourceVersion: "10"},
Items: []api.Pod{ Items: []api.Pod{
{TypeMeta: api.TypeMeta{ID: "foo", ResourceVersion: "1"}}, {TypeMeta: api.TypeMeta{Name: "foo", ResourceVersion: "1"}},
{TypeMeta: api.TypeMeta{ID: "bar", ResourceVersion: "2"}}, {TypeMeta: api.TypeMeta{Name: "bar", ResourceVersion: "2"}},
}, },
} }
@@ -167,19 +167,19 @@ func TestExtractToListExcludesDirectories(t *testing.T) {
Node: &etcd.Node{ Node: &etcd.Node{
Nodes: []*etcd.Node{ Nodes: []*etcd.Node{
{ {
Value: `{"id":"foo"}`, Value: `{"name":"foo"}`,
ModifiedIndex: 1, ModifiedIndex: 1,
}, },
{ {
Value: `{"id":"bar"}`, Value: `{"name":"bar"}`,
ModifiedIndex: 2, ModifiedIndex: 2,
}, },
{ {
Value: `{"id":"baz"}`, Value: `{"name":"baz"}`,
ModifiedIndex: 3, ModifiedIndex: 3,
}, },
{ {
Value: `{"id": "directory"}`, Value: `{"name": "directory"}`,
Dir: true, Dir: true,
}, },
}, },
@@ -189,9 +189,9 @@ func TestExtractToListExcludesDirectories(t *testing.T) {
expect := api.PodList{ expect := api.PodList{
TypeMeta: api.TypeMeta{ResourceVersion: "10"}, TypeMeta: api.TypeMeta{ResourceVersion: "10"},
Items: []api.Pod{ Items: []api.Pod{
{TypeMeta: api.TypeMeta{ID: "foo", ResourceVersion: "1"}}, {TypeMeta: api.TypeMeta{Name: "foo", ResourceVersion: "1"}},
{TypeMeta: api.TypeMeta{ID: "bar", ResourceVersion: "2"}}, {TypeMeta: api.TypeMeta{Name: "bar", ResourceVersion: "2"}},
{TypeMeta: api.TypeMeta{ID: "baz", ResourceVersion: "3"}}, {TypeMeta: api.TypeMeta{Name: "baz", ResourceVersion: "3"}},
}, },
} }
@@ -208,7 +208,7 @@ func TestExtractToListExcludesDirectories(t *testing.T) {
func TestExtractObj(t *testing.T) { func TestExtractObj(t *testing.T) {
fakeClient := NewFakeEtcdClient(t) fakeClient := NewFakeEtcdClient(t)
expect := api.Pod{TypeMeta: api.TypeMeta{ID: "foo"}} expect := api.Pod{TypeMeta: api.TypeMeta{Name: "foo"}}
fakeClient.Set("/some/key", util.EncodeJSON(expect), 0) fakeClient.Set("/some/key", util.EncodeJSON(expect), 0)
helper := EtcdHelper{fakeClient, latest.Codec, versioner} helper := EtcdHelper{fakeClient, latest.Codec, versioner}
var got api.Pod var got api.Pod
@@ -262,7 +262,7 @@ func TestExtractObjNotFoundErr(t *testing.T) {
} }
func TestCreateObj(t *testing.T) { func TestCreateObj(t *testing.T) {
obj := &api.Pod{TypeMeta: api.TypeMeta{ID: "foo"}} obj := &api.Pod{TypeMeta: api.TypeMeta{Name: "foo"}}
fakeClient := NewFakeEtcdClient(t) fakeClient := NewFakeEtcdClient(t)
helper := EtcdHelper{fakeClient, latest.Codec, versioner} helper := EtcdHelper{fakeClient, latest.Codec, versioner}
err := helper.CreateObj("/some/key", obj, 5) err := helper.CreateObj("/some/key", obj, 5)
@@ -283,7 +283,7 @@ func TestCreateObj(t *testing.T) {
} }
func TestSetObj(t *testing.T) { func TestSetObj(t *testing.T) {
obj := &api.Pod{TypeMeta: api.TypeMeta{ID: "foo"}} obj := &api.Pod{TypeMeta: api.TypeMeta{Name: "foo"}}
fakeClient := NewFakeEtcdClient(t) fakeClient := NewFakeEtcdClient(t)
helper := EtcdHelper{fakeClient, latest.Codec, versioner} helper := EtcdHelper{fakeClient, latest.Codec, versioner}
err := helper.SetObj("/some/key", obj) err := helper.SetObj("/some/key", obj)
@@ -302,7 +302,7 @@ func TestSetObj(t *testing.T) {
} }
func TestSetObjWithVersion(t *testing.T) { func TestSetObjWithVersion(t *testing.T) {
obj := &api.Pod{TypeMeta: api.TypeMeta{ID: "foo", ResourceVersion: "1"}} obj := &api.Pod{TypeMeta: api.TypeMeta{Name: "foo", ResourceVersion: "1"}}
fakeClient := NewFakeEtcdClient(t) fakeClient := NewFakeEtcdClient(t)
fakeClient.TestIndex = true fakeClient.TestIndex = true
fakeClient.Data["/some/key"] = EtcdResponseWithError{ fakeClient.Data["/some/key"] = EtcdResponseWithError{
@@ -331,7 +331,7 @@ func TestSetObjWithVersion(t *testing.T) {
} }
func TestSetObjWithoutResourceVersioner(t *testing.T) { func TestSetObjWithoutResourceVersioner(t *testing.T) {
obj := &api.Pod{TypeMeta: api.TypeMeta{ID: "foo"}} obj := &api.Pod{TypeMeta: api.TypeMeta{Name: "foo"}}
fakeClient := NewFakeEtcdClient(t) fakeClient := NewFakeEtcdClient(t)
helper := EtcdHelper{fakeClient, latest.Codec, nil} helper := EtcdHelper{fakeClient, latest.Codec, nil}
err := helper.SetObj("/some/key", obj) err := helper.SetObj("/some/key", obj)
@@ -356,7 +356,7 @@ func TestAtomicUpdate(t *testing.T) {
// Create a new node. // Create a new node.
fakeClient.ExpectNotFoundGet("/some/key") fakeClient.ExpectNotFoundGet("/some/key")
obj := &TestResource{TypeMeta: api.TypeMeta{ID: "foo"}, Value: 1} obj := &TestResource{TypeMeta: api.TypeMeta{Name: "foo"}, Value: 1}
err := helper.AtomicUpdate("/some/key", &TestResource{}, func(in runtime.Object) (runtime.Object, error) { err := helper.AtomicUpdate("/some/key", &TestResource{}, func(in runtime.Object) (runtime.Object, error) {
return obj, nil return obj, nil
}) })
@@ -375,7 +375,7 @@ func TestAtomicUpdate(t *testing.T) {
// Update an existing node. // Update an existing node.
callbackCalled := false callbackCalled := false
objUpdate := &TestResource{TypeMeta: api.TypeMeta{ID: "foo"}, Value: 2} objUpdate := &TestResource{TypeMeta: api.TypeMeta{Name: "foo"}, Value: 2}
err = helper.AtomicUpdate("/some/key", &TestResource{}, func(in runtime.Object) (runtime.Object, error) { err = helper.AtomicUpdate("/some/key", &TestResource{}, func(in runtime.Object) (runtime.Object, error) {
callbackCalled = true callbackCalled = true
@@ -410,7 +410,7 @@ func TestAtomicUpdateNoChange(t *testing.T) {
// Create a new node. // Create a new node.
fakeClient.ExpectNotFoundGet("/some/key") fakeClient.ExpectNotFoundGet("/some/key")
obj := &TestResource{TypeMeta: api.TypeMeta{ID: "foo"}, Value: 1} obj := &TestResource{TypeMeta: api.TypeMeta{Name: "foo"}, Value: 1}
err := helper.AtomicUpdate("/some/key", &TestResource{}, func(in runtime.Object) (runtime.Object, error) { err := helper.AtomicUpdate("/some/key", &TestResource{}, func(in runtime.Object) (runtime.Object, error) {
return obj, nil return obj, nil
}) })
@@ -420,7 +420,7 @@ func TestAtomicUpdateNoChange(t *testing.T) {
// Update an existing node with the same data // Update an existing node with the same data
callbackCalled := false callbackCalled := false
objUpdate := &TestResource{TypeMeta: api.TypeMeta{ID: "foo"}, Value: 1} objUpdate := &TestResource{TypeMeta: api.TypeMeta{Name: "foo"}, Value: 1}
fakeClient.Err = errors.New("should not be called") fakeClient.Err = errors.New("should not be called")
err = helper.AtomicUpdate("/some/key", &TestResource{}, func(in runtime.Object) (runtime.Object, error) { err = helper.AtomicUpdate("/some/key", &TestResource{}, func(in runtime.Object) (runtime.Object, error) {
callbackCalled = true callbackCalled = true
@@ -463,7 +463,7 @@ func TestAtomicUpdate_CreateCollision(t *testing.T) {
} }
currValue := in.(*TestResource).Value currValue := in.(*TestResource).Value
obj := &TestResource{TypeMeta: api.TypeMeta{ID: "foo"}, Value: currValue + 1} obj := &TestResource{TypeMeta: api.TypeMeta{Name: "foo"}, Value: currValue + 1}
return obj, nil return obj, nil
}) })
if err != nil { if err != nil {

View File

@@ -32,11 +32,11 @@ import (
func TestWatchInterpretations(t *testing.T) { func TestWatchInterpretations(t *testing.T) {
codec := latest.Codec codec := latest.Codec
// Declare some pods to make the test cases compact. // Declare some pods to make the test cases compact.
podFoo := &api.Pod{TypeMeta: api.TypeMeta{ID: "foo"}} podFoo := &api.Pod{TypeMeta: api.TypeMeta{Name: "foo"}}
podBar := &api.Pod{TypeMeta: api.TypeMeta{ID: "bar"}} podBar := &api.Pod{TypeMeta: api.TypeMeta{Name: "bar"}}
podBaz := &api.Pod{TypeMeta: api.TypeMeta{ID: "baz"}} podBaz := &api.Pod{TypeMeta: api.TypeMeta{Name: "baz"}}
firstLetterIsB := func(obj runtime.Object) bool { firstLetterIsB := func(obj runtime.Object) bool {
return obj.(*api.Pod).ID[0] == 'b' return obj.(*api.Pod).Name[0] == 'b'
} }
// All of these test cases will be run with the firstLetterIsB FilterFunc. // All of these test cases will be run with the firstLetterIsB FilterFunc.
@@ -236,7 +236,7 @@ func TestWatch(t *testing.T) {
} }
// Test normal case // Test normal case
pod := &api.Pod{TypeMeta: api.TypeMeta{ID: "foo"}} pod := &api.Pod{TypeMeta: api.TypeMeta{Name: "foo"}}
podBytes, _ := codec.Encode(pod) podBytes, _ := codec.Encode(pod)
fakeClient.WatchResponse <- &etcd.Response{ fakeClient.WatchResponse <- &etcd.Response{
Action: "set", Action: "set",
@@ -294,7 +294,7 @@ func TestWatchEtcdState(t *testing.T) {
{ {
Action: "create", Action: "create",
Node: &etcd.Node{ Node: &etcd.Node{
Value: string(runtime.EncodeOrDie(codec, &api.Endpoints{TypeMeta: api.TypeMeta{ID: "foo"}, Endpoints: []string{}})), Value: string(runtime.EncodeOrDie(codec, &api.Endpoints{TypeMeta: api.TypeMeta{Name: "foo"}, Endpoints: []string{}})),
}, },
}, },
}, },
@@ -308,12 +308,12 @@ func TestWatchEtcdState(t *testing.T) {
{ {
Action: "compareAndSwap", Action: "compareAndSwap",
Node: &etcd.Node{ Node: &etcd.Node{
Value: string(runtime.EncodeOrDie(codec, &api.Endpoints{TypeMeta: api.TypeMeta{ID: "foo"}, Endpoints: []string{"127.0.0.1:9000"}})), Value: string(runtime.EncodeOrDie(codec, &api.Endpoints{TypeMeta: api.TypeMeta{Name: "foo"}, Endpoints: []string{"127.0.0.1:9000"}})),
CreatedIndex: 1, CreatedIndex: 1,
ModifiedIndex: 2, ModifiedIndex: 2,
}, },
PrevNode: &etcd.Node{ PrevNode: &etcd.Node{
Value: string(runtime.EncodeOrDie(codec, &api.Endpoints{TypeMeta: api.TypeMeta{ID: "foo"}, Endpoints: []string{}})), Value: string(runtime.EncodeOrDie(codec, &api.Endpoints{TypeMeta: api.TypeMeta{Name: "foo"}, Endpoints: []string{}})),
CreatedIndex: 1, CreatedIndex: 1,
ModifiedIndex: 1, ModifiedIndex: 1,
}, },
@@ -330,7 +330,7 @@ func TestWatchEtcdState(t *testing.T) {
R: &etcd.Response{ R: &etcd.Response{
Action: "get", Action: "get",
Node: &etcd.Node{ Node: &etcd.Node{
Value: string(runtime.EncodeOrDie(codec, &api.Endpoints{TypeMeta: api.TypeMeta{ID: "foo"}, Endpoints: []string{}})), Value: string(runtime.EncodeOrDie(codec, &api.Endpoints{TypeMeta: api.TypeMeta{Name: "foo"}, Endpoints: []string{}})),
CreatedIndex: 1, CreatedIndex: 1,
ModifiedIndex: 1, ModifiedIndex: 1,
}, },
@@ -343,12 +343,12 @@ func TestWatchEtcdState(t *testing.T) {
{ {
Action: "compareAndSwap", Action: "compareAndSwap",
Node: &etcd.Node{ Node: &etcd.Node{
Value: string(runtime.EncodeOrDie(codec, &api.Endpoints{TypeMeta: api.TypeMeta{ID: "foo"}, Endpoints: []string{"127.0.0.1:9000"}})), Value: string(runtime.EncodeOrDie(codec, &api.Endpoints{TypeMeta: api.TypeMeta{Name: "foo"}, Endpoints: []string{"127.0.0.1:9000"}})),
CreatedIndex: 1, CreatedIndex: 1,
ModifiedIndex: 2, ModifiedIndex: 2,
}, },
PrevNode: &etcd.Node{ PrevNode: &etcd.Node{
Value: string(runtime.EncodeOrDie(codec, &api.Endpoints{TypeMeta: api.TypeMeta{ID: "foo"}, Endpoints: []string{}})), Value: string(runtime.EncodeOrDie(codec, &api.Endpoints{TypeMeta: api.TypeMeta{Name: "foo"}, Endpoints: []string{}})),
CreatedIndex: 1, CreatedIndex: 1,
ModifiedIndex: 1, ModifiedIndex: 1,
}, },
@@ -391,7 +391,7 @@ func TestWatchEtcdState(t *testing.T) {
func TestWatchFromZeroIndex(t *testing.T) { func TestWatchFromZeroIndex(t *testing.T) {
codec := latest.Codec codec := latest.Codec
pod := &api.Pod{TypeMeta: api.TypeMeta{ID: "foo"}} pod := &api.Pod{TypeMeta: api.TypeMeta{Name: "foo"}}
testCases := map[string]struct { testCases := map[string]struct {
Response EtcdResponseWithError Response EtcdResponseWithError
@@ -464,7 +464,7 @@ func TestWatchFromZeroIndex(t *testing.T) {
func TestWatchListFromZeroIndex(t *testing.T) { func TestWatchListFromZeroIndex(t *testing.T) {
codec := latest.Codec codec := latest.Codec
pod := &api.Pod{TypeMeta: api.TypeMeta{ID: "foo"}} pod := &api.Pod{TypeMeta: api.TypeMeta{Name: "foo"}}
fakeClient := NewFakeEtcdClient(t) fakeClient := NewFakeEtcdClient(t)
fakeClient.Data["/some/key"] = EtcdResponseWithError{ fakeClient.Data["/some/key"] = EtcdResponseWithError{

View File

@@ -36,7 +36,7 @@ func TestDecoder(t *testing.T) {
out, in := io.Pipe() out, in := io.Pipe()
decoder := NewDecoder(out, testapi.Codec()) decoder := NewDecoder(out, testapi.Codec())
expect := &api.Pod{TypeMeta: api.TypeMeta{ID: "foo"}} expect := &api.Pod{TypeMeta: api.TypeMeta{Name: "foo"}}
encoder := json.NewEncoder(in) encoder := json.NewEncoder(in)
go func() { go func() {
data, err := testapi.Codec().Encode(expect) data, err := testapi.Codec().Encode(expect)

Some files were not shown because too many files have changed in this diff Show More