Skip to content

Commit

Permalink
local controller: make sure removing session when disconnect
Browse files Browse the repository at this point in the history
Signed-off-by: Kohei Tokunaga <[email protected]>
  • Loading branch information
ktock committed Aug 21, 2023
1 parent 912af12 commit eb2b88b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion controller/local/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
}
}
Expand All @@ -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 {
Expand Down Expand Up @@ -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()
Expand All @@ -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
}

Expand Down

0 comments on commit eb2b88b

Please sign in to comment.