Merge pull request #1646 from dchen1107/termination

Fix an issue on GetContainerInfo.
This commit is contained in:
Tim Hockin 2014-10-07 17:27:56 -07:00
commit 2f2ef05fa8
2 changed files with 7 additions and 4 deletions

View File

@ -318,9 +318,11 @@ func (s *Server) serveStats(w http.ResponseWriter, req *http.Request) {
errors.New("pod level status currently unimplemented") errors.New("pod level status currently unimplemented")
case 3: case 3:
// Backward compatibility without uuid information // Backward compatibility without uuid information
stats, err = s.host.GetContainerInfo(components[1], "", components[2], &query) podFullName := GetPodFullName(&Pod{Name: components[1], Namespace: "etcd"})
stats, err = s.host.GetContainerInfo(podFullName, "", components[2], &query)
case 4: case 4:
stats, err = s.host.GetContainerInfo(components[1], components[2], components[2], &query) podFullName := GetPodFullName(&Pod{Name: components[1], Namespace: "etcd"})
stats, err = s.host.GetContainerInfo(podFullName, components[2], components[2], &query)
default: default:
http.Error(w, "unknown resource.", http.StatusNotFound) http.Error(w, "unknown resource.", http.StatusNotFound)
return return

View File

@ -174,7 +174,8 @@ func TestPodInfo(t *testing.T) {
func TestContainerInfo(t *testing.T) { func TestContainerInfo(t *testing.T) {
fw := newServerTest() fw := newServerTest()
expectedInfo := &info.ContainerInfo{} expectedInfo := &info.ContainerInfo{}
expectedPodID := "somepod" podID := "somepod"
expectedPodID := "somepod" + ".etcd"
expectedContainerName := "goodcontainer" expectedContainerName := "goodcontainer"
fw.fakeKubelet.containerInfoFunc = func(podID, containerName string, req *info.ContainerInfoRequest) (*info.ContainerInfo, error) { fw.fakeKubelet.containerInfoFunc = func(podID, containerName string, req *info.ContainerInfoRequest) (*info.ContainerInfo, error) {
if podID != expectedPodID || containerName != expectedContainerName { if podID != expectedPodID || containerName != expectedContainerName {
@ -183,7 +184,7 @@ func TestContainerInfo(t *testing.T) {
return expectedInfo, nil return expectedInfo, nil
} }
resp, err := http.Get(fw.testHTTPServer.URL + fmt.Sprintf("/stats/%v/%v", expectedPodID, expectedContainerName)) resp, err := http.Get(fw.testHTTPServer.URL + fmt.Sprintf("/stats/%v/%v", podID, expectedContainerName))
if err != nil { if err != nil {
t.Fatalf("Got error GETing: %v", err) t.Fatalf("Got error GETing: %v", err)
} }