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

GoogleCloudPlatform/k8s-node-termination-handler: termination/eviction.go; 9 LoC

Open
#7,513 0 comments 0 reactions 0 assignees View on GitHub
fresh tiny
Dominant language
No language data
Stars
0
Forks
0
PR merge metrics
PR metrics pending

Description

Found a possible issue in [GoogleCloudPlatform/k8s-node-termination-handler](https://www.github.com/GoogleCloudPlatform/k8s-node-termination-handler) at [termination/eviction.go](https://github.com/GoogleCloudPlatform/k8s-node-termination-handler/blob/4a4ec0b07a64a0365ae51de3b7d3bcdb9115290c/termination/eviction.go#L96-L104)

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 pod at line 97 may start a goroutine

[Click here to see the code in its original context.](https://github.com/GoogleCloudPlatform/k8s-node-termination-handler/blob/4a4ec0b07a64a0365ae51de3b7d3bcdb9115290c/termination/eviction.go#L96-L104)

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

```go
for _, pod := range pods {
p.recorder.Eventf(&pod, v1.EventTypeWarning, eventReason, "Node %q is about to be terminated. Evicting pod prior to node termination.", p.node)
// Delete the pod with the specified timeout.
glog.V(4).Infof("About to delete pod %q in namespace %q within grace period %d seconds", pod.Name, pod.Namespace, *deleteOptions.GracePeriodSeconds)
if err := p.client.Pods(pod.Namespace).Delete(pod.Name, deleteOptions); err != nil {
glog.V(2).Infof("Failed to delete pod %q in namespace %q - %v", pod.Name, pod.Namespace, err)
return err
}
}

```

Click here to show extra information the analyzer produced.

```
The following paths through the callgraph could lead to a goroutine:
(Eventf, 5) -> (Event, 4) -> (generateEvent, 5) -> (Action, 2) -> (New, 1) -> (HTTPWrappersForConfig, 2) -> (NewImpersonatingRoundTripper, 2) -> (newDebuggingRoundTripper, 2) -> (configureTransport, 1) -> (addConnIfNeeded, 3)
(Eventf, 5) -> (Event, 4) -> (generateEvent, 5) -> (Action, 2) -> (New, 1) -> (HTTPWrappersForConfig, 2) -> (NewImpersonatingRoundTripper, 2) -> (newDebuggingRoundTripper, 2) -> (configureTransport, 1) -> (addConnIfNeeded, 3) -> (run, 3) -> (addConnLocked, 2) -> (newClientConn, 2) -> (readLoop, 0) -> (WriteGoAway, 3) -> (writeBytes, 1)
(Eventf, 5) -> (Event, 4) -> (generateEvent, 5) -> (Action, 2) -> (New, 1) -> (HTTPWrappersForConfig, 2) -> (NewImpersonatingRoundTripper, 2) -> (newDebuggingRoundTripper, 2) -> (configureTransport, 1) -> (addConnIfNeeded, 3) -> (run, 3) -> (addConnLocked, 2) -> (newClientConn, 2) -> (readLoop, 0) -> (WriteGoAway, 3) -> (writeBytes, 1) -> (scheduleFrameWrite, 0) -> (Pop, 0)
(Eventf, 5) -> (Event, 4) -> (generateEvent, 5)
(Eventf, 5) -> (Event, 4) -> (Now, 0) -> (Add, 1) -> (ObjectKinds, 1) -> (NewNotRegisteredErrForType, 1)
(Eventf, 5) -> (Event, 4) -> (generateEvent, 5) -> (Action, 2) -> (NewUnboundedExecutor, 0) -> (TODO, 0) -> (cancel, 2)
(Eventf, 5) -> (Event, 4) -> (generateEvent, 5) -> (Action, 2) -> (New, 1) -> (HTTPWrappersForConfig, 2) -> (NewImpersonatingRoundTripper, 2) -> (newDebuggingRoundTripper, 2) -> (configureTransport, 1)
(Eventf, 5) -> (Event, 4) -> (generateEvent, 5) -> (Action, 2) -> (New, 1) -> (HTTPWrappersForConfig, 2) -> (NewImpersonatingRoundTripper, 2) -> (newDebuggingRoundTripper, 2) -> (configureTransport, 1) -> (addConnIfNeeded, 3) -> (run, 3) -> (addConnLocked, 2) -> (newClientConn, 2)
(Eventf, 5) -> (Event, 4) -> (generateEvent, 5) -> (Action, 2) -> (New, 1) -> (HTTPWrappersForConfig, 2) -> (NewImpersonatingRoundTripper, 2) -> (newDebuggingRoundTripper, 2) -> (configureTransport, 1) -> (addConnIfNeeded, 3) -> (run, 3) -> (addConnLocked, 2) -> (newClientConn, 2) -> (readLoop, 0) -> (WriteGoAway, 3) -> (writeBytes, 1) -> (handleResponse, 2)
(Eventf, 5) -> (Event, 4) -> (generateEvent, 5) -> (Action, 2) -> (New, 1) -> (HTTPWrappersForConfig, 2) -> (NewImpersonatingRoundTripper, 2) -> (newDebuggingRoundTripper, 2) -> (configureTransport, 1) -> (addConnIfNeeded, 3) -> (run, 3) -> (addConnLocked, 2) -> (newClientConn, 2) -> (readLoop, 0) -> (WriteGoAway, 3) -> (writeBytes, 1) -> (handleResponse, 2) -> (setResponseUncompressed, 1)
(Eventf, 5) -> (Event, 4) -> (generateEvent, 5) -> (Action, 2) -> (ObjectKinds, 1) -> (TypeOf, 1)
(Eventf, 5) -> (Event, 4) -> (generateEvent, 5) -> (Action, 2) -> (newStaticTable, 0) -> (addEntry, 1)
(Eventf, 5) -> (Event, 4) -> (generateEvent, 5) -> (Action, 2) -> (printf, 3) -> (output, 5) -> (AddInt64, 2)

```

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: 4a4ec0b07a64a0365ae51de3b7d3bcdb9115290c

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.