Fix return event publishing error

Signed-off-by: Shiming Zhang <wzshiming@foxmail.com>
This commit is contained in:
Shiming Zhang 2021-03-31 14:15:08 +08:00
parent d064140369
commit 45df696bf3

View File

@ -297,7 +297,10 @@ func (l *remoteEventsPublisher) Publish(ctx context.Context, topic string, event
cmd := exec.CommandContext(ctx, containerdBinaryFlag, "--address", l.address, "publish", "--topic", topic, "--namespace", ns) cmd := exec.CommandContext(ctx, containerdBinaryFlag, "--address", l.address, "publish", "--topic", topic, "--namespace", ns)
cmd.Stdin = bytes.NewReader(data) cmd.Stdin = bytes.NewReader(data)
b := bufPool.Get().(*bytes.Buffer) b := bufPool.Get().(*bytes.Buffer)
defer bufPool.Put(b) defer func() {
b.Reset()
bufPool.Put(b)
}()
cmd.Stdout = b cmd.Stdout = b
cmd.Stderr = b cmd.Stderr = b
c, err := reaper.Default.Start(cmd) c, err := reaper.Default.Start(cmd)