github-vet / github-vet/rangeloop-pointer-findings
huanwei/kube-spy: cmd/spy/main.go; 34 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [huanwei/kube-spy](https://www.github.com/huanwei/kube-spy) at [cmd/spy/main.go](https://github.com/huanwei/kube-spy/blob/ab3181670cf30a75db9d051ade38750e1a0695fb/cmd/spy/main.go#L55-L88)
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 chaos at line 75 may start a goroutine
[Click here to see the code in its original context.](https://github.com/huanwei/kube-spy/blob/ab3181670cf30a75db9d051ade38750e1a0695fb/cmd/spy/main.go#L55-L88)
Click here to show the 34 line(s) of Go which triggered the analyzer.
```go
for _, chaos := range spyConfig.VictimServices[i].ChaosList {
glog.Infof("Chaos test: Victim %s, Chaos %v", spyConfig.VictimServices[i].Name, chaos)
// Control replicas
previousReplica := spy.ChangeReplicas(clientset, services[i], int32(chaos.Replica), spyConfig.Namespace)
// Get pods after changing replicas
pods := spy.GetPods(clientset, services[i])
// Detect network environment before adding chaos
cidrs, podNames := spy.GetPodsInfo(pods)
spy.PingPods(services[i].Name, services[i].Namespace, nil, podNames, cidrs)
// Add chaos
err := spy.AddChaos(clientset, spyConfig, services[i], &chaos, pods)
if err != nil {
glog.Errorf("Adding chaos error: %s", err)
}
// Do API tests
spy.Dotests(clientset, spyConfig, &spyConfig.VictimServices[i], &chaos)
// Detect network environment under chaos
spy.PingPods(services[i].Name, services[i].Namespace, &chaos, podNames, cidrs)
// Clear chaos
spy.ClearChaos(clientset, spyConfig)
// Detect network environment after removing chaos
spy.PingPods(services[i].Name, services[i].Namespace, nil, podNames, cidrs)
// Restore replicas
spy.ChangeReplicas(clientset, services[i], int32(previousReplica), spyConfig.Namespace)
}
```
Click here to show extra information the analyzer produced.
```
The following paths through the callgraph could lead to a goroutine:
(Dotests, 4) -> (DoTest, 3) -> (Warningf, 2) -> (printf, 3) -> (output, 5) -> (AddInt64, 2)
(Dotests, 4) -> (DoTest, 3) -> (Infof, 2) -> (printf, 3) -> (output, 5) -> (AddInt64, 2)
(Dotests, 4) -> (AddResponse, 5) -> (Error, 0) -> (NewAggregate, 1) -> (ObjectKinds, 1) -> (NewNotRegisteredErrForType, 1)
(Dotests, 4) -> (AddResponse, 5) -> (Warningf, 2) -> (printf, 3) -> (output, 5) -> (AddInt64, 2)
(Dotests, 4) -> (SendResponses, 0) -> (Write, 1) -> (Encode, 2) -> (output, 5) -> (AddInt64, 2)
(Dotests, 4) -> (SendResponses, 0) -> (Write, 1) -> (Encode, 2) -> (NewEncoder, 1) -> (newEncoderWithWriter, 1)
(Dotests, 4) -> (SendResponses, 0) -> (Write, 1) -> (Encode, 2) -> (ObjectKinds, 1) -> (NewNotRegisteredErrForType, 1)
(Dotests, 4) -> (SendResponses, 0) -> (Errorf, 2) -> (printf, 3) -> (output, 5) -> (AddInt64, 2)
(Dotests, 4) -> (SendResponses, 0) -> (Error, 0) -> (NewAggregate, 1) -> (ObjectKinds, 1) -> (NewNotRegisteredErrForType, 1)
(Dotests, 4) -> (SendResponses, 0) -> (Fatalf, 2) -> (printf, 3) -> (output, 5) -> (AddInt64, 2)
(Dotests, 4) -> (New, 0) -> (New, 1) -> (HTTPWrappersForConfig, 2) -> (SetTransportDefaults, 1) -> (ConfigureTransport, 1) -> (configureTransport, 1)
(Dotests, 4) -> (GetService, 3) -> (Get, 2) -> (SubResource, 1) -> (Decode, 3) -> (ConvertToVersion, 2) -> (convertToVersion, 3)
(Dotests, 4) -> (GetService, 3) -> (Get, 2) -> (SubResource, 1) -> (EncodeParameters, 2) -> (Convert, 1) -> (convertStruct, 3)
(Dotests, 4) -> (GetService, 3) -> (Get, 2) -> (SubResource, 1) -> (Decode, 3) -> (ConvertToVersion, 2) -> (convertToVersion, 3)
(Dotests, 4) -> (GetService, 3) -> (New, 1) -> (HTTPWrappersForConfig, 2) -> (SetTransportDefaults, 1) -> (ConfigureTransport, 1) -> (configureTransport, 1)
(Dotests, 4) -> (DoTest, 3) -> (Flush, 0) -> (writeChunk, 1) -> (Encode, 2) -> (KindForGroupVersionKinds, 1) -> (bestMatch, 2)
(Dotests, 4) -> (DoTest, 3) -> (Flush, 0) -> (writeChunk, 1) -> (Encode, 2) -> (KindForGroupVersionKinds, 1) -> (bestMatch, 2)
(Dotests, 4) -> (New, 0) -> (New, 1) -> (HTTPWrappersForConfig, 2) -> (SetTransportDefaults, 1) -> (ConfigureTransport, 1) -> (configureTransport, 1) -> (addConnIfNeeded, 3)
(Dotests, 4) -> (GetService, 3) -> (New, 1) -> (HTTPWrappersForConfig, 2) -> (SetTransportDefaults, 1) -> (ConfigureTransport, 1) -> (configureTransport, 1) -> (addConnIfNeeded, 3)
(Dotests, 4) -> (New, 0) -> (New, 1) -> (HTTPWrappersForConfig, 2) -> (SetTransportDefaults, 1) -> (ConfigureTransport, 1) -> (configureTransport, 1) -> (addConnIfNeeded, 3) -> (run, 3) -> (addConnLocked, 2) -> (newClientConn, 2)
(Dotests, 4) -> (GetService, 3) -> (New, 1) -> (HTTPWrappersForConfig, 2) -> (SetTransportDefaults, 1) -> (ConfigureTransport, 1) -> (configureTransport, 1) -> (addConnIfNeeded, 3) -> (run, 3) -> (addConnLocked, 2) -> (newClientConn, 2)
(Dotests, 4) -> (New, 0) -> (New, 1) -> (HTTPWrappersForConfig, 2) -> (SetTransportDefaults, 1) -> (ConfigureTransport, 1) -> (configureTransport, 1) -> (addConnIfNeeded, 3) -> (run, 3) -> (addConnLocked, 2) -> (newClientConn, 2) -> (readLoop, 0) -> (WriteGoAway, 3) -> (writeBytes, 1)
(Dotests, 4) -> (GetService, 3) -> (New, 1) -> (HTTPWrappersForConfig, 2) -> (SetTransportDefaults, 1) -> (ConfigureTransport, 1) -> (configureTransport, 1) -> (addConnIfNeeded, 3) -> (run, 3) -> (addConnLocked, 2) -> (newClientConn, 2) -> (readLoop, 0) -> (WriteGoAway, 3) -> (writeBytes, 1)
(Dotests, 4) -> (New, 0) -> (New, 1) -> (HTTPWrappersForConfig, 2) -> (SetTransportDefaults, 1) -> (ConfigureTransport, 1) -> (configureTransport, 1) -> (addConnIfNeeded, 3) -> (run, 3) -> (addConnLocked, 2) -> (newClientConn, 2) -> (readLoop, 0) -> (WriteGoAway, 3) -> (writeBytes, 1) -> (in, 6)
(Dotests, 4) -> (GetService, 3) -> (New, 1) -> (HTTPWrappersForConfig, 2) -> (SetTransportDefaults, 1) -> (ConfigureTransport, 1) -> (configureTransport, 1) -> (addConnIfNeeded, 3) -> (run, 3) -> (addConnLocked, 2) -> (newClientConn, 2) -> (readLoop, 0) -> (WriteGoAway, 3) -> (writeBytes, 1) -> (in, 6)
(Dotests, 4) -> (New, 0) -> (New, 1) -> (HTTPWrappersForConfig, 2) -> (SetTransportDefaults, 1) -> (ConfigureTransport, 1) -> (configureTransport, 1) -> (addConnIfNeeded, 3) -> (run, 3) -> (addConnLocked, 2) -> (newClientConn, 2) -> (readLoop, 0) -> (WriteGoAway, 3) -> (writeBytes, 1) -> (in, 6) -> (assignBracketType, 3)
(Dotests, 4) -> (New, 0) -> (New, 1) -> (HTTPWrappersForConfig, 2) -> (SetTransportDefaults, 1) -> (ConfigureTransport, 1) -> (configureTransport, 1) -> (addConnIfNeeded, 3) -> (run, 3) -> (addConnLocked, 2) -> (newClientConn, 2) -> (readLoop, 0) -> (WriteGoAway, 3) -> (writeBytes, 1) -> (in, 6) -> (assignBracketType, 3)
(Dotests, 4) -> (New, 0) -> (New, 1) -> (HTTPWrappersForConfig, 2) -> (SetTransportDefaults, 1) -> (ConfigureTransport, 1) -> (configureTransport, 1) -> (addConnIfNeeded, 3) -> (run, 3) -> (addConnLocked, 2) -> (newClientConn, 2) -> (readLoop, 0) -> (WriteGoAway, 3) -> (writeBytes, 1) -> (in, 6) -> (assignBracketType, 3)
(Dotests, 4) -> (GetService, 3) -> (New, 1) -> (HTTPWrappersForConfig, 2) -> (SetTransportDefaults, 1) -> (ConfigureTransport, 1) -> (configureTransport, 1) -> (addConnIfNeeded, 3) -> (run, 3) -> (addConnLocked, 2) -> (newClientConn, 2) -> (readLoop, 0) -> (WriteGoAway, 3) -> (writeBytes, 1) -> (in, 6) -> (assignBracketType, 3)
(Dotests, 4) -> (GetService, 3) -> (New, 1) -> (HTTPWrappersForConfig, 2) -> (SetTransportDefaults, 1) -> (ConfigureTransport, 1) -> (configureTransport, 1) -> (addConnIfNeeded, 3) -> (run, 3) -> (addConnLocked, 2) -> (newClientConn, 2) -> (readLoop, 0) -> (WriteGoAway, 3) -> (writeBytes, 1) -> (in, 6) -> (assignBracketType, 3)
(Dotests, 4) -> (GetService, 3) -> (New, 1) -> (HTTPWrappersForConfig, 2) -> (SetTransportDefaults, 1) -> (ConfigureTransport, 1) -> (configureTransport, 1) -> (addConnIfNeeded, 3) -> (run, 3) -> (addConnLocked, 2) -> (newClientConn, 2) -> (readLoop, 0) -> (WriteGoAway, 3) -> (writeBytes, 1) -> (in, 6) -> (assignBracketType, 3)
(Dotests, 4) -> (New, 0) -> (New, 1) -> (HTTPWrappersForConfig, 2) -> (SetTransportDefaults, 1) -> (ConfigureTransport, 1) -> (configureTransport, 1) -> (addConnIfNeeded, 3) -> (run, 3) -> (addConnLocked, 2) -> (newClientConn, 2) -> (readLoop, 0) -> (WriteGoAway, 3) -> (writeBytes, 1) -> (in, 6) -> (assignBracketType, 3) -> (WithCancel, 1) -> (cancel, 2)
(Dotests, 4) -> (GetService, 3) -> (New, 1) -> (HTTPWrappersForConfig, 2) -> (SetTransportDefaults, 1) -> (ConfigureTransport, 1) -> (configureTransport, 1) -> (addConnIfNeeded, 3) -> (run, 3) -> (addConnLocked, 2) -> (newClientConn, 2) -> (readLoop, 0) -> (WriteGoAway, 3) -> (writeBytes, 1) -> (in, 6) -> (assignBracketType, 3) -> (WithCancel, 1) -> (cancel, 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: ab3181670cf30a75db9d051ade38750e1a0695fb
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.