From 4c210a27e9a6b680a894dc45b5a2d0bccba4bc05 Mon Sep 17 00:00:00 2001 From: Kohei Tokunaga Date: Mon, 21 Aug 2023 14:15:17 +0900 Subject: [PATCH] local controller: make sure removing session when disconnect Signed-off-by: Kohei Tokunaga --- controller/local/controller.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/controller/local/controller.go b/controller/local/controller.go index fb1cd282..ca84c477 100644 --- a/controller/local/controller.go +++ b/controller/local/controller.go @@ -21,7 +21,6 @@ import ( func NewLocalBuildxController(ctx context.Context, dockerCli command.Cli, logger progress.SubLogger) control.BuildxController { return &localController{ dockerCli: dockerCli, - ref: "local", processes: processes.NewManager(), } } @@ -48,6 +47,7 @@ func (b *localController) Build(ctx context.Context, options controllerapi.Build } defer b.buildOnGoing.Store(false) + b.ref = "local" resp, res, buildErr := cbuild.RunBuild(ctx, b.dockerCli, options, in, progress, true) // NOTE: RunBuild can return *build.ResultHandle even on error. if res != nil { @@ -121,6 +121,7 @@ func (b *localController) Kill(context.Context) error { } func (b *localController) Close() error { + b.ref = "" b.cancelRunningProcesses() if b.buildConfig.resultCtx != nil { b.buildConfig.resultCtx.Done() @@ -130,6 +131,9 @@ func (b *localController) Close() error { } func (b *localController) List(ctx context.Context) (res []string, _ error) { + if b.ref == "" { + return nil, nil + } return []string{b.ref}, nil }