github-vet / github-vet/rangeloop-pointer-findings
bluek8s/kubedirector: pkg/controller/kubedirectorcluster/cluster.go; 54 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [bluek8s/kubedirector](https://www.github.com/bluek8s/kubedirector) at [pkg/controller/kubedirectorcluster/cluster.go](https://github.com/bluek8s/kubedirector/blob/5fca5b9b3708829a252b036e98ac5297e2f84875/pkg/controller/kubedirectorcluster/cluster.go#L293-L346)
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.
>
[Click here to see the code in its original context.](https://github.com/bluek8s/kubedirector/blob/5fca5b9b3708829a252b036e98ac5297e2f84875/pkg/controller/kubedirectorcluster/cluster.go#L293-L346)
Click here to show the 54 line(s) of Go which triggered the analyzer.
```go
for _, kubecluster := range allClusters.Items {
if amIBeingConnectedToThis(kubecluster) {
shared.LogInfof(
reqLogger,
cr,
shared.EventReasonCluster,
"connected to cluster {%s}; updating it",
kubecluster.Name,
)
shared.LogInfof(
reqLogger,
&kubecluster,
shared.EventReasonCluster,
"connected cluster {%s} has changed",
cr.Name,
)
// Annotate cluster to trigger connected cluster's reconciler
wait := time.Second
maxWait := 4096 * time.Second
for {
updateMetaGenerator := &kubecluster
annotations := updateMetaGenerator.Annotations
if annotations == nil {
annotations = make(map[string]string)
updateMetaGenerator.Annotations = annotations
}
if v, ok := annotations[shared.ConnectionsIncrementor]; ok {
newV, _ := strconv.Atoi(v)
annotations[shared.ConnectionsIncrementor] = strconv.Itoa(newV + 1)
} else {
annotations[shared.ConnectionsIncrementor] = "1"
}
updateMetaGenerator.Annotations = annotations
if shared.Update(context.TODO(), updateMetaGenerator) == nil {
break
}
// Since update failed, get a fresh copy of this cluster to work with and
// try update
updateMetaGenerator, fetchErr := observer.GetCluster(kubecluster.Namespace, kubecluster.Name)
if fetchErr != nil {
if errors.IsNotFound(fetchErr) {
break
}
}
if wait > maxWait {
return fmt.Errorf(
"Unable to notify cluster {%s} of configmeta change",
updateMetaGenerator.Name)
}
time.Sleep(wait)
wait = wait * 2
}
}
}
```
Click here to show extra information the analyzer produced.
```
No path was found through the callgraph that could lead to a function which writes a pointer argument.
No path was found through the callgraph that could lead to a function which passes a pointer to third-party code.
root signature {LogInfof 5} was not found in the callgraph; reference was passed directly to third-party code
```
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: 5fca5b9b3708829a252b036e98ac5297e2f84875
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.