Skip to content

Commit bfcb090

Browse files
committed
investigate issues #13243
Signed-off-by: Nicolas De Loof <[email protected]>
1 parent ce463d5 commit bfcb090

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

pkg/compose/build_bake.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import (
2525
"errors"
2626
"fmt"
2727
"io"
28-
"math/rand"
2928
"os"
3029
"os/exec"
3130
"path/filepath"
@@ -41,6 +40,7 @@ import (
4140
"github.com/docker/compose/v2/pkg/progress"
4241
"github.com/docker/docker/api/types/versions"
4342
"github.com/docker/docker/builder/remotecontext/urlutil"
43+
"github.com/google/uuid"
4444
"github.com/moby/buildkit/client"
4545
gitutil "github.com/moby/buildkit/frontend/dockerfile/dfgitutil"
4646
"github.com/moby/buildkit/util/progress/progressui"
@@ -293,10 +293,15 @@ func (s *composeService) doBuildBake(ctx context.Context, project *types.Project
293293
for {
294294
// we don't use os.CreateTemp here as we need a temporary file name, but don't want it actually created
295295
// as bake relies on atomicwriter and this creates conflict during rename
296-
metadataFile = filepath.Join(os.TempDir(), fmt.Sprintf("compose-build-metadataFile-%d.json", rand.Int31()))
297-
if _, err = os.Stat(metadataFile); os.IsNotExist(err) {
298-
break
296+
metadataFile = filepath.Join(os.TempDir(), fmt.Sprintf("compose-build-metadataFile-%s.json", uuid.New().String()))
297+
if _, err = os.Stat(metadataFile); err != nil {
298+
if os.IsNotExist(err) {
299+
break
300+
} else {
301+
return nil, fmt.Errorf("failed to check metadata file %s already exists: %w", metadataFile, err)
302+
}
299303
}
304+
logrus.Debugf("metadata file already exists: %s", metadataFile)
300305
}
301306
defer func() {
302307
_ = os.Remove(metadataFile)

0 commit comments

Comments
 (0)