Skip to content

running_taskruns metric overcounts TaskRuns that have no condition set yet #9438

@khrm

Description

@khrm

tekton_pipelines_controller_running_taskruns should only count TaskRuns whose Succeeded condition is Unknown, matching the behavior of the equivalent PipelineRun metric.

Actual Behavior

observeRunningTaskRuns uses !tr.IsDone() as the running predicate. Since IsDone() returns false when no Succeeded condition exists, newly created TaskRuns (before their first reconcile) are
incorrectly counted as running. This also creates an internal inconsistency: the throttle/task-resolution sub-metrics in the same loop are gated on succeedCondition != nil &&
succeedCondition.Status == corev1.ConditionUnknown, so a no-condition TaskRun increments runningTrs but none of the sub-metrics.

Root Cause

pkg/taskrunmetrics/metrics.go, observeRunningTaskRuns:

// Current (incorrect) — counts TaskRuns with no condition set
if !tr.IsDone() {

// Fix — aligns with pipelinerunmetrics; nil.IsUnknown() returns false
if tr.Status.GetCondition(apis.ConditionSucceeded).IsUnknown() {

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugCategorizes issue or PR as related to a bug.

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions