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

mzzgaopeng/kubernetes: pkg/controller/util/node/controller_utils.go; 20 LoC

Open
#11,655 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 [mzzgaopeng/kubernetes](https://www.github.com/mzzgaopeng/kubernetes) at [pkg/controller/util/node/controller_utils.go](https://github.com/mzzgaopeng/kubernetes/blob/ded624b8c7918766a08023e72fa7af79e16be080/pkg/controller/util/node/controller_utils.go#L132-L151)

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 cond at line 135 may start a goroutine

[Click here to see the code in its original context.](https://github.com/mzzgaopeng/kubernetes/blob/ded624b8c7918766a08023e72fa7af79e16be080/pkg/controller/util/node/controller_utils.go#L132-L151)

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

```go
for _, cond := range pod.Status.Conditions {
if cond.Type == v1.PodReady {
cond.Status = v1.ConditionFalse
if !utilpod.UpdatePodCondition(&pod.Status, &cond) {
break
}
klog.V(2).Infof("Updating ready status of pod %v to false", pod.Name)
_, err := kubeClient.CoreV1().Pods(pod.Namespace).UpdateStatus(pod)
if err != nil {
if apierrors.IsNotFound(err) {
// NotFound error means that pod was already deleted.
// There is nothing left to do with this pod.
continue
}
klog.Warningf("Failed to update status for pod %q: %v", format.Pod(pod), err)
errMsg = append(errMsg, fmt.Sprintf("%v", err))
}
break
}
}

```

Click here to show extra information the analyzer produced.

```
The following graphviz dot graph describes paths through the callgraph that could lead to a function calling a goroutine:
digraph G {
"(dial, 1)" -> {"(dialWithoutProxy, 2)";}
"(NewClientConn, 3)" -> {"(clientHandshake, 2)";}
"(newWatchBroadcast, 3)" -> {}
"(ConfigureTransport, 1)" -> {"(configureTransport, 1)";}
"(configureTransport, 1)" -> {"(addConnIfNeeded, 3)";}
"(newWatchableStore, 5)" -> {}
"(ReturnIterator, 1)" -> {"(Put, 1)";}
"(dialWithoutProxy, 2)" -> {"(Dial, 3)";}
"(dial, 2)" -> {"(DialURL, 3)";}
"(Add, 2)" -> {"(New, 1)";"(Search, 2)";}
"(Run, 2)" -> {"(Run, 1)";"(CreateControllerContext, 4)";"(Start, 1)";"(Register, 2)";"(run, 1)";"(Register, 3)";"(List, 1)";}
"(Register, 2)" -> {"(addEndpoint, 1)";}
"(handleHttps, 2)" -> {}
"(newParentProcess, 1)" -> {"(includeExecFifo, 1)";}
"(includeExecFifo, 1)" -> {"(Open, 3)";}
"(Delete, 2)" -> {"(Accept, 2)";}
"(NewClient, 2)" -> {"(EndpointURL, 4)";}
"(AddPod, 1)" -> {"(UpdatePod, 1)";}
"(Equal, 1)" -> {"(Get, 1)";"(Compare, 1)";}
"(Run, 3)" -> {"(List, 1)";"(Run, 1)";}
"(add, 1)" -> {"(post, 1)";"(newWatchBroadcast, 3)";"(newWatchBroadcasts, 1)";"(Update, 1)";}
"(tryUpgrade, 2)" -> {"(DialForUpgrade, 1)";}
"(DeleteCollection, 4)" -> {}
"(Update, 2)" -> {"(updatePod, 2)";}
"(Open, 3)" -> {"(openAtIndex, 4)";}
"(DialForUpgrade, 1)" -> {"(dial, 2)";}
"(Copy, 2)" -> {"(ServeHTTP, 2)";}
"(newAsyncIDTokenVerifier, 3)" -> {}
"(Get, 0)" -> {"(Get, 2)";}
"(send, 3)" -> {}
"(processPkg, 2)" -> {}
"(Verifier, 1)" -> {"(newAsyncIDTokenVerifier, 3)";}
"(Update, 3)" -> {"(Accept, 2)";}
"(SetTransportDefaults, 1)" -> {"(ConfigureTransport, 1)";}
"(Run, 1)" -> {"(Register, 2)";"(copyToPod, 3)";"(NewSSHTunnelList, 4)";"(start, 1)";"(processPkg, 2)";"(Update, 2)";}
"(newWatchBroadcasts, 1)" -> {}
"(Write, 1)" -> {"(append, 1)";"(Copy, 2)";"(Update, 3)";}
"(ServeHTTP, 2)" -> {"(handleHttps, 2)";"(proxy, 2)";"(serveResource, 6)";"(RoundTrip, 1)";"(tryUpgrade, 2)";}
"(startZfsWatcher, 1)" -> {}
"(RoundTripOpt, 2)" -> {"(roundTrip, 1)";}
"(post, 1)" -> {"(RoundTrip, 1)";}
"(Accept, 2)" -> {}
"(RoundTrip, 1)" -> {"(RoundTripOpt, 2)";"(Dial, 1)";"(roundTrip, 1)";}
"(addPod, 1)" -> {"(AddPod, 1)";}
"(append, 1)" -> {}
"(Read, 2)" -> {"(Update, 3)";}
"(EndpointURL, 4)" -> {"(List, 2)";}
"(addConnIfNeeded, 3)" -> {}
"(waitUntilFreshAndBlock, 2)" -> {}
"(Update, 1)" -> {"(Update, 2)";}
"(clientHandshake, 2)" -> {"(newClientTransport, 6)";}
"(newClientTransport, 6)" -> {}
"(Get, 1)" -> {"(New, 1)";"(Remove, 1)";"(Add, 2)";"(expand, 2)";"(Get, 0)";"(Search, 2)";"(get, 1)";"(Read, 1)";"(Add, 1)";"(Put, 1)";"(ReturnIterator, 1)";}
"(List, 2)" -> {}
"(addEndpoint, 1)" -> {}
"(Handle, 2)" -> {"(Delete, 2)";"(Get, 2)";}
"(DialURL, 3)" -> {"(Dial, 3)";}
"(CreateControllerContext, 4)" -> {}
"(Search, 2)" -> {"(List, 1)";}
"(WaitUntilFreshAndList, 2)" -> {"(waitUntilFreshAndBlock, 2)";}
"(openAtIndex, 4)" -> {"(newFilePipeline, 3)";}
"(start, 1)" -> {"(newParentProcess, 1)";}
"(run, 1)" -> {"(start, 1)";}
"(Register, 3)" -> {"(startZfsWatcher, 1)";"(startThinPoolWatcher, 1)";}
"(UpdatePodCondition, 2)" -> {"(Equal, 1)";}
"(Read, 1)" -> {"(Copy, 2)";"(New, 1)";"(Write, 1)";"(add, 1)";"(Read, 2)";}
"(newClient, 1)" -> {"(NewMaintenance, 1)";}
"(expand, 2)" -> {"(Write, 1)";}
"(Compare, 1)" -> {"(merge, 4)";"(Insert, 1)";}
"(Insert, 1)" -> {"(Add, 1)";"(Search, 2)";}
"(newFilePipeline, 3)" -> {}
"(NewMaintenance, 1)" -> {"(Dial, 1)";}
"(Start, 1)" -> {"(Run, 1)";"(start, 1)";"(CreateListener, 1)";"(SendRequest, 3)";}
"(Add, 1)" -> {"(Search, 2)";"(add, 1)";"(New, 1)";"(Delete, 1)";"(add, 2)";}
"(Remove, 1)" -> {"(New, 1)";"(Delete, 1)";"(Search, 2)";}
"(NewSSHTunnelList, 4)" -> {}
"(Dial, 1)" -> {"(dial, 1)";"(dial, 2)";}
"(Dial, 3)" -> {"(NewClientConn, 3)";}
"(Delete, 1)" -> {"(Get, 2)";}
"(SendRequest, 3)" -> {"(send, 3)";}
"(New, 5)" -> {"(newWatchableStore, 5)";}
"(UpdatePod, 1)" -> {}
"(ListenPipe, 2)" -> {}
"(updatePod, 2)" -> {"(AddPod, 1)";"(addPod, 1)";}
"(List, 5)" -> {"(WaitUntilFreshAndList, 2)";"(New, 5)";}
"(awaitOpenSlotForRequest, 1)" -> {}
"(New, 2)" -> {"(Start, 1)";}
"(Get, 2)" -> {"(Accept, 2)";}
"(List, 1)" -> {"(List, 2)";"(List, 5)";}
"(startThinPoolWatcher, 1)" -> {}
"(Put, 1)" -> {"(Update, 3)";}
"(add, 2)" -> {"(add, 1)";}
"(serveResource, 6)" -> {"(DeleteCollection, 4)";}
"(roundTrip, 1)" -> {"(awaitOpenSlotForRequest, 1)";}
"(proxy, 2)" -> {}
"(CreateListener, 1)" -> {"(ListenPipe, 2)";}
"(New, 1)" -> {"(Verifier, 1)";"(Handle, 2)";"(Run, 3)";"(Run, 2)";"(Run, 1)";"(newClient, 1)";"(NewClient, 2)";"(New, 2)";"(Start, 1)";}
"(copyToPod, 3)" -> {}
"(merge, 4)" -> {"(Get, 0)";"(Put, 1)";}
"(get, 1)" -> {"(SetTransportDefaults, 1)";}
}

```

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: ded624b8c7918766a08023e72fa7af79e16be080

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.