github-vet / github-vet/rangeloop-pointer-findings
zalando-incubator/kube-metrics-adapter: pkg/provider/hpa.go; 55 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [zalando-incubator/kube-metrics-adapter](https://www.github.com/zalando-incubator/kube-metrics-adapter) at [pkg/provider/hpa.go](https://github.com/zalando-incubator/kube-metrics-adapter/blob/6f71e9c6b0c46f4d7eea7c9821fde46ad16df2b6/pkg/provider/hpa.go#L131-L185)
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.
>
[Click here to see the code in its original context.](https://github.com/zalando-incubator/kube-metrics-adapter/blob/6f71e9c6b0c46f4d7eea7c9821fde46ad16df2b6/pkg/provider/hpa.go#L131-L185)
Click here to show the 55 line(s) of Go which triggered the analyzer.
```go
for _, hpa := range hpas.Items {
resourceRef := resourceReference{
Name: hpa.Name,
Namespace: hpa.Namespace,
}
cachedHPA, ok := p.hpaCache[resourceRef]
hpaUpdated := !equalHPA(cachedHPA, hpa)
if !ok || hpaUpdated {
// if the hpa has changed then remove the previous
// scheduled collector.
if hpaUpdated {
p.logger.Infof("Removing previously scheduled metrics collector: %s", resourceRef)
p.collectorScheduler.Remove(resourceRef)
}
metricConfigs, err := collector.ParseHPAMetrics(&hpa)
if err != nil {
p.logger.Errorf("Failed to parse HPA metrics: %v", err)
continue
}
cache := true
for _, config := range metricConfigs {
interval := config.Interval
if interval == 0 {
interval = p.collectorInterval
}
c, err := p.collectorFactory.NewCollector(&hpa, config, interval)
if err != nil {
// Only log when it's not a PluginNotFoundError AND flag disregardIncompatibleHPAs is true
if !(errors.Is(err, &collector.PluginNotFoundError{}) && p.disregardIncompatibleHPAs) {
p.recorder.Eventf(&hpa, apiv1.EventTypeWarning, "CreateNewMetricsCollector", "Failed to create new metrics collector: %v", err)
}
cache = false
continue
}
p.logger.Infof("Adding new metrics collector: %T", c)
p.collectorScheduler.Add(resourceRef, config.MetricTypeName, c)
}
newHPAs++
// if we get an error setting up the collectors for the
// HPA, don't cache it, but try again later.
if !cache {
continue
}
}
newHPACache[resourceRef] = hpa
}
```
Click here to show extra information the analyzer produced.
```
No path was found through the callgraph that could lead to a function which writes a pointer argument.
No path was found through the callgraph that could lead to a function which passes a pointer to third-party code.
root signature {Eventf 5} was not found in the callgraph; reference was passed directly to third-party code
```
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: 6f71e9c6b0c46f4d7eea7c9821fde46ad16df2b6
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.