Merge pull request #460 from vbatts/readable_server_fields

server: readable fields
This commit is contained in:
Antonio Murdaca 2017-04-21 00:54:35 +02:00 committed by GitHub
commit 339e01ba79
11 changed files with 72 additions and 72 deletions

View file

@ -250,7 +250,7 @@ func (s *Server) CreateContainer(ctx context.Context, req *pb.CreateContainerReq
}
defer func() {
if err != nil {
err2 := s.storage.DeleteContainer(containerID)
err2 := s.storageRuntimeServer.DeleteContainer(containerID)
if err2 != nil {
logrus.Warnf("Failed to cleanup container directory: %v", err2)
}
@ -491,7 +491,7 @@ func (s *Server) createSandboxContainer(ctx context.Context, containerID string,
metaname := metadata.Name
attempt := metadata.Attempt
containerInfo, err := s.storage.CreateContainer(s.imageContext,
containerInfo, err := s.storageRuntimeServer.CreateContainer(s.imageContext,
sb.name, sb.id,
image, image,
containerName, containerID,
@ -503,7 +503,7 @@ func (s *Server) createSandboxContainer(ctx context.Context, containerID string,
return nil, err
}
mountPoint, err := s.storage.StartContainer(containerID)
mountPoint, err := s.storageRuntimeServer.StartContainer(containerID)
if err != nil {
return nil, fmt.Errorf("failed to mount container %s(%s): %v", containerName, containerID, err)
}

View file

@ -36,11 +36,11 @@ func (s *Server) RemoveContainer(ctx context.Context, req *pb.RemoveContainerReq
s.removeContainer(c)
if err := s.storage.StopContainer(c.ID()); err != nil {
if err := s.storageRuntimeServer.StopContainer(c.ID()); err != nil {
return nil, fmt.Errorf("failed to unmount container %s: %v", c.ID(), err)
}
if err := s.storage.DeleteContainer(c.ID()); err != nil {
if err := s.storageRuntimeServer.DeleteContainer(c.ID()); err != nil {
return nil, fmt.Errorf("failed to delete storage for container %s: %v", c.ID(), err)
}

View file

@ -41,7 +41,7 @@ func (s *Server) ContainerStatus(ctx context.Context, req *pb.ContainerStatusReq
}
resp.Status.Mounts = mounts
status, err := s.images.ImageStatus(s.imageContext, image.Image)
status, err := s.storageImageServer.ImageStatus(s.imageContext, image.Image)
if err != nil {
return nil, err
}

View file

@ -17,7 +17,7 @@ func (s *Server) ListImages(ctx context.Context, req *pb.ListImagesRequest) (*pb
filter = filterImage.Image
}
}
results, err := s.images.ListImages(filter)
results, err := s.storageImageServer.ListImages(filter)
if err != nil {
return nil, err
}

View file

@ -47,7 +47,7 @@ func (s *Server) PullImage(ctx context.Context, req *pb.PullImageRequest) (*pb.P
},
}
}
_, err := s.images.PullImage(s.imageContext, image, options)
_, err := s.storageImageServer.PullImage(s.imageContext, image, options)
if err != nil {
return nil, err
}

View file

@ -19,7 +19,7 @@ func (s *Server) RemoveImage(ctx context.Context, req *pb.RemoveImageRequest) (*
if image == "" {
return nil, fmt.Errorf("no image specified")
}
err := s.images.RemoveImage(s.imageContext, image)
err := s.storageImageServer.RemoveImage(s.imageContext, image)
if err != nil {
return nil, err
}

View file

@ -20,7 +20,7 @@ func (s *Server) ImageStatus(ctx context.Context, req *pb.ImageStatusRequest) (*
if image == "" {
return nil, fmt.Errorf("no image specified")
}
status, err := s.images.ImageStatus(s.imageContext, image)
status, err := s.storageImageServer.ImageStatus(s.imageContext, image)
if err != nil {
if err == storage.ErrImageUnknown {
return &pb.ImageStatusResponse{}, nil

View file

@ -52,10 +52,10 @@ func (s *Server) RemovePodSandbox(ctx context.Context, req *pb.RemovePodSandboxR
continue
}
if err := s.storage.StopContainer(c.ID()); err != nil {
if err := s.storageRuntimeServer.StopContainer(c.ID()); err != nil {
return nil, fmt.Errorf("failed to delete container %s in pod sandbox %s: %v", c.Name(), sb.id, err)
}
if err := s.storage.DeleteContainer(c.ID()); err != nil {
if err := s.storageRuntimeServer.DeleteContainer(c.ID()); err != nil {
return nil, fmt.Errorf("failed to delete container %s in pod sandbox %s: %v", c.Name(), sb.id, err)
}
@ -85,10 +85,10 @@ func (s *Server) RemovePodSandbox(ctx context.Context, req *pb.RemovePodSandboxR
sb.infraContainer = nil
// Remove the files related to the sandbox
if err := s.storage.StopContainer(sb.id); err != nil {
if err := s.storageRuntimeServer.StopContainer(sb.id); err != nil {
return nil, fmt.Errorf("failed to delete sandbox container in pod sandbox %s: %v", sb.id, err)
}
if err := s.storage.RemovePodSandbox(sb.id); err != nil {
if err := s.storageRuntimeServer.RemovePodSandbox(sb.id); err != nil {
return nil, fmt.Errorf("failed to remove pod sandbox %s: %v", sb.id, err)
}

View file

@ -94,7 +94,7 @@ func (s *Server) RunPodSandbox(ctx context.Context, req *pb.RunPodSandboxRequest
}
}()
podContainer, err := s.storage.CreatePodSandbox(s.imageContext,
podContainer, err := s.storageRuntimeServer.CreatePodSandbox(s.imageContext,
name, id,
s.config.PauseImage, "",
containerName,
@ -111,7 +111,7 @@ func (s *Server) RunPodSandbox(ctx context.Context, req *pb.RunPodSandboxRequest
}
defer func() {
if err != nil {
if err2 := s.storage.RemovePodSandbox(id); err2 != nil {
if err2 := s.storageRuntimeServer.RemovePodSandbox(id); err2 != nil {
logrus.Warnf("couldn't cleanup pod sandbox %q: %v", id, err2)
}
}
@ -383,7 +383,7 @@ func (s *Server) RunPodSandbox(ctx context.Context, req *pb.RunPodSandboxRequest
}
saveOptions := generate.ExportOptions{}
mountPoint, err := s.storage.StartContainer(id)
mountPoint, err := s.storageRuntimeServer.StartContainer(id)
if err != nil {
return nil, fmt.Errorf("failed to mount container %s in pod sandbox %s(%s): %v", containerName, sb.name, id, err)
}
@ -421,12 +421,12 @@ func (s *Server) RunPodSandbox(ctx context.Context, req *pb.RunPodSandboxRequest
}
func (s *Server) setPodSandboxMountLabel(id, mountLabel string) error {
storageMetadata, err := s.storage.GetContainerMetadata(id)
storageMetadata, err := s.storageRuntimeServer.GetContainerMetadata(id)
if err != nil {
return err
}
storageMetadata.SetMountLabel(mountLabel)
return s.storage.SetContainerMetadata(id, storageMetadata)
return s.storageRuntimeServer.SetContainerMetadata(id, storageMetadata)
}
func getSELinuxLabels(selinuxOptions *pb.SELinuxOption) (processLabel string, mountLabel string, err error) {

View file

@ -29,20 +29,20 @@ const (
// Server implements the RuntimeService and ImageService
type Server struct {
config Config
runtime *oci.Runtime
store sstorage.Store
images storage.ImageServer
storage storage.RuntimeServer
stateLock sync.Mutex
updateLock sync.RWMutex
state *serverState
netPlugin ocicni.CNIPlugin
podNameIndex *registrar.Registrar
podIDIndex *truncindex.TruncIndex
ctrNameIndex *registrar.Registrar
ctrIDIndex *truncindex.TruncIndex
imageContext *types.SystemContext
config Config
runtime *oci.Runtime
store sstorage.Store
storageImageServer storage.ImageServer
storageRuntimeServer storage.RuntimeServer
stateLock sync.Mutex
updateLock sync.RWMutex
state *serverState
netPlugin ocicni.CNIPlugin
podNameIndex *registrar.Registrar
podIDIndex *truncindex.TruncIndex
ctrNameIndex *registrar.Registrar
ctrIDIndex *truncindex.TruncIndex
imageContext *types.SystemContext
seccompEnabled bool
seccompProfile seccomp.Seccomp
@ -255,7 +255,7 @@ func (s *Server) restore() {
pods := map[string]*storage.RuntimeContainerMetadata{}
podContainers := map[string]*storage.RuntimeContainerMetadata{}
for _, container := range containers {
metadata, err2 := s.storage.GetContainerMetadata(container.ID)
metadata, err2 := s.storageRuntimeServer.GetContainerMetadata(container.ID)
if err2 != nil {
logrus.Warnf("error parsing metadata for %s: %v, ignoring", container.ID, err2)
continue
@ -316,7 +316,7 @@ func (s *Server) update() error {
continue
}
// not previously known, so figure out what it is
metadata, err2 := s.storage.GetContainerMetadata(container.ID)
metadata, err2 := s.storageRuntimeServer.GetContainerMetadata(container.ID)
if err2 != nil {
logrus.Errorf("error parsing metadata for %s: %v, ignoring", container.ID, err2)
continue
@ -470,12 +470,12 @@ func New(config *Config) (*Server, error) {
return nil, err
}
s := &Server{
runtime: r,
store: store,
images: imageService,
storage: storageRuntimeService,
netPlugin: netPlugin,
config: *config,
runtime: r,
store: store,
storageImageServer: imageService,
storageRuntimeServer: storageRuntimeService,
netPlugin: netPlugin,
config: *config,
state: &serverState{
sandboxes: sandboxes,
containers: containers,