github-vet / github-vet/rangeloop-pointer-findings

mongodb/mongo-tools: release/release.go; 43 LoC

Open
#18,112 0 comments 0 reactions 0 assignees View on GitHub
fresh small
Dominant language
No language data
Stars
0
Forks
0
PR merge metrics
PR metrics pending

Description

Found a possible issue in [mongodb/mongo-tools](https://www.github.com/mongodb/mongo-tools) at [release/release.go](https://github.com/mongodb/mongo-tools/blob/dca14b998f38e66da8d7df725bb0272cfb4cd3f7/release/release.go#L1162-L1204)

Below is the message reported by the analyzer for this snippet of code. Beware that the analyzer only reports the first issue it finds, so please do not limit your consideration to the contents of the below message.

> range-loop variable mongoEdition used in defer or goroutine at line 1166

[Click here to see the code in its original context.](https://github.com/mongodb/mongo-tools/blob/dca14b998f38e66da8d7df725bb0272cfb4cd3f7/release/release.go#L1162-L1204)

Click here to show the 43 line(s) of Go which triggered the analyzer.

```go
for _, mongoEdition := range editionsToRelease {
wg.Add(1)
go func() {
var err error
prefix := fmt.Sprintf("%s-%s-%s", pf.Variant(), mongoEdition, mongoVersionName)
// retry twice on failure.
maxRetries := 2
for retries := maxRetries; retries >= 0; retries-- {
curatorArgs := []string{
"--level", "debug",
"repo", "submit",
"--service", "https://barque.corp.mongodb.com",
"--config", "etc/repo-config.yml",
"--distro", pf.Name,
"--arch", pf.Arch,
"--edition", mongoEdition,
"--version", mongoVersionNumber,
"--packages", packagesURL,
"--username", os.Getenv("BARQUE_USERNAME"),
"--api_key", os.Getenv("BARQUE_API_KEY"),
}

if retries == maxRetries {
log.Printf("starting curator for %s\n", prefix)
} else {
log.Printf("restarting curator for %s after failure\n", prefix)
}
err = runAndStreamStderr(prefix, "./curator", curatorArgs...)
if err == nil {
log.Printf("finished curator for %s\n", prefix)
wg.Done()
return
}
}
check(err, "run curator for %s", prefix)
}()

// We need to sleep briefly between curator
// invocations because of an auth race condition in
// barque.
// Sleep a bit more to try to keep the flakiness from showing up.
time.Sleep(5 * time.Second)
}

```

Leave a reaction on this issue to contribute to the project by classifying this instance as a **Bug** :-1:, **Mitigated** :+1:, or **Desirable Behavior** :rocket:
See the descriptions of the classifications [here](https://github.com/github-vet/rangeclosure-findings#how-can-i-help) for more information.

commit ID: dca14b998f38e66da8d7df725bb0272cfb4cd3f7

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.