github-vet / github-vet/rangeloop-pointer-findings
gravitational/force: pkg/kube/run.go; 12 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [gravitational/force](https://www.github.com/gravitational/force) at [pkg/kube/run.go](https://github.com/gravitational/force/blob/8fc2537d2164e4722bd956c8c08cd2e213ce929f/pkg/kube/run.go#L258-L269)
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 containerDiff used in defer or goroutine at line 266
[Click here to see the code in its original context.](https://github.com/gravitational/force/blob/8fc2537d2164e4722bd956c8c08cd2e213ce929f/pkg/kube/run.go#L258-L269)
Click here to show the 12 line(s) of Go which triggered the analyzer.
```go
for _, containerDiff := range diff.containers {
// stream logs for running containers, or if the first run,
// output logs anyways
if containerDiff.new.State.Running != nil || (firstRun && containerDiff.new.State.Terminated != nil) {
watchCtx, watchCancel := context.WithCancel(ctx)
watches = append(watches, watchCtx)
go func() {
defer watchCancel()
r.streamPodContainerLogs(ctx, client, pod, *containerDiff.new, out)
}()
}
}
```
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: 8fc2537d2164e4722bd956c8c08cd2e213ce929f
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reading pkg/kube/run.go at lines 258-269 and reviewing the analyzer report about containerDiff being used in a goroutine. Verify the behavior of the container log watch and confirm that the analyzer finding is resolved without changing which running or first-run containers receive logs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100