Merge pull request #345 from smarterclayton/fix_ids

Ensure pod and manifest have a UUID in apiserver
This commit is contained in:
Tim Hockin
2014-07-11 11:29:00 -07:00
17 changed files with 1192 additions and 14 deletions

View File

@@ -19,7 +19,6 @@ package controller
import (
"encoding/json"
"fmt"
"math/rand"
"time"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
@@ -64,9 +63,6 @@ func (r RealPodControl) createReplica(controllerSpec api.ReplicationController)
labels["replicationController"] = controllerSpec.ID
}
pod := api.Pod{
JSONBase: api.JSONBase{
ID: fmt.Sprintf("%08x", rand.Uint32()),
},
DesiredState: controllerSpec.DesiredState.PodTemplate.DesiredState,
Labels: controllerSpec.DesiredState.PodTemplate.Labels,
}

View File

@@ -200,12 +200,22 @@ func TestCreateReplica(t *testing.T) {
podControl.createReplica(controllerSpec)
//expectedPod := Pod{
// Labels: controllerSpec.DesiredState.PodTemplate.Labels,
// DesiredState: controllerSpec.DesiredState.PodTemplate.DesiredState,
//}
// TODO: fix this so that it validates the body.
expectedPod := api.Pod{
JSONBase: api.JSONBase{
Kind: "Pod",
},
Labels: controllerSpec.DesiredState.PodTemplate.Labels,
DesiredState: controllerSpec.DesiredState.PodTemplate.DesiredState,
}
fakeHandler.ValidateRequest(t, makeURL("/pods"), "POST", nil)
actualPod := api.Pod{}
if err := json.Unmarshal([]byte(fakeHandler.RequestBody), &actualPod); err != nil {
t.Errorf("Unexpected error: %#v", err)
}
if !reflect.DeepEqual(expectedPod, actualPod) {
t.Logf("Body: %s", fakeHandler.RequestBody)
t.Errorf("Unexpected mismatch. Expected %#v, Got: %#v", expectedPod, actualPod)
}
}
func TestHandleWatchResponseNotSet(t *testing.T) {