github-vet / github-vet/rangeloop-pointer-findings
networkservicemesh/networkservicemesh: scripts/aws/destroy-kubernetes-cluster.go; 38 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [networkservicemesh/networkservicemesh](https://www.github.com/networkservicemesh/networkservicemesh) at [scripts/aws/destroy-kubernetes-cluster.go](https://github.com/networkservicemesh/networkservicemesh/blob/cb2e62e24eb38c3ff7faa62f8e78ff8af197f675/scripts/aws/destroy-kubernetes-cluster.go#L319-L356)
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.
> range-loop variable stack used in defer or goroutine at line 344
[Click here to see the code in its original context.](https://github.com/networkservicemesh/networkservicemesh/blob/cb2e62e24eb38c3ff7faa62f8e78ff8af197f675/scripts/aws/destroy-kubernetes-cluster.go#L319-L356)
Click here to show the 38 line(s) of Go which triggered the analyzer.
```go
for _, stack := range stacks.StackSummaries {
stackName := aws.StringValue(stack.StackName)
if stackName[:len(awsClusterStackPrefix)] != "nsm-srv" {
continue
}
if aws.StringValue(stack.StackStatus) == "DELETE_COMPLETE" {
continue
}
if matched, err := regexp.MatchString(namePattern, stackName[len(awsClusterStackPrefix):]); err != nil || !matched {
logrus.Infof("Skip cluster: %s (matched: %v; err: %v)", stackName[len(awsClusterStackPrefix):], matched, err)
continue
}
if stack.CreationTime.After(time.Now().Add(-1 * saveDuration)) {
logrus.Infof("Skip cluster: %s (created: %v)", stackName[len(awsClusterStackPrefix):], stack.CreationTime)
continue
}
wg.Add(1)
go func() {
defer wg.Done()
for att := 0; att < 3; att++ {
logrus.Infof("Deleting %s (created %v), attempt %d", stackName[len(awsClusterStackPrefix):], stack.CreationTime, att+1)
err := NewAWSCluster(stackName[len(awsClusterStackPrefix):]).DeleteAWSKubernetesCluster()
if err == nil {
break
}
}
}()
i++
if i%5 == 0 {
wg.Wait() // Guard from AWS Throttling error
}
}
```
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: cb2e62e24eb38c3ff7faa62f8e78ff8af197f675
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.