Move generateID to util.

Signed-off-by: Lantao Liu <lantaol@google.com>
This commit is contained in:
Lantao Liu
2017-08-11 03:03:14 +00:00
parent 07e3a2b5e2
commit 77b703f1e7
5 changed files with 31 additions and 9 deletions

View File

@@ -31,6 +31,7 @@ import (
"k8s.io/kubernetes/pkg/kubelet/apis/cri/v1alpha1/runtime"
containerstore "github.com/kubernetes-incubator/cri-containerd/pkg/store/container"
"github.com/kubernetes-incubator/cri-containerd/pkg/util"
)
// CreateContainer creates a new container in the given PodSandbox.
@@ -54,7 +55,7 @@ func (c *criContainerdService) CreateContainer(ctx context.Context, r *runtime.C
// Generate unique id and name for the container and reserve the name.
// Reserve the container name to avoid concurrent `CreateContainer` request creating
// the same container.
id := generateID()
id := util.GenerateID()
name := makeContainerName(config.GetMetadata(), sandboxConfig.GetMetadata())
if err = c.containerNameIndex.Reserve(name, id); err != nil {
return nil, fmt.Errorf("failed to reserve container name %q: %v", name, err)