github-vet / github-vet/rangeloop-pointer-findings
kindule/zalando-postgres-operator: pkg/cluster/volumes.go; 37 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [kindule/zalando-postgres-operator](https://www.github.com/kindule/zalando-postgres-operator) at [pkg/cluster/volumes.go](https://github.com/kindule/zalando-postgres-operator/blob/8161b5d48cf8d6e2849685fbd6bc2c3caadf60f7/pkg/cluster/volumes.go#L114-L150)
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 resizer used in defer or goroutine at line 125
[Click here to see the code in its original context.](https://github.com/kindule/zalando-postgres-operator/blob/8161b5d48cf8d6e2849685fbd6bc2c3caadf60f7/pkg/cluster/volumes.go#L114-L150)
Click here to show the 37 line(s) of Go which triggered the analyzer.
```go
for _, resizer := range resizers {
if !resizer.VolumeBelongsToProvider(pv) {
continue
}
compatible = true
if !resizer.IsConnectedToProvider() {
err := resizer.ConnectToProvider()
if err != nil {
return fmt.Errorf("could not connect to the volume provider: %v", err)
}
defer func() {
if err := resizer.DisconnectFromProvider(); err != nil {
c.logger.Errorf("%v", err)
}
}()
}
awsVolumeID, err := resizer.GetProviderVolumeID(pv)
if err != nil {
return err
}
c.logger.Debugf("updating persistent volume %q to %d", pv.Name, newSize)
if err := resizer.ResizeVolume(awsVolumeID, newSize); err != nil {
return fmt.Errorf("could not resize EBS volume %q: %v", awsVolumeID, err)
}
c.logger.Debugf("resizing the filesystem on the volume %q", pv.Name)
podName := getPodNameFromPersistentVolume(pv)
if err := c.resizePostgresFilesystem(podName, []filesystems.FilesystemResizer{&filesystems.Ext234Resize{}}); err != nil {
return fmt.Errorf("could not resize the filesystem on pod %q: %v", podName, err)
}
c.logger.Debugf("filesystem resize successful on volume %q", pv.Name)
pv.Spec.Capacity[v1.ResourceStorage] = newQuantity
c.logger.Debugf("updating persistent volume definition for volume %q", pv.Name)
if _, err := c.KubeClient.PersistentVolumes().Update(pv); err != nil {
return fmt.Errorf("could not update persistent volume: %q", err)
}
c.logger.Debugf("successfully updated persistent volume %q", pv.Name)
}
```
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: 8161b5d48cf8d6e2849685fbd6bc2c3caadf60f7
Contributor guide
No contributing guide indexed for this repository
Research direction
Inspect pkg/cluster/volumes.go at lines 114-150 in commit 8161b5d48cf8d6e2849685fbd6bc2c3caadf60f7, focusing on the deferred closure inside the resizers range loop. Determine whether the closure captures the range variable in a way that can disconnect the wrong resizer, then leave the requested reaction classification on this issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, postgresql
- Domain
- backend, databases
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100