github-vet / github-vet/rangeloop-pointer-findings
dotmesh-io/ds-deployer: internal/controller/ingress_controller.go; 51 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [dotmesh-io/ds-deployer](https://www.github.com/dotmesh-io/ds-deployer) at [internal/controller/ingress_controller.go](https://github.com/dotmesh-io/ds-deployer/blob/cf9c00239111686572d242d57742f0878e847562/internal/controller/ingress_controller.go#L23-L73)
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 modelDeployment used in defer or goroutine at line 61
[Click here to see the code in its original context.](https://github.com/dotmesh-io/ds-deployer/blob/cf9c00239111686572d242d57742f0878e847562/internal/controller/ingress_controller.go#L23-L73)
Click here to show the 51 line(s) of Go which triggered the analyzer.
```go
for _, modelDeployment := range c.cache.ModelDeployments() {
existing, ok := c.cache.GetIngress(modelDeployment.Namespace, getDeploymentName(modelDeployment))
if !ok {
if c.statusCache.Get(modelDeployment.Id).Ingress != status.StatusConfiguring {
c.statusCache.Set(modelDeployment.Id, status.ModuleIngress, status.StatusConfiguring)
}
wg.Add(1)
// creating new deployment
go func(modelDeployment *deployer_v1.Deployment) {
err := c.createIngress(modelDeployment)
if err != nil {
c.logger.Errorw("failed to create ingress",
"error", err,
"deployment_id", modelDeployment.GetId(),
)
}
wg.Done()
}(modelDeployment)
// should get created if it doesn't exist
continue
}
c.logger.Debugf("ingress %s/%s found, checking for updates", existing.Namespace, existing.Name)
if !ingressesEqual(toKubernetesIngress(modelDeployment, c.controllerIdentifier), existing) {
if c.statusCache.Get(modelDeployment.Id).Ingress != status.StatusConfiguring {
c.statusCache.Set(modelDeployment.Id, status.ModuleIngress, status.StatusConfiguring)
}
updatedIngress := updateIngress(existing, modelDeployment, c.controllerIdentifier)
wg.Add(1)
go func(updatedIngress *v1beta1.Ingress) {
err := c.client.Update(context.Background(), updatedIngress)
if err != nil {
c.logger.Errorw("failed to update service",
"error", err,
"service_namespace", modelDeployment.Namespace,
"service_name", updatedIngress.GetName(),
"deployment_id", modelDeployment.GetId(),
)
}
wg.Done()
}(updatedIngress)
} else {
if c.statusCache.Get(modelDeployment.Id).Ingress != status.StatusReady {
c.statusCache.Set(modelDeployment.Id, status.ModuleIngress, status.StatusReady)
}
}
}
```
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: cf9c00239111686572d242d57742f0878e847562
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in internal/controller/ingress_controller.go around lines 23-73 and inspect the goroutines created while iterating over ModelDeployments, especially the update path near line 61. Compare the closure arguments and logging references, then verify that the analyzer finding is resolved without changing ingress creation or update behavior using the repository's existing Go tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- infrastructure
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100