diff --git a/cmd/server/main.go b/cmd/server/main.go index d7391c5a..be9a9ea2 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -4,6 +4,7 @@ import ( "fmt" "net" "os" + "path/filepath" "github.com/Sirupsen/logrus" "github.com/kubernetes-incubator/ocid/server" @@ -12,6 +13,10 @@ import ( "k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime" ) +const ( + ocidRoot = "/var/lib/ocid" +) + func main() { app := cli.NewApp() app.Name = "ocid" @@ -19,14 +24,19 @@ func main() { app.Version = "0.0.1" app.Flags = []cli.Flag{ + cli.StringFlag{ + Name: "root", + Value: ocidRoot, + Usage: "ocid root dir", + }, cli.StringFlag{ Name: "sandboxdir", - Value: "/var/lib/ocid/sandboxes", + Value: filepath.Join(ocidRoot, "sandboxes"), Usage: "ocid pod sandbox dir", }, cli.StringFlag{ Name: "containerdir", - Value: "/var/lib/ocid/containers", + Value: filepath.Join(ocidRoot, "containers"), Usage: "ocid container dir", }, cli.StringFlag{ @@ -94,7 +104,7 @@ func main() { containerDir := c.String("containerdir") sandboxDir := c.String("sandboxdir") - service, err := server.New(c.String("runtime"), sandboxDir, containerDir) + service, err := server.New(c.String("runtime"), c.String("root"), sandboxDir, containerDir) if err != nil { logrus.Fatal(err) } diff --git a/server/sandbox.go b/server/sandbox.go index e762b5d5..54d23f6a 100644 --- a/server/sandbox.go +++ b/server/sandbox.go @@ -89,6 +89,7 @@ func (s *Server) CreatePodSandbox(ctx context.Context, req *pb.CreatePodSandboxR // creates a spec Generator with the default spec. g := generate.New() + podInfraRootfs := filepath.Join(s.root, "graph/vfs/pause") // setup defaults for the pod sandbox g.SetRootPath(filepath.Join(podInfraRootfs, "rootfs")) g.SetRootReadonly(true) diff --git a/server/server.go b/server/server.go index bc3f41c6..5991646a 100644 --- a/server/server.go +++ b/server/server.go @@ -24,6 +24,7 @@ const ( // Server implements the RuntimeService and ImageService type Server struct { + root string runtime *oci.Runtime sandboxDir string stateLock sync.Mutex @@ -102,7 +103,7 @@ func (s *Server) reservePodName(id, name string) (string, error) { } // New creates a new Server with options provided -func New(runtimePath, sandboxDir, containerDir string) (*Server, error) { +func New(runtimePath, root, sandboxDir, containerDir string) (*Server, error) { // TODO: This will go away later when we have wrapper process or systemd acting as // subreaper. if err := utils.SetSubreaper(1); err != nil { @@ -130,6 +131,7 @@ func New(runtimePath, sandboxDir, containerDir string) (*Server, error) { return nil, err } s := &Server{ + root: root, runtime: r, netPlugin: netPlugin, sandboxDir: sandboxDir,