id and name indexes for pods

Signed-off-by: Antonio Murdaca <runcom@redhat.com>
This commit is contained in:
Antonio Murdaca 2016-09-20 10:27:11 +02:00
parent 361fc8fde7
commit 32029aaba6
No known key found for this signature in database
GPG key ID: B2BEAD150DE936B9
4 changed files with 95 additions and 61 deletions

View file

@ -1,6 +1,7 @@
package server
import (
"errors"
"fmt"
"os"
"path/filepath"
@ -17,10 +18,10 @@ import (
func (s *Server) CreateContainer(ctx context.Context, req *pb.CreateContainerRequest) (*pb.CreateContainerResponse, error) {
// The id of the PodSandbox
podSandboxID := req.GetPodSandboxId()
if !s.hasSandbox(podSandboxID) {
sb := s.getSandbox(podSandboxID)
if sb == nil {
return nil, fmt.Errorf("the pod sandbox (%s) does not exist", podSandboxID)
}
// The config of the container
containerConfig := req.GetConfig()
if containerConfig == nil {
@ -43,7 +44,7 @@ func (s *Server) CreateContainer(ctx context.Context, req *pb.CreateContainerReq
return nil, err
}
container, err := s.createSandboxContainer(name, podSandboxID, req.GetSandboxConfig(), containerDir, containerConfig)
container, err := s.createSandboxContainer(name, sb, req.GetSandboxConfig(), containerDir, containerConfig)
if err != nil {
return nil, err
}
@ -63,7 +64,10 @@ func (s *Server) CreateContainer(ctx context.Context, req *pb.CreateContainerReq
}, nil
}
func (s *Server) createSandboxContainer(name, podSandboxID string, SandboxConfig *pb.PodSandboxConfig, containerDir string, containerConfig *pb.ContainerConfig) (*oci.Container, error) {
func (s *Server) createSandboxContainer(name string, sb *sandbox, SandboxConfig *pb.PodSandboxConfig, containerDir string, containerConfig *pb.ContainerConfig) (*oci.Container, error) {
if sb == nil {
return nil, errors.New("createSandboxContainer needs a sandbox")
}
// creates a spec Generator with the default spec.
specgen := generate.New()
@ -129,8 +133,6 @@ func (s *Server) createSandboxContainer(name, podSandboxID string, SandboxConfig
}
}
specgen.AddAnnotation("pod_sandbox_id", podSandboxID)
if containerConfig.GetPrivileged() {
specgen.SetupPrivileged(true)
}
@ -235,9 +237,8 @@ func (s *Server) createSandboxContainer(name, podSandboxID string, SandboxConfig
}
}
}
// Join the namespace paths for the pod sandbox container.
podContainerName := podSandboxID + "-infra"
podContainerName := sb.name + "-infra"
podInfraContainer := s.state.containers.Get(podContainerName)
podInfraState := s.runtime.ContainerStatus(podInfraContainer)
@ -274,7 +275,7 @@ func (s *Server) createSandboxContainer(name, podSandboxID string, SandboxConfig
return nil, err
}
container, err := oci.NewContainer(name, containerDir, logPath, labels, podSandboxID, containerConfig.GetTty())
container, err := oci.NewContainer(name, containerDir, logPath, labels, sb.id, containerConfig.GetTty())
if err != nil {
return nil, err
}