Skip to content
This repository was archived by the owner on Feb 8, 2021. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions Godeps/Godeps.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
"strings"

"github.com/codegangsta/cli"
"github.com/docker/containerd/api/grpc/types"
"github.com/hyperhq/runv/lib/term"
"github.com/hyperhq/runv/supervisord/api/grpc/types"
"github.com/opencontainers/runtime-spec/specs-go"
netcontext "golang.org/x/net/context"
)
Expand Down
2 changes: 1 addition & 1 deletion integration-test/init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,5 +117,5 @@ func (s *RunVSuite) TearDownTest(c *check.C) {
// after kill/delete functions are stable
exec.Command("pkill", "-9", "runv-namespaced").Run()
exec.Command("pkill", "-9", "qemu").Run()
exec.Command("pkill", "-9", "containerd-nslistener")
exec.Command("pkill", "-9", "supervisord-nslistener")
}
2 changes: 1 addition & 1 deletion kill.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
"syscall"

"github.com/codegangsta/cli"
"github.com/docker/containerd/api/grpc/types"
"github.com/hyperhq/runv/lib/linuxsignal"
"github.com/hyperhq/runv/supervisord/api/grpc/types"
netcontext "golang.org/x/net/context"
)

Expand Down
6 changes: 3 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import (
"time"

"github.com/codegangsta/cli"
"github.com/docker/containerd/api/grpc/types"
"github.com/docker/docker/pkg/reexec"
"github.com/golang/protobuf/ptypes"
"github.com/hyperhq/runv/containerd"
_ "github.com/hyperhq/runv/supervisor/proxy" // for proxy.init()
"github.com/hyperhq/runv/supervisord"
"github.com/hyperhq/runv/supervisord/api/grpc/types"
netcontext "golang.org/x/net/context"
"google.golang.org/grpc"
"google.golang.org/grpc/grpclog"
Expand Down Expand Up @@ -121,7 +121,7 @@ func main() {
listCommand,
stateCommand,
manageCommand,
containerd.ContainerdCommand,
supervisord.SupervisordCommand,
}
if err := app.Run(os.Args); err != nil {
fmt.Printf("%s\n", err.Error())
Expand Down
8 changes: 4 additions & 4 deletions start.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
"syscall"

"github.com/codegangsta/cli"
"github.com/docker/containerd/api/grpc/types"
"github.com/hyperhq/runv/lib/term"
"github.com/hyperhq/runv/supervisord/api/grpc/types"
"github.com/kardianos/osext"
"github.com/opencontainers/runtime-spec/specs-go"
netcontext "golang.org/x/net/context"
Expand Down Expand Up @@ -197,8 +197,8 @@ command(s) that get executed on start, edit the args parameter of the spec. See
}
}
args = append(args,
"containerd", "--solo-namespaced",
"--containerd-dir", namespace,
"supervisord", "--solo-namespaced",
"--supervisord-dir", namespace,
"--state-dir", root,
"--listen", filepath.Join(namespace, "namespaced.sock"),
)
Expand All @@ -210,7 +210,7 @@ command(s) that get executed on start, edit the args parameter of the spec. See
}
err = cmd.Start()
if err != nil {
fmt.Printf("failed to launch runv containerd, error:%v\n", err)
fmt.Printf("failed to launch runv supervisord, error:%v\n", err)
os.Exit(-1)
}
address = filepath.Join(namespace, "namespaced.sock")
Expand Down
2 changes: 1 addition & 1 deletion supervisor/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func (se *SvEvents) setupEventLog(logDir string) error {
glog.Infof("write event log: %v", e)
se.eventLog = append(se.eventLog, e)
if err := enc.Encode(e); err != nil {
glog.Infof("containerd: fail to write event to journal")
glog.Infof("supervisord: fail to write event to journal")
}
}
}()
Expand Down
10 changes: 5 additions & 5 deletions supervisor/hyperpod.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ func (hp *HyperPod) startNsListener() (err error) {
glog.Infof("get exec path %s", path)
parentPipe, childPipe, err = newPipe()
if err != nil {
glog.Errorf("create pipe for containerd-nslistener failed: %v", err)
glog.Errorf("create pipe for supervisord-nslistener failed: %v", err)
return err
}

Expand All @@ -320,10 +320,10 @@ func (hp *HyperPod) startNsListener() (err error) {
}()

cmd := exec.Command(path)
cmd.Args[0] = "containerd-nslistener"
cmd.Args[0] = "supervisord-nslistener"
cmd.ExtraFiles = append(cmd.ExtraFiles, childPipe)
if err = cmd.Start(); err != nil {
glog.Errorf("start containerd-nslistener failed: %v", err)
glog.Errorf("start supervisord-nslistener failed: %v", err)
return err
}

Expand All @@ -347,12 +347,12 @@ func (hp *HyperPod) startNsListener() (err error) {
/* Make sure nsListener create new netns */
var ready string
if err = dec.Decode(&ready); err != nil {
glog.Errorf("Get ready message from containerd-nslistener failed: %v", err)
glog.Errorf("Get ready message from supervisord-nslistener failed: %v", err)
return err
}

if ready != "init" {
err = fmt.Errorf("containerd get incorrect init message: %s", ready)
err = fmt.Errorf("supervisord get incorrect init message: %s", ready)
return err
}

Expand Down
24 changes: 12 additions & 12 deletions supervisor/proxy/nslistener.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
)

func init() {
reexec.Register("containerd-nslistener", setupNsListener)
reexec.Register("supervisord-nslistener", setupNsListener)
}

func setupNsListener() {
Expand All @@ -31,7 +31,7 @@ func setupNsListener() {
enc := gob.NewEncoder(childPipe)
dec := gob.NewDecoder(childPipe)

/* notify containerd to execute prestart hooks */
/* notify supervisord to execute prestart hooks */
if err := enc.Encode("init"); err != nil {
glog.Error(err)
return
Expand All @@ -49,15 +49,15 @@ func setupNsListener() {
return
}

// Get network namespace info for the first time and send to the containerd
// Get network namespace info for the first time and send to the supervisord
/* get route info before link down */
routes, err := netlink.RouteList(nil, netlink.FAMILY_V4)
if err != nil {
glog.Error(err)
return
}

/* send interface info to containerd */
/* send interface info to supervisord */
infos := collectionInterfaceInfo()
if err := enc.Encode(infos); err != nil {
glog.Error(err)
Expand All @@ -70,14 +70,14 @@ func setupNsListener() {
}

// This is a call back function.
// Use to send netlink update informations to containerd.
netNs2Containerd := func(netlinkUpdate supervisor.NetlinkUpdate) {
// Use to send netlink update informations to supervisord.
netNs2Supervisord := func(netlinkUpdate supervisor.NetlinkUpdate) {
if err := enc.Encode(netlinkUpdate); err != nil {
glog.Info("err Encode(netlinkUpdate) is :", err)
}
}
// Keep collecting network namespace info and sending to the containerd
setupNetworkNsTrap(netNs2Containerd)
// Keep collecting network namespace info and sending to the supervisord
setupNetworkNsTrap(netNs2Supervisord)
}

func collectionInterfaceInfo() []supervisor.InterfaceInfo {
Expand Down Expand Up @@ -119,7 +119,7 @@ func collectionInterfaceInfo() []supervisor.InterfaceInfo {

// This function should be put into the main process or somewhere that can be
// use to init the network namespace trap.
func setupNetworkNsTrap(netNs2Containerd func(supervisor.NetlinkUpdate)) {
func setupNetworkNsTrap(netNs2Supervisord func(supervisor.NetlinkUpdate)) {

// Subscribe for links change event
chLink := make(chan netlink.LinkUpdate)
Expand Down Expand Up @@ -148,11 +148,11 @@ func setupNetworkNsTrap(netNs2Containerd func(supervisor.NetlinkUpdate)) {
for {
select {
case updateLink := <-chLink:
handleLink(updateLink, netNs2Containerd)
handleLink(updateLink, netNs2Supervisord)
case updateAddr := <-chAddr:
handleAddr(updateAddr, netNs2Containerd)
handleAddr(updateAddr, netNs2Supervisord)
case updateRoute := <-chRoute:
handleRoute(updateRoute, netNs2Containerd)
handleRoute(updateRoute, netNs2Supervisord)
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions containerd/README.md → supervisord/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# containerd
# supervisord

runv-containerd is a daemon to control hypercontainer and supports the same gRPC api of the [docker-containerd](https://github.com/docker/containerd/).
runv-supervisord is a daemon to control hypercontainer and supports the same gRPC api of the [docker-containerd](https://github.com/docker/containerd/).

## Getting started

Expand All @@ -14,9 +14,9 @@ runv-containerd is a daemon to control hypercontainer and supports the same gRPC

```bash
# in terminal #1
runv --debug --driver libvirt --kernel /opt/hyperstart/build/kernel --initrd /opt/hyperstart/build/hyper-initrd.img containerd
runv --debug --driver libvirt --kernel /opt/hyperstart/build/kernel --initrd /opt/hyperstart/build/hyper-initrd.img supervisord
# in terminal #2
docker daemon -D -l debug --containerd=/run/runv-containerd/containerd.sock
docker daemon -D -l debug --containerd=/run/runv-supervisord/supervisord.sock
# in terminal #3 for trying it
docker run -ti busybox
# ls # (already in the terminal of the busybox container)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import (
"time"

"github.com/cloudfoundry/gosigar"
"github.com/docker/containerd/api/grpc/types"
"github.com/golang/glog"
"github.com/golang/protobuf/ptypes"
"github.com/hyperhq/runv/supervisor"
"github.com/hyperhq/runv/supervisord/api/grpc/types"
"github.com/opencontainers/runtime-spec/specs-go"
"golang.org/x/net/context"
)
Expand All @@ -33,7 +33,7 @@ func (s *apiServer) GetServerVersion(ctx context.Context, c *types.GetServerVers
Major: 0,
Minor: 6,
Patch: 2,
Revision: "runv-containerd",
Revision: "runv-supervisord",
}, nil
}

Expand Down
40 changes: 20 additions & 20 deletions containerd/containerd.go → supervisord/supervisord.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package containerd
package supervisord

import (
"encoding/json"
Expand All @@ -11,29 +11,29 @@ import (
"time"

"github.com/codegangsta/cli"
"github.com/docker/containerd/api/grpc/types"
"github.com/docker/containerd/osutils"
"github.com/golang/glog"
"github.com/hyperhq/runv/containerd/api/grpc/server"
"github.com/hyperhq/runv/driverloader"
"github.com/hyperhq/runv/factory"
singlefactory "github.com/hyperhq/runv/factory/single"
templatefactory "github.com/hyperhq/runv/factory/template"
"github.com/hyperhq/runv/hypervisor"
"github.com/hyperhq/runv/supervisor"
"github.com/hyperhq/runv/supervisord/api/grpc/server"
"github.com/hyperhq/runv/supervisord/api/grpc/types"
"github.com/hyperhq/runv/supervisord/osutils"
templatecore "github.com/hyperhq/runv/template"
"google.golang.org/grpc"
)

const (
usage = `High performance hypervisor based container daemon`
defaultStateDir = "/run/runv-containerd"
defaultStateDir = "/run/runv-supervisord"
defaultListenType = "unix"
defaultGRPCEndpoint = "/run/runv-containerd/containerd.sock"
defaultGRPCEndpoint = "/run/runv-supervisord/supervisord.sock"
)

var ContainerdCommand = cli.Command{
Name: "containerd",
var SupervisordCommand = cli.Command{
Name: "supervisord",
Usage: usage,
Flags: []cli.Flag{
cli.StringFlag{
Expand All @@ -42,9 +42,9 @@ var ContainerdCommand = cli.Command{
Usage: "runtime state directory",
},
cli.StringFlag{
Name: "containerd-dir",
Name: "supervisord-dir",
Value: defaultStateDir,
Usage: "containerd daemon state directory",
Usage: "supervisord daemon state directory",
},
cli.StringFlag{
Name: "listen,l",
Expand All @@ -62,9 +62,9 @@ var ContainerdCommand = cli.Command{
initrd := context.GlobalString("initrd")
template := context.GlobalString("template")
stateDir := context.String("state-dir")
containerdDir := context.String("containerd-dir")
if containerdDir == "" {
containerdDir = stateDir
supervisordDir := context.String("supervisord-dir")
if supervisordDir == "" {
supervisordDir = stateDir
}

if context.GlobalBool("debug") {
Expand Down Expand Up @@ -114,15 +114,15 @@ var ContainerdCommand = cli.Command{
} else {
f = factory.NewFromConfigs(kernel, initrd, nil)
}
sv, err := supervisor.New(stateDir, containerdDir, f,
sv, err := supervisor.New(stateDir, supervisordDir, f,
context.GlobalInt("default_cpus"), context.GlobalInt("default_memory"))
if err != nil {
glog.Infof("%v", err)
os.Exit(1)
}

if context.Bool("solo-namespaced") {
go namespaceShare(sv, containerdDir, stateDir)
go namespaceShare(sv, supervisordDir, stateDir)
}

if err = daemon(sv, context.String("listen")); err != nil {
Expand All @@ -131,7 +131,7 @@ var ContainerdCommand = cli.Command{
}

if context.Bool("solo-namespaced") {
os.RemoveAll(containerdDir)
os.RemoveAll(supervisordDir)
}
},
}
Expand All @@ -150,10 +150,10 @@ func daemon(sv *supervisor.Supervisor, address string) error {
switch ss {
case syscall.SIGCHLD:
if _, err := osutils.Reap(); err != nil {
glog.Infof("containerd: reap child processes")
glog.Infof("supervisord: reap child processes")
}
default:
glog.Infof("stopping containerd after receiving %s", ss)
glog.Infof("stopping supervisord after receiving %s", ss)
time.Sleep(3 * time.Second) // TODO: fix it by proper way
server.Stop()
return nil
Expand Down Expand Up @@ -189,9 +189,9 @@ func startServer(address string, sv *supervisor.Supervisor) (*grpc.Server, error
s := grpc.NewServer()
types.RegisterAPIServer(s, server.NewServer(sv))
go func() {
glog.Infof("containerd: grpc api on %s", address)
glog.Infof("supervisord: grpc api on %s", address)
if err := s.Serve(l); err != nil {
glog.Infof("containerd: serve grpc error")
glog.Infof("supervisord: serve grpc error")
}
}()
return s, nil
Expand Down
2 changes: 1 addition & 1 deletion tty.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"os/signal"
"syscall"

"github.com/docker/containerd/api/grpc/types"
"github.com/hyperhq/runv/lib/term"
"github.com/hyperhq/runv/supervisord/api/grpc/types"
netcontext "golang.org/x/net/context"
)

Expand Down