github-vet / github-vet/rangeloop-pointer-findings
kiegroup/kogito-cloud-operator: controllers/build/trigger.go; 47 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [kiegroup/kogito-cloud-operator](https://www.github.com/kiegroup/kogito-cloud-operator) at [controllers/build/trigger.go](https://github.com/kiegroup/kogito-cloud-operator/blob/017427aa88254789ab1142072b258e8f213f69eb/controllers/build/trigger.go#L58-L104)
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.
>
[Click here to see the code in its original context.](https://github.com/kiegroup/kogito-cloud-operator/blob/017427aa88254789ab1142072b258e8f213f69eb/controllers/build/trigger.go#L58-L104)
Click here to show the 47 line(s) of Go which triggered the analyzer.
```go
for _, b := range builds.Items {
if b.Status.Phase == v1.BuildPhaseNew ||
b.Status.Phase == v1.BuildPhasePending ||
b.Status.Phase == v1.BuildPhaseRunning {
var cancelError error
wg.Add(1)
go func(build *v1.Build) {
defer wg.Done()
err := wait.Poll(poolWaitTimeout, cancelUpdateTimeout, func() (bool, error) {
build.Status.Cancelled = true
_, err := client.BuildCli.Builds(build.Namespace).Update(context.TODO(), build, metav1.UpdateOptions{})
if err == nil {
return true, nil
} else if errors.IsConflict(err) {
// try again, someone just updated our status
build, err = client.BuildCli.Builds(build.Namespace).Get(context.TODO(), build.Name, metav1.GetOptions{})
return false, err
}
return true, err
})
if err != nil {
log.Error(err, "Failed to cancel", "Build", build.Name)
cancelError = err
return
}
// wait for the build to be cancelled
err = wait.Poll(poolWaitTimeout, cancelUpdateTimeout, func() (bool, error) {
updatedBuild, err := client.BuildCli.Builds(build.Namespace).Get(context.TODO(), build.Name, metav1.GetOptions{})
if err != nil {
return true, err
}
if updatedBuild.Status.Phase == v1.BuildPhaseCancelled {
log.Info("Successfully cancelled", "Build", build.Name, "Namespace", build.Namespace)
return true, nil
}
return false, nil
})
if err != nil {
log.Error(err, "Failed to fetch build during cancelling check phase", "Build", build.Name)
cancelError = err
return
}
}(&b)
wg.Wait()
return cancelError
}
}
```
Click here to show extra information the analyzer produced.
```
No path was found through the callgraph that could lead to a function which writes a pointer argument.
No path was found through the callgraph that could lead to a function which passes a pointer to third-party code.
root signature { 1} was not found in the callgraph; reference was passed directly to third-party code
```
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: 017427aa88254789ab1142072b258e8f213f69eb
Contributor guide
No contributing guide indexed for this repository
Research direction
Read controllers/build/trigger.go lines 58-104 at commit 017427aa88254789ab1142072b258e8f213f69eb, then review the analyzer's range-loop pointer finding and its Bug, Mitigated, and Desirable Behavior guidance. Done means determining the appropriate classification and leaving the corresponding reaction on the issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- devops, infrastructure
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100