github-vet / github-vet/rangeloop-pointer-findings
elsevier-core-engineering/replicator: client/job_scaling_policies.go; 42 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [elsevier-core-engineering/replicator](https://www.github.com/elsevier-core-engineering/replicator) at [client/job_scaling_policies.go](https://github.com/elsevier-core-engineering/replicator/blob/b86a43c9d8de5f091519d9c05609551ca7bf4848/client/job_scaling_policies.go#L102-L143)
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 group used in defer or goroutine at line 136
[Click here to see the code in its original context.](https://github.com/elsevier-core-engineering/replicator/blob/b86a43c9d8de5f091519d9c05609551ca7bf4848/client/job_scaling_policies.go#L102-L143)
Click here to show the 42 line(s) of Go which triggered the analyzer.
```go
for _, group := range jobInfo.TaskGroups {
if group.Update == nil {
logging.Error("client/job_scaling_policies: job %s and group %v is missing update stanza",
jobID, *group.Name)
continue
}
missedKeys := helper.ParseMetaConfig(group.Meta, requiredKeys)
// If all 7 keys missed, then the job group does not have scaling enabled,
// this is logged for operator clarity.
if len(missedKeys) == len(requiredKeys) {
logging.Debug("client/job_scaling_policies: job %s and group %v is not configured for autoscaling",
jobID, *group.Name)
go removeGroupScalingPolicy(jobID, *group.Name, scaling)
continue
}
// If some keys missed, the operator has made an effort to enable job scaling
// but potentially made a typo. This is logged as an error so operators can
// see and quickly resolve these issues.
if len(missedKeys) > 0 && len(missedKeys) < len(requiredKeys) {
logging.Error("client/job_scaling_policies: job %s and group %v is missing meta scaling key(s): %v",
jobID, *group.Name, missedKeys)
continue
}
// If all keys were matched we update the job scaling policy struct with the
// information.
if len(missedKeys) == 0 {
logging.Debug("client/job_scaling_policies: job %s and group %v has all meta required for autoscaling",
jobID, *group.Name)
go func() {
err := updateScalingPolicy(jobID, *group.Name, group.Meta, scaling)
if err != nil {
logging.Error("client/job_scaling_policies: unable to update scaling policy for job %v and group %v: %v",
jobID, group.Name, err)
}
}()
}
}
```
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: b86a43c9d8de5f091519d9c05609551ca7bf4848
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.