From f51c98b057fbf88dc785c485caf093eb221c7e9c Mon Sep 17 00:00:00 2001 From: Dan Walsh Date: Wed, 28 Sep 2016 15:49:46 -0400 Subject: [PATCH] Install conmon in /usr/libexec/ocid/conmon Signed-off-by: Dan Walsh --- Makefile | 5 +++-- cmd/server/main.go | 10 ++++++++-- docs/ocid.8.md | 4 ++++ oci/oci.go | 6 ++++-- server/server.go | 4 ++-- test/helpers.bash | 2 +- 6 files changed, 22 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index d10fa494..9abff264 100644 --- a/Makefile +++ b/Makefile @@ -81,12 +81,13 @@ docs: $(MANPAGES_MD:%.md=%) install: binaries docs install -D -m 755 ocid ${INSTALLDIR}/ocid install -D -m 755 ocic ${INSTALLDIR}/ocic - install -D -m 755 conmon/conmon ${INSTALLDIR}/conmon + install -D -m 755 conmon/conmon $(PREFIX)/libexec/ocid/conmon install -d $(PREFIX)/share/man/man8 install -m 644 $(basename $(MANPAGES_MD)) $(PREFIX)/share/man/man8 uninstall: - rm -f ${INSTALLDIR}/{ocid,ocic,conmon} + rm -f ${INSTALLDIR}/{ocid,ocic} + rm -f $(PREFIX)/libexec/ocid/conmon for i in $(basename $(MANPAGES_MD)); do \ rm -f $(PREFIX)/share/man/man8/$$(basename $${i}); \ done diff --git a/cmd/server/main.go b/cmd/server/main.go index 1c4f23e9..4bc44a18 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -14,7 +14,8 @@ import ( ) const ( - ocidRoot = "/var/lib/ocid" + ocidRoot = "/var/lib/ocid" + conmonPath = "/usr/libexec/ocid/conmon" ) func main() { @@ -24,6 +25,11 @@ func main() { app.Version = "0.0.1" app.Flags = []cli.Flag{ + cli.StringFlag{ + Name: "conmon", + Value: conmonPath, + Usage: "path to the conmon executable", + }, cli.StringFlag{ Name: "root", Value: ocidRoot, @@ -104,7 +110,7 @@ func main() { containerDir := c.String("containerdir") sandboxDir := c.String("sandboxdir") - service, err := server.New(c.String("runtime"), c.String("root"), sandboxDir, containerDir) + service, err := server.New(c.String("runtime"), c.String("root"), sandboxDir, containerDir, conmonPath) if err != nil { logrus.Fatal(err) } diff --git a/docs/ocid.8.md b/docs/ocid.8.md index d111c783..77478635 100644 --- a/docs/ocid.8.md +++ b/docs/ocid.8.md @@ -7,6 +7,7 @@ ocid - Enable OCI Kubernetes Container Runtime daemon # SYNOPSIS **ocid** [**--root**=[*value*]] +[**--conmon**=[*value*]] [**--sandboxdir**=[*value*]] [**--containerdir**=[*value*]] [**--socket**=[*value*]] @@ -39,6 +40,9 @@ ocid is meant to provide an integration path between OCI conformant runtimes and **--sandboxdir**="" OCID pod sandbox dir (default: "/var/lib/ocid/sandboxes") +**--conmon**="" + path to the conmon executable (default: "/usr/libexec/ocid/conmon") + **--containerdir**="" OCID container dir (default: "/var/lib/ocid/containers") diff --git a/oci/oci.go b/oci/oci.go index 802148b6..66c9dc86 100644 --- a/oci/oci.go +++ b/oci/oci.go @@ -21,11 +21,12 @@ import ( ) // New creates a new Runtime with options provided -func New(runtimePath string, containerDir string) (*Runtime, error) { +func New(runtimePath string, containerDir string, conmonPath string) (*Runtime, error) { r := &Runtime{ name: filepath.Base(runtimePath), path: runtimePath, containerDir: containerDir, + conmonPath: conmonPath, } return r, nil } @@ -35,6 +36,7 @@ type Runtime struct { name string path string containerDir string + conmonPath string } // syncInfo is used to return data from monitor process to daemon @@ -91,7 +93,7 @@ func (r *Runtime) CreateContainer(c *Container) error { args = append(args, "-t") } - cmd := exec.Command("conmon", args...) + cmd := exec.Command(r.conmonPath, args...) cmd.Dir = c.bundlePath cmd.SysProcAttr = &syscall.SysProcAttr{ Setpgid: true, diff --git a/server/server.go b/server/server.go index 68bc895b..9ed0814c 100644 --- a/server/server.go +++ b/server/server.go @@ -107,7 +107,7 @@ func (s *Server) releasePodName(name string) { } // New creates a new Server with options provided -func New(runtimePath, root, sandboxDir, containerDir string) (*Server, error) { +func New(runtimePath, root, sandboxDir, containerDir string, conmonPath 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 { @@ -124,7 +124,7 @@ func New(runtimePath, root, sandboxDir, containerDir string) (*Server, error) { return nil, err } - r, err := oci.New(runtimePath, containerDir) + r, err := oci.New(runtimePath, containerDir, conmonPath) if err != nil { return nil, err } diff --git a/test/helpers.bash b/test/helpers.bash index 370b9425..01e4df8a 100644 --- a/test/helpers.bash +++ b/test/helpers.bash @@ -70,7 +70,7 @@ function wait_until_reachable() { # Start ocid. function start_ocid() { - "$OCID_BINARY" --debug --socket "$TESTDIR/ocid.sock" --runtime "$RUNC_BINARY" --root "$TESTDIR/ocid" --sandboxdir "$TESTDIR/sandboxes" --containerdir "$TESTDIR/ocid/containers" & OCID_PID=$! + "$OCID_BINARY" --conmon "$CONMON_BINARY" --debug --socket "$TESTDIR/ocid.sock" --runtime "$RUNC_BINARY" --root "$TESTDIR/ocid" --sandboxdir "$TESTDIR/sandboxes" --containerdir "$TESTDIR/ocid/containers" & OCID_PID=$! wait_until_reachable }