Merge pull request #1867 from derekwaynecarr/pod_cache_kubelet_update

Fixup kubelet handlePodInfo to be namespace aware
This commit is contained in:
Eric Tune 2014-10-17 14:18:43 -07:00
commit 1c4e9300f2
3 changed files with 10 additions and 5 deletions

View File

@ -42,7 +42,7 @@ func (s sortedPods) Swap(i, j int) {
s[i], s[j] = s[j], s[i] s[i], s[j] = s[j], s[i]
} }
func (s sortedPods) Less(i, j int) bool { 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 { func CreateValidPod(name, namespace, source string) api.BoundPod {

View File

@ -228,17 +228,22 @@ func (s *Server) handlePodInfo(w http.ResponseWriter, req *http.Request) {
} }
podID := u.Query().Get("podID") podID := u.Query().Get("podID")
podUUID := u.Query().Get("UUID") podUUID := u.Query().Get("UUID")
podNamespace := u.Query().Get("podNamespace")
if len(podID) == 0 { if len(podID) == 0 {
w.WriteHeader(http.StatusBadRequest) w.WriteHeader(http.StatusBadRequest)
http.Error(w, "Missing 'podID=' query entry.", http.StatusBadRequest) http.Error(w, "Missing 'podID=' query entry.", http.StatusBadRequest)
return 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 // 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, ID: podID,
// TODO: I am broken Namespace: podNamespace,
Namespace: api.NamespaceDefault,
Annotations: map[string]string{ConfigSourceAnnotationKey: "etcd"}, Annotations: map[string]string{ConfigSourceAnnotationKey: "etcd"},
}, },
}) })

View File

@ -263,7 +263,7 @@ func TestPodInfo(t *testing.T) {
} }
return nil, fmt.Errorf("bad pod %s", name) 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 { if err != nil {
t.Errorf("Got error GETing: %v", err) t.Errorf("Got error GETing: %v", err)
} }