From 0878d5b22bffed8b728ce94fe3dd8e9befa05b30 Mon Sep 17 00:00:00 2001 From: "Jonathan A. Sternberg" Date: Fri, 29 Sep 2023 15:53:38 -0500 Subject: [PATCH] commands: release the file lock before attempting to boot during create If the boot command hung or took a long time, it blocked any read operations (such as `buildx ls`). When the boot happens, we no longer need to hold the file lock so we can release it. Releasing multiple times is legal and causes whichever release that is second to be a no-op so the defer is kept to ensure the lock is released even when an error condition happens. Signed-off-by: Jonathan A. Sternberg --- commands/create.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/commands/create.go b/commands/create.go index 522a1432..ccf56e10 100644 --- a/commands/create.go +++ b/commands/create.go @@ -72,6 +72,7 @@ func runCreate(dockerCli command.Cli, in createOptions, args []string) error { if err != nil { return err } + // Ensure the file lock gets released no matter what happens. defer release() name := in.name @@ -300,6 +301,10 @@ func runCreate(dockerCli command.Cli, in createOptions, args []string) error { } } + // The store is no longer used from this point. + // Release it so we aren't holding the file lock during the boot. + release() + if in.bootstrap { if _, err = b.Boot(ctx); err != nil { return err