From 8830866eedc377f45f8655baea2601e0ad92ff76 Mon Sep 17 00:00:00 2001 From: Michael Crosby Date: Wed, 21 Jun 2017 11:43:41 -0700 Subject: [PATCH] Remove events from Runtime Signed-off-by: Michael Crosby --- containers/containers.go | 26 +++++++++++++++++++++----- linux/runtime.go | 4 ---- plugin/runtime.go | 2 -- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/containers/containers.go b/containers/containers.go index 6aec0ff1d..d93cfcbd8 100644 --- a/containers/containers.go +++ b/containers/containers.go @@ -28,21 +28,37 @@ type RuntimeInfo struct { Options map[string]string } -func (r RuntimeInfo) MarshalBinary() ([]byte, error) { +type marshaledRuntimeInfo struct { + Name string + Options map[string]string +} + +func (r *RuntimeInfo) MarshalBinary() ([]byte, error) { buf := bytes.NewBuffer(nil) - if err := gob.NewEncoder(buf).Encode(r); err != nil { + if err := gob.NewEncoder(buf).Encode(marshaledRuntimeInfo{ + Name: r.Name, + Options: r.Options, + }); err != nil { return nil, err } return buf.Bytes(), nil } -func (r RuntimeInfo) UnmarshalBinary(data []byte) error { +func (r *RuntimeInfo) UnmarshalBinary(data []byte) error { buf := data if len(buf) == 0 { return errors.New("RuntimeInfo: no data") } - reader := bytes.NewReader(buf) - return gob.NewDecoder(reader).Decode(&r) + var ( + mr marshaledRuntimeInfo + reader = bytes.NewReader(buf) + ) + if err := gob.NewDecoder(reader).Decode(&mr); err != nil { + return err + } + r.Name = mr.Name + r.Options = mr.Options + return nil } type Store interface { diff --git a/linux/runtime.go b/linux/runtime.go index 0ea75a482..ded3dd7d6 100644 --- a/linux/runtime.go +++ b/linux/runtime.go @@ -370,10 +370,6 @@ func (r *Runtime) loadTasks(ctx context.Context, ns string) ([]*Task, error) { return o, nil } -func (r *Runtime) Events(ctx context.Context) <-chan *plugin.Event { - return r.events -} - func (r *Runtime) handleEvents(ctx context.Context, s shim.ShimClient) error { events, err := s.Events(r.eventsContext, &shim.EventsRequest{}) if err != nil { diff --git a/plugin/runtime.go b/plugin/runtime.go index 3cd04a4f0..8927c4dd0 100644 --- a/plugin/runtime.go +++ b/plugin/runtime.go @@ -43,6 +43,4 @@ type Runtime interface { Tasks(context.Context) ([]Task, error) // Delete removes the task in the runtime. Delete(context.Context, Task) (*Exit, error) - // Events returns events for the runtime and all tasks created by the runtime - Events(context.Context) <-chan *Event }