remove unnecessary gateway container interface

Signed-off-by: Cory Bennett <cbennett@netflix.com>
v0.8
Cory Bennett 2020-09-11 16:48:24 +00:00
parent b97b1a58f7
commit 7b4414f72d
2 changed files with 5 additions and 23 deletions

View File

@ -18,13 +18,6 @@ import (
"golang.org/x/sync/errgroup"
)
type Container interface {
client.Container
// OnRelease allows callbacks to free up resources when the container exits.
// The functions are called in LIFO order.
OnRelease(func() error)
}
type NewContainerRequest struct {
ContainerID string
NetMode opspb.NetMode
@ -43,7 +36,7 @@ type Mount struct {
RefProxy solver.ResultProxy
}
func NewContainer(ctx context.Context, e executor.Executor, req NewContainerRequest) (Container, error) {
func NewContainer(ctx context.Context, e executor.Executor, req NewContainerRequest) (client.Container, error) {
ctx, cancel := context.WithCancel(ctx)
eg, ctx := errgroup.WithContext(ctx)
ctr := &gatewayContainer{
@ -77,9 +70,10 @@ func NewContainer(ctx context.Context, e executor.Executor, req NewContainerRequ
if err != nil {
return nil, stack.Enable(err)
}
ctr.OnRelease(func() error {
ctr.cleanup = append(ctr.cleanup, func() error {
return stack.Enable(ref.Release(context.TODO()))
})
execMount.Src = ref
}
@ -186,12 +180,6 @@ func (gwCtr *gatewayContainer) Release(ctx context.Context) error {
return stack.Enable(err2)
}
// OnRelease will call the provided function when the Container has been
// released. The functions are called in LIFO order.
func (gwCtr *gatewayContainer) OnRelease(f func() error) {
gwCtr.cleanup = append(gwCtr.cleanup, f)
}
type gatewayContainerProcess struct {
errGroup *errgroup.Group
groupCtx context.Context

View File

@ -322,7 +322,7 @@ func newBridgeForwarder(ctx context.Context, llbBridge frontend.FrontendLLBBridg
workers: workers,
inputs: inputs,
sid: sid,
ctrs: map[string]Container{},
ctrs: map[string]gwclient.Container{},
}
return lbf
}
@ -423,7 +423,7 @@ type llbBridgeForwarder struct {
isErrServerClosed bool
sid string
*pipe
ctrs map[string]Container
ctrs map[string]gwclient.Container
ctrsMu sync.Mutex
}
@ -1031,12 +1031,6 @@ func (lbf *llbBridgeForwarder) ExecProcess(srv pb.LLBBridge_ExecProcessServer) e
}
pio.resize = proc.Resize
// ensure process has been canceled if the container is released
ctr.OnRelease(func() error {
initCancel()
return nil
})
eg.Go(func() error {
<-pio.done
logrus.Debugf("|---> Done Message %s", pid)