github-vet / github-vet/rangeloop-pointer-findings
kubernetes/test-infra: prow/cmd/sinker/main.go; 50 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [kubernetes/test-infra](https://www.github.com/kubernetes/test-infra) at [prow/cmd/sinker/main.go](https://github.com/kubernetes/test-infra/blob/94bde9b43d8af13762777ee060954f2a90ea1d5d/prow/cmd/sinker/main.go#L398-L447)
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/kubernetes/test-infra/blob/94bde9b43d8af13762777ee060954f2a90ea1d5d/prow/cmd/sinker/main.go#L398-L447)
Click here to show the 50 line(s) of Go which triggered the analyzer.
```go
for _, pod := range pods.Items {
reason := ""
clean := false
// by default, use the pod name as the key to match the associated prow job
// this is to support legacy plank in case the kube.ProwJobIDLabel label is not set
podJobName := pod.ObjectMeta.Name
// if the pod has the kube.ProwJobIDLabel label, use this instead of the pod name
if value, ok := pod.ObjectMeta.Labels[kube.ProwJobIDLabel]; ok {
podJobName = value
}
log = log.WithField("pj", podJobName)
terminationTime := time.Time{}
if pj, ok := pjMap[podJobName]; ok && pj.Complete() {
terminationTime = pj.Status.CompletionTime.Time
}
if podNeedsKubernetesFinalizerCleanup(log, pjMap[podJobName], &pod) {
if err := c.cleanupKubernetesFinalizer(&pod, client); err != nil {
log.WithError(err).Error("Failed to remove kubernetesreporter finalizer")
}
}
switch {
case !pod.Status.StartTime.IsZero() && time.Since(pod.Status.StartTime.Time) > maxPodAge:
clean = true
reason = reasonPodAged
case !terminationTime.IsZero() && time.Since(terminationTime) > terminatedPodTTL:
clean = true
reason = reasonPodTTLed
}
if !isFinished.Has(podJobName) {
// prowjob exists and is not marked as completed yet
// deleting the pod now will result in plank creating a brand new pod
clean = false
}
if c.isPodOrphaned(log, &pod, podJobName) {
// prowjob has gone, we want to clean orphan pods regardless of the state
reason = reasonPodOrphaned
clean = true
}
if !clean {
continue
}
c.deletePod(log, &pod, reason, client, &metrics)
}
```
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 {deletePod 5} 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: 94bde9b43d8af13762777ee060954f2a90ea1d5d
Contributor guide
No contributing guide indexed for this repository
Research direction
Read prow/cmd/sinker/main.go around lines 398-447 and trace podNeedsKubernetesFinalizerCleanup, isPodOrphaned, and deletePod to determine whether the range variable's address escapes or reaches third-party code. Compare that behavior with the analyzer's empty report and classify the finding as Bug, Mitigated, or Desirable Behavior; it is done when an evidence-backed reaction is left.
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