Merge pull request #460 from vbatts/readable_server_fields
server: readable fields
This commit is contained in:
commit
339e01ba79
11 changed files with 72 additions and 72 deletions
|
@ -39,7 +39,7 @@ var (
|
||||||
)
|
)
|
||||||
|
|
||||||
type runtimeService struct {
|
type runtimeService struct {
|
||||||
imageServer ImageServer
|
storageImageServer ImageServer
|
||||||
pauseImage string
|
pauseImage string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,22 +159,22 @@ func (r *runtimeService) createContainerOrPodSandbox(systemContext *types.System
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if we have the specified image.
|
// Check if we have the specified image.
|
||||||
ref, err := istorage.Transport.ParseStoreReference(r.imageServer.GetStore(), imageName)
|
ref, err := istorage.Transport.ParseStoreReference(r.storageImageServer.GetStore(), imageName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// Maybe it's some other transport's copy of the image?
|
// Maybe it's some other transport's copy of the image?
|
||||||
otherRef, err2 := alltransports.ParseImageName(imageName)
|
otherRef, err2 := alltransports.ParseImageName(imageName)
|
||||||
if err2 == nil && otherRef.DockerReference() != nil {
|
if err2 == nil && otherRef.DockerReference() != nil {
|
||||||
ref, err = istorage.Transport.ParseStoreReference(r.imageServer.GetStore(), otherRef.DockerReference().Name())
|
ref, err = istorage.Transport.ParseStoreReference(r.storageImageServer.GetStore(), otherRef.DockerReference().Name())
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// Maybe the image ID is sufficient?
|
// Maybe the image ID is sufficient?
|
||||||
ref, err = istorage.Transport.ParseStoreReference(r.imageServer.GetStore(), "@"+imageID)
|
ref, err = istorage.Transport.ParseStoreReference(r.storageImageServer.GetStore(), "@"+imageID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ContainerInfo{}, err
|
return ContainerInfo{}, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
img, err := istorage.Transport.GetStoreImage(r.imageServer.GetStore(), ref)
|
img, err := istorage.Transport.GetStoreImage(r.storageImageServer.GetStore(), ref)
|
||||||
if img == nil && err == storage.ErrImageUnknown && imageName == r.pauseImage {
|
if img == nil && err == storage.ErrImageUnknown && imageName == r.pauseImage {
|
||||||
image := imageID
|
image := imageID
|
||||||
if imageName != "" {
|
if imageName != "" {
|
||||||
|
@ -184,11 +184,11 @@ func (r *runtimeService) createContainerOrPodSandbox(systemContext *types.System
|
||||||
return ContainerInfo{}, ErrInvalidImageName
|
return ContainerInfo{}, ErrInvalidImageName
|
||||||
}
|
}
|
||||||
logrus.Debugf("couldn't find image %q, retrieving it", image)
|
logrus.Debugf("couldn't find image %q, retrieving it", image)
|
||||||
ref, err = r.imageServer.PullImage(systemContext, image, options)
|
ref, err = r.storageImageServer.PullImage(systemContext, image, options)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ContainerInfo{}, err
|
return ContainerInfo{}, err
|
||||||
}
|
}
|
||||||
img, err = istorage.Transport.GetStoreImage(r.imageServer.GetStore(), ref)
|
img, err = istorage.Transport.GetStoreImage(r.storageImageServer.GetStore(), ref)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ContainerInfo{}, err
|
return ContainerInfo{}, err
|
||||||
}
|
}
|
||||||
|
@ -247,7 +247,7 @@ func (r *runtimeService) createContainerOrPodSandbox(systemContext *types.System
|
||||||
if metadata.Pod {
|
if metadata.Pod {
|
||||||
names = append(names, metadata.PodName)
|
names = append(names, metadata.PodName)
|
||||||
}
|
}
|
||||||
container, err := r.imageServer.GetStore().CreateContainer(containerID, names, img.ID, "", string(mdata), nil)
|
container, err := r.storageImageServer.GetStore().CreateContainer(containerID, names, img.ID, "", string(mdata), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if metadata.Pod {
|
if metadata.Pod {
|
||||||
logrus.Debugf("failed to create pod sandbox %s(%s): %v", metadata.PodName, metadata.PodID, err)
|
logrus.Debugf("failed to create pod sandbox %s(%s): %v", metadata.PodName, metadata.PodID, err)
|
||||||
|
@ -266,7 +266,7 @@ func (r *runtimeService) createContainerOrPodSandbox(systemContext *types.System
|
||||||
// container before returning.
|
// container before returning.
|
||||||
defer func() {
|
defer func() {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err2 := r.imageServer.GetStore().DeleteContainer(container.ID); err2 != nil {
|
if err2 := r.storageImageServer.GetStore().DeleteContainer(container.ID); err2 != nil {
|
||||||
if metadata.Pod {
|
if metadata.Pod {
|
||||||
logrus.Infof("%v deleting partially-created pod sandbox %q", err2, container.ID)
|
logrus.Infof("%v deleting partially-created pod sandbox %q", err2, container.ID)
|
||||||
} else {
|
} else {
|
||||||
|
@ -281,18 +281,18 @@ func (r *runtimeService) createContainerOrPodSandbox(systemContext *types.System
|
||||||
// Add a name to the container's layer so that it's easier to follow
|
// Add a name to the container's layer so that it's easier to follow
|
||||||
// what's going on if we're just looking at the storage-eye view of things.
|
// what's going on if we're just looking at the storage-eye view of things.
|
||||||
layerName := metadata.ContainerName + "-layer"
|
layerName := metadata.ContainerName + "-layer"
|
||||||
names, err = r.imageServer.GetStore().GetNames(container.LayerID)
|
names, err = r.storageImageServer.GetStore().GetNames(container.LayerID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ContainerInfo{}, err
|
return ContainerInfo{}, err
|
||||||
}
|
}
|
||||||
names = append(names, layerName)
|
names = append(names, layerName)
|
||||||
err = r.imageServer.GetStore().SetNames(container.LayerID, names)
|
err = r.storageImageServer.GetStore().SetNames(container.LayerID, names)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ContainerInfo{}, err
|
return ContainerInfo{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find out where the container work directories are, so that we can return them.
|
// Find out where the container work directories are, so that we can return them.
|
||||||
containerDir, err := r.imageServer.GetStore().GetContainerDirectory(container.ID)
|
containerDir, err := r.storageImageServer.GetStore().GetContainerDirectory(container.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ContainerInfo{}, err
|
return ContainerInfo{}, err
|
||||||
}
|
}
|
||||||
|
@ -302,7 +302,7 @@ func (r *runtimeService) createContainerOrPodSandbox(systemContext *types.System
|
||||||
logrus.Debugf("container %q has work directory %q", container.ID, containerDir)
|
logrus.Debugf("container %q has work directory %q", container.ID, containerDir)
|
||||||
}
|
}
|
||||||
|
|
||||||
containerRunDir, err := r.imageServer.GetStore().GetContainerRunDirectory(container.ID)
|
containerRunDir, err := r.storageImageServer.GetStore().GetContainerRunDirectory(container.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ContainerInfo{}, err
|
return ContainerInfo{}, err
|
||||||
}
|
}
|
||||||
|
@ -329,14 +329,14 @@ func (r *runtimeService) CreateContainer(systemContext *types.SystemContext, pod
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *runtimeService) RemovePodSandbox(idOrName string) error {
|
func (r *runtimeService) RemovePodSandbox(idOrName string) error {
|
||||||
container, err := r.imageServer.GetStore().GetContainer(idOrName)
|
container, err := r.storageImageServer.GetStore().GetContainer(idOrName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == storage.ErrContainerUnknown {
|
if err == storage.ErrContainerUnknown {
|
||||||
return ErrInvalidSandboxID
|
return ErrInvalidSandboxID
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
err = r.imageServer.GetStore().DeleteContainer(container.ID)
|
err = r.storageImageServer.GetStore().DeleteContainer(container.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Debugf("failed to delete pod sandbox %q: %v", container.ID, err)
|
logrus.Debugf("failed to delete pod sandbox %q: %v", container.ID, err)
|
||||||
return err
|
return err
|
||||||
|
@ -345,14 +345,14 @@ func (r *runtimeService) RemovePodSandbox(idOrName string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *runtimeService) DeleteContainer(idOrName string) error {
|
func (r *runtimeService) DeleteContainer(idOrName string) error {
|
||||||
container, err := r.imageServer.GetStore().GetContainer(idOrName)
|
container, err := r.storageImageServer.GetStore().GetContainer(idOrName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == storage.ErrContainerUnknown {
|
if err == storage.ErrContainerUnknown {
|
||||||
return ErrInvalidContainerID
|
return ErrInvalidContainerID
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
err = r.imageServer.GetStore().DeleteContainer(container.ID)
|
err = r.storageImageServer.GetStore().DeleteContainer(container.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Debugf("failed to delete container %q: %v", container.ID, err)
|
logrus.Debugf("failed to delete container %q: %v", container.ID, err)
|
||||||
return err
|
return err
|
||||||
|
@ -366,12 +366,12 @@ func (r *runtimeService) SetContainerMetadata(idOrName string, metadata RuntimeC
|
||||||
logrus.Debugf("failed to encode metadata for %q: %v", idOrName, err)
|
logrus.Debugf("failed to encode metadata for %q: %v", idOrName, err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return r.imageServer.GetStore().SetMetadata(idOrName, string(mdata))
|
return r.storageImageServer.GetStore().SetMetadata(idOrName, string(mdata))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *runtimeService) GetContainerMetadata(idOrName string) (RuntimeContainerMetadata, error) {
|
func (r *runtimeService) GetContainerMetadata(idOrName string) (RuntimeContainerMetadata, error) {
|
||||||
metadata := RuntimeContainerMetadata{}
|
metadata := RuntimeContainerMetadata{}
|
||||||
mdata, err := r.imageServer.GetStore().GetMetadata(idOrName)
|
mdata, err := r.storageImageServer.GetStore().GetMetadata(idOrName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return metadata, err
|
return metadata, err
|
||||||
}
|
}
|
||||||
|
@ -382,7 +382,7 @@ func (r *runtimeService) GetContainerMetadata(idOrName string) (RuntimeContainer
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *runtimeService) StartContainer(idOrName string) (string, error) {
|
func (r *runtimeService) StartContainer(idOrName string) (string, error) {
|
||||||
container, err := r.imageServer.GetStore().GetContainer(idOrName)
|
container, err := r.storageImageServer.GetStore().GetContainer(idOrName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == storage.ErrContainerUnknown {
|
if err == storage.ErrContainerUnknown {
|
||||||
return "", ErrInvalidContainerID
|
return "", ErrInvalidContainerID
|
||||||
|
@ -393,7 +393,7 @@ func (r *runtimeService) StartContainer(idOrName string) (string, error) {
|
||||||
if err = json.Unmarshal([]byte(container.Metadata), &metadata); err != nil {
|
if err = json.Unmarshal([]byte(container.Metadata), &metadata); err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
mountPoint, err := r.imageServer.GetStore().Mount(container.ID, metadata.MountLabel)
|
mountPoint, err := r.storageImageServer.GetStore().Mount(container.ID, metadata.MountLabel)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Debugf("failed to mount container %q: %v", container.ID, err)
|
logrus.Debugf("failed to mount container %q: %v", container.ID, err)
|
||||||
return "", err
|
return "", err
|
||||||
|
@ -403,14 +403,14 @@ func (r *runtimeService) StartContainer(idOrName string) (string, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *runtimeService) StopContainer(idOrName string) error {
|
func (r *runtimeService) StopContainer(idOrName string) error {
|
||||||
container, err := r.imageServer.GetStore().GetContainer(idOrName)
|
container, err := r.storageImageServer.GetStore().GetContainer(idOrName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == storage.ErrContainerUnknown {
|
if err == storage.ErrContainerUnknown {
|
||||||
return ErrInvalidContainerID
|
return ErrInvalidContainerID
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
err = r.imageServer.GetStore().Unmount(container.ID)
|
err = r.storageImageServer.GetStore().Unmount(container.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Debugf("failed to unmount container %q: %v", container.ID, err)
|
logrus.Debugf("failed to unmount container %q: %v", container.ID, err)
|
||||||
return err
|
return err
|
||||||
|
@ -420,33 +420,33 @@ func (r *runtimeService) StopContainer(idOrName string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *runtimeService) GetWorkDir(id string) (string, error) {
|
func (r *runtimeService) GetWorkDir(id string) (string, error) {
|
||||||
container, err := r.imageServer.GetStore().GetContainer(id)
|
container, err := r.storageImageServer.GetStore().GetContainer(id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == storage.ErrContainerUnknown {
|
if err == storage.ErrContainerUnknown {
|
||||||
return "", ErrInvalidContainerID
|
return "", ErrInvalidContainerID
|
||||||
}
|
}
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
return r.imageServer.GetStore().GetContainerDirectory(container.ID)
|
return r.storageImageServer.GetStore().GetContainerDirectory(container.ID)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *runtimeService) GetRunDir(id string) (string, error) {
|
func (r *runtimeService) GetRunDir(id string) (string, error) {
|
||||||
container, err := r.imageServer.GetStore().GetContainer(id)
|
container, err := r.storageImageServer.GetStore().GetContainer(id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == storage.ErrContainerUnknown {
|
if err == storage.ErrContainerUnknown {
|
||||||
return "", ErrInvalidContainerID
|
return "", ErrInvalidContainerID
|
||||||
}
|
}
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
return r.imageServer.GetStore().GetContainerRunDirectory(container.ID)
|
return r.storageImageServer.GetStore().GetContainerRunDirectory(container.ID)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetRuntimeService returns a RuntimeServer that uses the passed-in image
|
// GetRuntimeService returns a RuntimeServer that uses the passed-in image
|
||||||
// service to pull and manage images, and its store to manage containers based
|
// service to pull and manage images, and its store to manage containers based
|
||||||
// on those images.
|
// on those images.
|
||||||
func GetRuntimeService(imageServer ImageServer, pauseImage string) RuntimeServer {
|
func GetRuntimeService(storageImageServer ImageServer, pauseImage string) RuntimeServer {
|
||||||
return &runtimeService{
|
return &runtimeService{
|
||||||
imageServer: imageServer,
|
storageImageServer: storageImageServer,
|
||||||
pauseImage: pauseImage,
|
pauseImage: pauseImage,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -250,7 +250,7 @@ func (s *Server) CreateContainer(ctx context.Context, req *pb.CreateContainerReq
|
||||||
}
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err2 := s.storage.DeleteContainer(containerID)
|
err2 := s.storageRuntimeServer.DeleteContainer(containerID)
|
||||||
if err2 != nil {
|
if err2 != nil {
|
||||||
logrus.Warnf("Failed to cleanup container directory: %v", err2)
|
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
|
metaname := metadata.Name
|
||||||
attempt := metadata.Attempt
|
attempt := metadata.Attempt
|
||||||
containerInfo, err := s.storage.CreateContainer(s.imageContext,
|
containerInfo, err := s.storageRuntimeServer.CreateContainer(s.imageContext,
|
||||||
sb.name, sb.id,
|
sb.name, sb.id,
|
||||||
image, image,
|
image, image,
|
||||||
containerName, containerID,
|
containerName, containerID,
|
||||||
|
@ -503,7 +503,7 @@ func (s *Server) createSandboxContainer(ctx context.Context, containerID string,
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
mountPoint, err := s.storage.StartContainer(containerID)
|
mountPoint, err := s.storageRuntimeServer.StartContainer(containerID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to mount container %s(%s): %v", containerName, containerID, err)
|
return nil, fmt.Errorf("failed to mount container %s(%s): %v", containerName, containerID, err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,11 +36,11 @@ func (s *Server) RemoveContainer(ctx context.Context, req *pb.RemoveContainerReq
|
||||||
|
|
||||||
s.removeContainer(c)
|
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)
|
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)
|
return nil, fmt.Errorf("failed to delete storage for container %s: %v", c.ID(), err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ func (s *Server) ContainerStatus(ctx context.Context, req *pb.ContainerStatusReq
|
||||||
}
|
}
|
||||||
resp.Status.Mounts = mounts
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ func (s *Server) ListImages(ctx context.Context, req *pb.ListImagesRequest) (*pb
|
||||||
filter = filterImage.Image
|
filter = filterImage.Image
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
results, err := s.images.ListImages(filter)
|
results, err := s.storageImageServer.ListImages(filter)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ func (s *Server) RemoveImage(ctx context.Context, req *pb.RemoveImageRequest) (*
|
||||||
if image == "" {
|
if image == "" {
|
||||||
return nil, fmt.Errorf("no image specified")
|
return nil, fmt.Errorf("no image specified")
|
||||||
}
|
}
|
||||||
err := s.images.RemoveImage(s.imageContext, image)
|
err := s.storageImageServer.RemoveImage(s.imageContext, image)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ func (s *Server) ImageStatus(ctx context.Context, req *pb.ImageStatusRequest) (*
|
||||||
if image == "" {
|
if image == "" {
|
||||||
return nil, fmt.Errorf("no image specified")
|
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 != nil {
|
||||||
if err == storage.ErrImageUnknown {
|
if err == storage.ErrImageUnknown {
|
||||||
return &pb.ImageStatusResponse{}, nil
|
return &pb.ImageStatusResponse{}, nil
|
||||||
|
|
|
@ -52,10 +52,10 @@ func (s *Server) RemovePodSandbox(ctx context.Context, req *pb.RemovePodSandboxR
|
||||||
continue
|
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)
|
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)
|
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
|
sb.infraContainer = nil
|
||||||
|
|
||||||
// Remove the files related to the sandbox
|
// 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)
|
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)
|
return nil, fmt.Errorf("failed to remove pod sandbox %s: %v", sb.id, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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,
|
name, id,
|
||||||
s.config.PauseImage, "",
|
s.config.PauseImage, "",
|
||||||
containerName,
|
containerName,
|
||||||
|
@ -111,7 +111,7 @@ func (s *Server) RunPodSandbox(ctx context.Context, req *pb.RunPodSandboxRequest
|
||||||
}
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
if err != nil {
|
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)
|
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{}
|
saveOptions := generate.ExportOptions{}
|
||||||
mountPoint, err := s.storage.StartContainer(id)
|
mountPoint, err := s.storageRuntimeServer.StartContainer(id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to mount container %s in pod sandbox %s(%s): %v", containerName, sb.name, id, err)
|
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 {
|
func (s *Server) setPodSandboxMountLabel(id, mountLabel string) error {
|
||||||
storageMetadata, err := s.storage.GetContainerMetadata(id)
|
storageMetadata, err := s.storageRuntimeServer.GetContainerMetadata(id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
storageMetadata.SetMountLabel(mountLabel)
|
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) {
|
func getSELinuxLabels(selinuxOptions *pb.SELinuxOption) (processLabel string, mountLabel string, err error) {
|
||||||
|
|
|
@ -32,8 +32,8 @@ type Server struct {
|
||||||
config Config
|
config Config
|
||||||
runtime *oci.Runtime
|
runtime *oci.Runtime
|
||||||
store sstorage.Store
|
store sstorage.Store
|
||||||
images storage.ImageServer
|
storageImageServer storage.ImageServer
|
||||||
storage storage.RuntimeServer
|
storageRuntimeServer storage.RuntimeServer
|
||||||
stateLock sync.Mutex
|
stateLock sync.Mutex
|
||||||
updateLock sync.RWMutex
|
updateLock sync.RWMutex
|
||||||
state *serverState
|
state *serverState
|
||||||
|
@ -255,7 +255,7 @@ func (s *Server) restore() {
|
||||||
pods := map[string]*storage.RuntimeContainerMetadata{}
|
pods := map[string]*storage.RuntimeContainerMetadata{}
|
||||||
podContainers := map[string]*storage.RuntimeContainerMetadata{}
|
podContainers := map[string]*storage.RuntimeContainerMetadata{}
|
||||||
for _, container := range containers {
|
for _, container := range containers {
|
||||||
metadata, err2 := s.storage.GetContainerMetadata(container.ID)
|
metadata, err2 := s.storageRuntimeServer.GetContainerMetadata(container.ID)
|
||||||
if err2 != nil {
|
if err2 != nil {
|
||||||
logrus.Warnf("error parsing metadata for %s: %v, ignoring", container.ID, err2)
|
logrus.Warnf("error parsing metadata for %s: %v, ignoring", container.ID, err2)
|
||||||
continue
|
continue
|
||||||
|
@ -316,7 +316,7 @@ func (s *Server) update() error {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
// not previously known, so figure out what it is
|
// 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 {
|
if err2 != nil {
|
||||||
logrus.Errorf("error parsing metadata for %s: %v, ignoring", container.ID, err2)
|
logrus.Errorf("error parsing metadata for %s: %v, ignoring", container.ID, err2)
|
||||||
continue
|
continue
|
||||||
|
@ -472,8 +472,8 @@ func New(config *Config) (*Server, error) {
|
||||||
s := &Server{
|
s := &Server{
|
||||||
runtime: r,
|
runtime: r,
|
||||||
store: store,
|
store: store,
|
||||||
images: imageService,
|
storageImageServer: imageService,
|
||||||
storage: storageRuntimeService,
|
storageRuntimeServer: storageRuntimeService,
|
||||||
netPlugin: netPlugin,
|
netPlugin: netPlugin,
|
||||||
config: *config,
|
config: *config,
|
||||||
state: &serverState{
|
state: &serverState{
|
||||||
|
|
Loading…
Reference in a new issue