github-vet / github-vet/rangeloop-pointer-findings
integr8ly/cluster-service: pkg/aws/manager_elasticache.go; 39 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [integr8ly/cluster-service](https://www.github.com/integr8ly/cluster-service) at [pkg/aws/manager_elasticache.go](https://github.com/integr8ly/cluster-service/blob/60f20b52d665180bb7c5f06e8a06ab390b619db9/pkg/aws/manager_elasticache.go#L83-L121)
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 replicationGroupId was used in a composite literal at line 101
[Click here to see the code in its original context.](https://github.com/integr8ly/cluster-service/blob/60f20b52d665180bb7c5f06e8a06ab390b619db9/pkg/aws/manager_elasticache.go#L83-L121)
Click here to show the 39 line(s) of Go which triggered the analyzer.
```go
for _, replicationGroupId := range replicationGroupsToDelete {
//delete each replication group in the list
rgLogger := logger.WithField("replicationGroupId", aws.String(replicationGroupId))
rgLogger.Debugf("building report for database")
reportItem := &clusterservice.ReportItem{
ID: replicationGroupId,
Name: "elasticache Replication group",
Action: clusterservice.ActionDelete,
ActionStatus: clusterservice.ActionStatusInProgress,
}
reportItems = append(reportItems, reportItem)
if dryRun {
rgLogger.Debug("dry run enabled, skipping deletion step")
reportItem.ActionStatus = clusterservice.ActionStatusDryRun
continue
}
rgLogger.Debug("performing deletion of replication group")
replicationGroupDescribeInput := &elasticache.DescribeReplicationGroupsInput{
ReplicationGroupId: &replicationGroupId,
}
replicationGroup, err := r.elasticacheClient.DescribeReplicationGroups(replicationGroupDescribeInput)
if err != nil {
return nil, errors.WrapLog(err, "cannot describe replicationGroups", logger)
}
//deleting will return an error if the replication group is already in a deleting state
if len(replicationGroup.ReplicationGroups) > 0 &&
aws.StringValue(replicationGroup.ReplicationGroups[0].Status) == statusDeleting {
rgLogger.Debugf("deletion of replication Groups already in progress")
reportItem.ActionStatus = clusterservice.ActionStatusInProgress
continue
}
deleteReplicationGroupInput := &elasticache.DeleteReplicationGroupInput{
ReplicationGroupId: aws.String(replicationGroupId),
RetainPrimaryCluster: aws.Bool(false),
}
if _, err := r.elasticacheClient.DeleteReplicationGroup(deleteReplicationGroupInput); err != nil {
return nil, errors.WrapLog(err, "failed to delete elasticache replication group", logger)
}
}
```
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: 60f20b52d665180bb7c5f06e8a06ab390b619db9
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.