From 77dd0afc2648515ee9bcafe25a8fe2aff1377f68 Mon Sep 17 00:00:00 2001 From: Brendan Burns Date: Wed, 18 Jun 2014 10:37:27 -0700 Subject: [PATCH] Fix a bug in pod listing introduced in a recent refactor. Add a test to catch a regression in the future. --- pkg/registry/etcd_registry.go | 1 + pkg/registry/etcd_registry_test.go | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/pkg/registry/etcd_registry.go b/pkg/registry/etcd_registry.go index 55dfeb61b41..fcf5ee064c6 100644 --- a/pkg/registry/etcd_registry.go +++ b/pkg/registry/etcd_registry.go @@ -78,6 +78,7 @@ func (registry *EtcdRegistry) ListPods(query labels.Query) ([]api.Pod, error) { } for _, pod := range machinePods { if query.Matches(labels.Set(pod.Labels)) { + pod.CurrentState.Host = machine pods = append(pods, pod) } } diff --git a/pkg/registry/etcd_registry_test.go b/pkg/registry/etcd_registry_test.go index a9872b888fd..4e13dc9ab12 100644 --- a/pkg/registry/etcd_registry_test.go +++ b/pkg/registry/etcd_registry_test.go @@ -354,6 +354,10 @@ func TestEtcdListPods(t *testing.T) { if len(pods) != 2 || pods[0].ID != "foo" || pods[1].ID != "bar" { t.Errorf("Unexpected pod list: %#v", pods) } + if pods[0].CurrentState.Host != "machine" || + pods[1].CurrentState.Host != "machine" { + t.Errorf("Failed to populate host name.") + } } func TestEtcdListControllersNotFound(t *testing.T) {