github-vet / github-vet/rangeloop-pointer-findings
sudhamisha/vmw-kube: pkg/kubelet/rkt/rkt.go; 38 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [sudhamisha/vmw-kube](https://www.github.com/sudhamisha/vmw-kube) at [pkg/kubelet/rkt/rkt.go](https://github.com/sudhamisha/vmw-kube/blob/09869715fc1f74f7ddcd6a3da45cfbacd4715896/pkg/kubelet/rkt/rkt.go#L994-L1031)
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.
> function call which takes a reference to container at line 999 may start a goroutine
[Click here to see the code in its original context.](https://github.com/sudhamisha/vmw-kube/blob/09869715fc1f74f7ddcd6a3da45cfbacd4715896/pkg/kubelet/rkt/rkt.go#L994-L1031)
Click here to show the 38 line(s) of Go which triggered the analyzer.
```go
for _, container := range pod.Spec.Containers {
expectedHash := kubecontainer.HashContainer(&container)
c := runningPod.FindContainerByName(container.Name)
if c == nil {
if kubecontainer.ShouldContainerBeRestarted(&container, pod, &podStatus, r.readinessManager) {
glog.V(3).Infof("Container %+v is dead, but RestartPolicy says that we should restart it.", container)
// TODO(yifan): Containers in one pod are fate-sharing at this moment, see:
// https://github.com/appc/spec/issues/276.
restartPod = true
break
}
continue
}
// TODO: check for non-root image directives. See ../docker/manager.go#SyncPod
// TODO(yifan): Take care of host network change.
containerChanged := c.Hash != 0 && c.Hash != expectedHash
if containerChanged {
glog.Infof("Pod %q container %q hash changed (%d vs %d), it will be killed and re-created.", podFullName, container.Name, c.Hash, expectedHash)
restartPod = true
break
}
result, err := r.prober.Probe(pod, podStatus, container, string(c.ID), c.Created)
// TODO(vmarmol): examine this logic.
if err == nil && result != probe.Success {
glog.Infof("Pod %q container %q is unhealthy (probe result: %v), it will be killed and re-created.", podFullName, container.Name, result)
restartPod = true
break
}
if err != nil {
glog.V(2).Infof("Probe container %q failed: %v", container.Name, err)
}
delete(unidentifiedContainers, c.ID)
}
```
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: 09869715fc1f74f7ddcd6a3da45cfbacd4715896
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.