github-vet / github-vet/rangeloop-pointer-findings
banzaicloud/pipeline: internal/ark/sync/backups_sync_svc.go; 42 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [banzaicloud/pipeline](https://www.github.com/banzaicloud/pipeline) at [internal/ark/sync/backups_sync_svc.go](https://github.com/banzaicloud/pipeline/blob/9d6e4240062207de07b624b2e395cd61186e3127/internal/ark/sync/backups_sync_svc.go#L121-L162)
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 backup was used in a composite literal at line 125
[Click here to see the code in its original context.](https://github.com/banzaicloud/pipeline/blob/9d6e4240062207de07b624b2e395cd61186e3127/internal/ark/sync/backups_sync_svc.go#L121-L162)
Click here to show the 42 line(s) of Go which triggered the analyzer.
```go
for _, backup := range backups.Items {
log := s.logger.WithField("backup", backup.Name)
req := &api.PersistBackupRequest{
BucketID: bucket.ID,
Backup: &backup,
DeploymentID: bucket.DeploymentID,
ClusterID: bucket.ClusterID,
Distribution: bucket.ClusterDistribution,
Cloud: bucket.ClusterCloud,
}
persitedBackup, err := s.backupsSvc.FindByPersistRequest(req)
if err == gorm.ErrRecordNotFound {
err = nil
}
if err != nil {
log.Warning(err.Error())
err = nil
continue
}
if persitedBackup != nil && persitedBackup.ContentChecked != true &&
(backup.Status.Phase == arkAPI.BackupPhaseCompleted || backup.Status.Phase == arkAPI.BackupPhasePartiallyFailed) {
nodes, err := s.bucketsSvc.GetNodesFromBackupContents(bucket, backup.Name)
if err != nil {
log.Warning(err.Error())
err = nil
continue
}
req.ContentChecked = true
req.Nodes = &nodes
req.NodeCount = uint(len(nodes.Items))
log.WithField("count", req.NodeCount).Debug("node count found")
}
_, err = s.backupsSvc.Persist(req)
if err != nil {
return errors.WrapIf(err, "could not persist backup")
}
log.Debug("backup synced")
}
```
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: 9d6e4240062207de07b624b2e395cd61186e3127
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.