github-vet / github-vet/rangeloop-pointer-findings
cortexlabs/cortex: pkg/operator/endpoints/info.go; 30 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [cortexlabs/cortex](https://www.github.com/cortexlabs/cortex) at [pkg/operator/endpoints/info.go](https://github.com/cortexlabs/cortex/blob/2f8d0cf42f6369cadfe9c9c7dc8de2a45a459b72/pkg/operator/endpoints/info.go#L72-L101)
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.
> reference to node was used in a composite literal at line 97
[Click here to see the code in its original context.](https://github.com/cortexlabs/cortex/blob/2f8d0cf42f6369cadfe9c9c7dc8de2a45a459b72/pkg/operator/endpoints/info.go#L72-L101)
Click here to show the 30 line(s) of Go which triggered the analyzer.
```go
for _, node := range nodes {
instanceType := node.Labels["beta.kubernetes.io/instance-type"]
isSpot := strings.Contains(strings.ToLower(node.Labels["lifecycle"]), "spot")
price := aws.InstanceMetadatas[*config.Cluster.Region][instanceType].Price
if isSpot {
if spotPrice, ok := spotPriceCache[instanceType]; ok {
price = spotPrice
} else {
spotPrice, err := config.AWS.SpotInstancePrice(instanceType)
if err == nil && spotPrice != 0 {
price = spotPrice
spotPriceCache[instanceType] = spotPrice
} else {
spotPriceCache[instanceType] = price // the request failed, so no need to try again in the future
}
}
}
nodeInfoMap[node.Name] = &schema.NodeInfo{
Name: node.Name,
InstanceType: instanceType,
IsSpot: isSpot,
Price: price,
NumReplicas: 0, // will be added to below
ComputeUserCapacity: nodeComputeAllocatable(&node), // will be subtracted from below
ComputeAvailable: nodeComputeAllocatable(&node), // will be subtracted from below
ComputeUserRequested: userconfig.ZeroCompute(), // will be added to below
}
}
```
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: 2f8d0cf42f6369cadfe9c9c7dc8de2a45a459b72
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.