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 <jonathan.sternberg@docker.com>
This commit is contained in:
Jonathan A. Sternberg 2023-09-29 15:53:38 -05:00
parent da6662975f
commit 0878d5b22b
No known key found for this signature in database
GPG Key ID: 6603D4B96394F6B1
1 changed files with 5 additions and 0 deletions

View File

@ -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