Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix an overflow on retries on container name conflicts #4752

Merged
merged 2 commits into from May 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 5 additions & 3 deletions new.go
Expand Up @@ -239,7 +239,7 @@ func newBuilder(ctx context.Context, store storage.Store, options BuilderOptions
tmpName = findUnusedContainer(tmpName, containers)
}

conflict := 100
suffixDigitsModulo := 100
for {

var flags map[string]interface{}
Expand All @@ -265,8 +265,10 @@ func newBuilder(ctx context.Context, store storage.Store, options BuilderOptions
if !errors.Is(err, storage.ErrDuplicateName) || options.Container != "" {
return nil, fmt.Errorf("creating container: %w", err)
}
tmpName = fmt.Sprintf("%s-%d", name, rand.Int()%conflict)
conflict = conflict * 10
tmpName = fmt.Sprintf("%s-%d", name, rand.Int()%suffixDigitsModulo)
if suffixDigitsModulo < 1_000_000_000 {
suffixDigitsModulo *= 10
}
}
defer func() {
if err != nil {
Expand Down