Set OnClose shim function
When restoring a task make sure that dead shims are handled. Fixes #2078 Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
@@ -80,7 +80,7 @@ func WithStart(binary, address, daemonAddress, cgroup string, debug bool, exitHa
|
||||
if err = sys.SetOOMScore(cmd.Process.Pid, sys.OOMScoreMaxKillable); err != nil {
|
||||
return nil, nil, errors.Wrap(err, "failed to set OOM Score on shim")
|
||||
}
|
||||
c, clo, err := WithConnect(address)(ctx, config)
|
||||
c, clo, err := WithConnect(address, func() {})(ctx, config)
|
||||
if err != nil {
|
||||
return nil, nil, errors.Wrap(err, "failed to connect")
|
||||
}
|
||||
@@ -149,13 +149,15 @@ func annonDialer(address string, timeout time.Duration) (net.Conn, error) {
|
||||
}
|
||||
|
||||
// WithConnect connects to an existing shim
|
||||
func WithConnect(address string) Opt {
|
||||
func WithConnect(address string, onClose func()) Opt {
|
||||
return func(ctx context.Context, config shim.Config) (shimapi.ShimService, io.Closer, error) {
|
||||
conn, err := connect(address, annonDialer)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
return shimapi.NewShimClient(ttrpc.NewClient(conn)), conn, nil
|
||||
client := ttrpc.NewClient(conn)
|
||||
client.OnClose(onClose)
|
||||
return shimapi.NewShimClient(client), conn, nil
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user