Merge pull request #48 from mrunalp/pod_namespace

Include pod namespace in the pod name
This commit is contained in:
Antonio Murdaca 2016-09-23 21:11:19 +02:00 committed by GitHub
commit 53c2a359e6

View file

@ -25,6 +25,7 @@ type sandbox struct {
const (
podInfraRootfs = "/var/lib/ocid/graph/vfs/pause"
podDefaultNamespace = "default"
)
func (s *sandbox) addContainer(c *oci.Container) {
@ -39,12 +40,15 @@ func (s *sandbox) removeContainer(c *oci.Container) {
s.containers.Delete(c.Name())
}
func (s *Server) generatePodIDandName(name string) (string, string, error) {
func (s *Server) generatePodIDandName(name, namespace string) (string, string, error) {
var (
err error
id = stringid.GenerateNonCryptoID()
)
if name, err = s.reservePodName(id, name); err != nil {
if namespace == "" {
namespace = podDefaultNamespace
}
if name, err = s.reservePodName(id, namespace+"-"+name); err != nil {
return "", "", err
}
return id, name, err
@ -59,8 +63,10 @@ func (s *Server) CreatePodSandbox(ctx context.Context, req *pb.CreatePodSandboxR
return nil, fmt.Errorf("PodSandboxConfig.Name should not be empty")
}
namespace := req.GetConfig().GetMetadata().GetNamespace()
var err error
id, name, err := s.generatePodIDandName(name)
id, name, err := s.generatePodIDandName(name, namespace)
if err != nil {
return nil, err
}