From d590af2ce54464caefcde952236f80747a46ff70 Mon Sep 17 00:00:00 2001 From: derekwaynecarr Date: Fri, 17 Oct 2014 12:09:01 -0400 Subject: [PATCH] Fixup kubelet handlePodInfo to be namespace aware --- pkg/kubelet/config/config_test.go | 2 +- pkg/kubelet/server.go | 11 ++++++++--- pkg/kubelet/server_test.go | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/pkg/kubelet/config/config_test.go b/pkg/kubelet/config/config_test.go index 4671c65aa80..bbed599133b 100644 --- a/pkg/kubelet/config/config_test.go +++ b/pkg/kubelet/config/config_test.go @@ -42,7 +42,7 @@ func (s sortedPods) Swap(i, j int) { s[i], s[j] = s[j], s[i] } func (s sortedPods) Less(i, j int) bool { - return s[i].ID < s[j].ID + return s[i].ID < s[j].ID && s[i].Namespace < s[j].Namespace } func CreateValidPod(name, namespace, source string) api.BoundPod { diff --git a/pkg/kubelet/server.go b/pkg/kubelet/server.go index 16d7f689342..daa077a2f8e 100644 --- a/pkg/kubelet/server.go +++ b/pkg/kubelet/server.go @@ -228,17 +228,22 @@ func (s *Server) handlePodInfo(w http.ResponseWriter, req *http.Request) { } podID := u.Query().Get("podID") podUUID := u.Query().Get("UUID") + podNamespace := u.Query().Get("podNamespace") if len(podID) == 0 { w.WriteHeader(http.StatusBadRequest) http.Error(w, "Missing 'podID=' query entry.", http.StatusBadRequest) return } + if len(podNamespace) == 0 { + w.WriteHeader(http.StatusBadRequest) + http.Error(w, "Missing 'podNamespace=' query entry.", http.StatusBadRequest) + return + } // TODO: backwards compatibility with existing API, needs API change podFullName := GetPodFullName(&api.BoundPod{ TypeMeta: api.TypeMeta{ - ID: podID, - // TODO: I am broken - Namespace: api.NamespaceDefault, + ID: podID, + Namespace: podNamespace, Annotations: map[string]string{ConfigSourceAnnotationKey: "etcd"}, }, }) diff --git a/pkg/kubelet/server_test.go b/pkg/kubelet/server_test.go index 3261337c47c..13a98b2ecab 100644 --- a/pkg/kubelet/server_test.go +++ b/pkg/kubelet/server_test.go @@ -263,7 +263,7 @@ func TestPodInfo(t *testing.T) { } return nil, fmt.Errorf("bad pod %s", name) } - resp, err := http.Get(fw.testHTTPServer.URL + "/podInfo?podID=goodpod") + resp, err := http.Get(fw.testHTTPServer.URL + "/podInfo?podID=goodpod&podNamespace=default") if err != nil { t.Errorf("Got error GETing: %v", err) }