From 78d9538358437392c94944750435aa6bc523600b Mon Sep 17 00:00:00 2001 From: Brendan Burns Date: Thu, 26 Jun 2014 19:22:12 -0700 Subject: [PATCH] Set id width at 8 and pad with zeros. --- pkg/controller/replication_controller.go | 2 +- pkg/kubelet/kubelet.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/controller/replication_controller.go b/pkg/controller/replication_controller.go index 7fa568ae27b..e156247e544 100644 --- a/pkg/controller/replication_controller.go +++ b/pkg/controller/replication_controller.go @@ -62,7 +62,7 @@ func (r RealPodControl) createReplica(controllerSpec api.ReplicationController) } pod := api.Pod{ JSONBase: api.JSONBase{ - ID: fmt.Sprintf("%x", rand.Int()), + ID: fmt.Sprintf("%08x", rand.Uint32()), }, DesiredState: controllerSpec.DesiredState.PodTemplate.DesiredState, Labels: controllerSpec.DesiredState.PodTemplate.Labels, diff --git a/pkg/kubelet/kubelet.go b/pkg/kubelet/kubelet.go index 40e3c9be139..8467f333ee0 100644 --- a/pkg/kubelet/kubelet.go +++ b/pkg/kubelet/kubelet.go @@ -263,7 +263,7 @@ const containerNamePrefix = "k8s" // Creates a name which can be reversed to identify both manifest id and container name. func manifestAndContainerToDockerName(manifest *api.ContainerManifest, container *api.Container) string { // Note, manifest.Id could be blank. - return fmt.Sprintf("%s--%s--%s--%x", containerNamePrefix, escapeDash(container.Name), escapeDash(manifest.Id), rand.Uint32()) + return fmt.Sprintf("%s--%s--%s--%08x", containerNamePrefix, escapeDash(container.Name), escapeDash(manifest.Id), rand.Uint32()) } // Upacks a container name, returning the manifest id and container name we would have used to