From f15a1170d368f9fce9639dff2c2edba714daba9c Mon Sep 17 00:00:00 2001 From: Michael Crosby Date: Thu, 26 Jul 2018 11:21:50 -0400 Subject: [PATCH 1/2] Add windows publisher Signed-off-by: Michael Crosby --- runtime/v2/shim/shim_windows.go | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/runtime/v2/shim/shim_windows.go b/runtime/v2/shim/shim_windows.go index ff49cb303..7827b25ad 100644 --- a/runtime/v2/shim/shim_windows.go +++ b/runtime/v2/shim/shim_windows.go @@ -19,13 +19,17 @@ package shim import ( + "bytes" "context" "net" "os" + "os/exec" winio "github.com/Microsoft/go-winio" "github.com/containerd/containerd/events" + "github.com/containerd/containerd/namespaces" "github.com/containerd/ttrpc" + "github.com/containerd/typeurl" "github.com/pkg/errors" "github.com/sirupsen/logrus" ) @@ -68,7 +72,6 @@ func handleSignals(logger *logrus.Entry, signals chan os.Signal) error { } func (l *remoteEventsPublisher) Publish(ctx context.Context, topic string, event events.Event) error { - /* TOOD: JTERRY75: Implement publish for windows ns, _ := namespaces.Namespace(ctx) encoded, err := typeurl.MarshalAny(event) if err != nil { @@ -80,17 +83,5 @@ func (l *remoteEventsPublisher) Publish(ctx context.Context, topic string, event } cmd := exec.CommandContext(ctx, l.containerdBinaryPath, "--address", l.address, "publish", "--topic", topic, "--namespace", ns) cmd.Stdin = bytes.NewReader(data) - c, err := Default.Start(cmd) - if err != nil { - return err - } - status, err := Default.Wait(cmd, c) - if err != nil { - return err - } - if status != 0 { - return errors.New("failed to publish event") - } - */ - return nil + return cmd.Run() } From 9d72b4543b57e85b5a7f60d69df7e00433e8feae Mon Sep 17 00:00:00 2001 From: Michael Crosby Date: Thu, 26 Jul 2018 11:24:20 -0400 Subject: [PATCH 2/2] Handle windows signals Since windows does not require a signal handler, we just block on the channel forever so that it does not exit. Signed-off-by: Michael Crosby --- runtime/v2/shim/shim_windows.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/runtime/v2/shim/shim_windows.go b/runtime/v2/shim/shim_windows.go index 7827b25ad..0f1616a35 100644 --- a/runtime/v2/shim/shim_windows.go +++ b/runtime/v2/shim/shim_windows.go @@ -37,7 +37,6 @@ import ( // setupSignals creates a new signal handler for all signals func setupSignals() (chan os.Signal, error) { signals := make(chan os.Signal, 32) - // TODO: JTERRY75: Make this based on events. return signals, nil } @@ -67,7 +66,7 @@ func serveListener(path string) (net.Listener, string, error) { } func handleSignals(logger *logrus.Entry, signals chan os.Signal) error { - // TODO: JTERRY75: Make this based on events? + <-signals return nil }