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

multi-io/kubermatic-old: api/cmd/conformance-tests/runner.go; 19 LoC

Open
#14,857 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 [multi-io/kubermatic-old](https://www.github.com/multi-io/kubermatic-old) at [api/cmd/conformance-tests/runner.go](https://github.com/multi-io/kubermatic-old/blob/5d8b73ba9eee47e07d4cabdbc9c4b9c75117feda/api/cmd/conformance-tests/runner.go#L841-L859)

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.

> reference to nd was used in a composite literal at line 846

[Click here to see the code in its original context.](https://github.com/multi-io/kubermatic-old/blob/5d8b73ba9eee47e07d4cabdbc9c4b9c75117feda/api/cmd/conformance-tests/runner.go#L841-L859)

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

```go
for _, nd := range nodeDeployments {
params := &projectclient.CreateNodeDeploymentParams{
ProjectID: r.kubermatcProjectID,
ClusterID: clusterName,
DC: r.seed.Name,
Body: &nd,
}
params.SetTimeout(15 * time.Second)

if err := retryNAttempts(defaultAPIRetries, func(attempt int) error {
if _, err := r.kubermaticClient.Project.CreateNodeDeployment(params, r.kubermaticAuthenticator); err != nil {
log.Warnf("[Attempt %d/%d] Failed to create NodeDeployment %s: %v. Retrying", attempt, defaultAPIRetries, nd.Name, fmtSwaggerError(err))
return err
}
return nil
}); err != nil {
return fmt.Errorf("failed to create NodeDeployment %s via kubermatic api after %d attempts: %q", nd.Name, defaultAPIRetries, fmtSwaggerError(err))
}
}

```

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: 5d8b73ba9eee47e07d4cabdbc9c4b9c75117feda

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with api/cmd/conformance-tests/runner.go at lines 841-859 and review the Go range-loop handling around the nodeDeployments iteration. Check whether the request body can refer to the wrong deployment, then run the conformance tests to verify that each node deployment is submitted correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
testing
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.