Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-12-SP4:Update
containerd.3056
socket-activation-02-daemon.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File socket-activation-02-daemon.patch of Package containerd.3056
From f88d7012333fea526fe09133761023c790187598 Mon Sep 17 00:00:00 2001 From: Aleksa Sarai <asarai@suse.de> Date: Thu, 31 Mar 2016 14:23:54 +1100 Subject: [PATCH 2/3] containerd: use docker/listeners to create the GRPC socket This allows for the use of socket activation with the flag `-l fd://` and similar. The semantics are identical to Docker, but it's important to note that the semantics of the --listen flag have changed to require a proto://addr formatted string. Signed-off-by: Aleksa Sarai <asarai@suse.de> --- containerd/main.go | 26 ++++++++++++++++++-------- containerd/main_linux.go | 3 +-- 2 files changed, 19 insertions(+), 10 deletions(-) Index: containerd-0.2.2/containerd/main.go =================================================================== --- containerd-0.2.2.orig/containerd/main.go +++ containerd-0.2.2/containerd/main.go @@ -2,9 +2,9 @@ package main import ( "fmt" - "net" "os" "os/signal" + "strings" "sync" "syscall" "time" @@ -18,6 +18,7 @@ import ( "github.com/docker/containerd/api/grpc/types" "github.com/docker/containerd/osutils" "github.com/docker/containerd/supervisor" + "github.com/docker/docker/pkg/listeners" ) const ( @@ -43,7 +44,7 @@ var daemonFlags = []cli.Flag{ cli.StringFlag{ Name: "listen,l", Value: defaultGRPCEndpoint, - Usage: "Address on which GRPC API will listen", + Usage: "proto://address on which the GRPC API will listen", }, cli.StringFlag{ Name: "runtime,r", @@ -120,7 +121,13 @@ func daemon(context *cli.Context) error if err := sv.Start(); err != nil { return err } - server, err := startServer(context.String("listen"), sv) + // Split the listen string of the form proto://addr + listenSpec := context.String("listen") + listenParts := strings.SplitN(listenSpec, "://", 2) + if len(listenParts) != 2 { + return fmt.Errorf("bad listen address format %s, expected proto://address", listenSpec) + } + server, err := startServer(listenParts[0], listenParts[1], sv) if err != nil { return err } @@ -139,14 +146,17 @@ func daemon(context *cli.Context) error return nil } -func startServer(address string, sv *supervisor.Supervisor) (*grpc.Server, error) { - if err := os.RemoveAll(address); err != nil { - return nil, err - } - l, err := net.Listen(defaultListenType, address) +func startServer(protocol, address string, sv *supervisor.Supervisor) (*grpc.Server, error) { + // TODO: We should use TLS. + // TODO: Add an option for the SocketGroup. + sockets, err := listeners.Init(protocol, address, "", nil) if err != nil { return nil, err } + if len(sockets) != 1 { + return nil, fmt.Errorf("incorrect number of listeners") + } + l := sockets[0] s := grpc.NewServer() types.RegisterAPIServer(s, server.NewServer(sv)) go func() { Index: containerd-0.2.2/containerd/main_linux.go =================================================================== --- containerd-0.2.2.orig/containerd/main_linux.go +++ containerd-0.2.2/containerd/main_linux.go @@ -20,8 +20,7 @@ import ( const ( defaultStateDir = "/run/containerd" - defaultListenType = "unix" - defaultGRPCEndpoint = "/run/containerd/containerd.sock" + defaultGRPCEndpoint = "unix:///run/containerd/containerd.sock" ) func appendPlatformFlags() {
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor