Skip to content

Commit ecad3fa

Browse files
gabemonterotekton-robot
authored andcommitted
check namespace config for node throttle metric
Now that @vdemeester 's fix so that the background metric polling goroutines for pipelinerunmetrics and taskrunmetrics can access config.observability, we can properly address issue around verifiying non-default config around adding the namespace label for the node and quota throttle metrics that @divyansh42 @khrm and myself discovered last week. Signed-off-by: gabemontero <gmontero@redhat.com> rh-pre-commit.version: 2.3.1 rh-pre-commit.check-secrets: ENABLED
1 parent 3429744 commit ecad3fa

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

pkg/taskrunmetrics/metrics.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,11 @@ func (r *Recorder) RunningTaskRuns(ctx context.Context, lister listers.TaskRunLi
528528
metrics.Record(ctx, runningTRsThrottledByQuota.M(float64(cnt)))
529529
}
530530
for ns, cnt := range trsThrottledByNode {
531-
ctx, err := tag.New(ctx, []tag.Mutator{tag.Insert(namespaceTag, ns)}...)
531+
var mutators []tag.Mutator
532+
if addNamespaceLabelToQuotaThrottleMetric {
533+
mutators = []tag.Mutator{tag.Insert(namespaceTag, ns)}
534+
}
535+
ctx, err := tag.New(ctx, mutators...)
532536
if err != nil {
533537
return err
534538
}

pkg/taskrunmetrics/metrics_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,18 @@ func TestRecordRunningTaskRunsThrottledCounts(t *testing.T) {
583583
reason: pod.ReasonExceededNodeResources,
584584
nodeCount: 3,
585585
},
586+
{
587+
status: corev1.ConditionUnknown,
588+
reason: pod.ReasonExceededResourceQuota,
589+
quotaCount: 3,
590+
addNS: true,
591+
},
592+
{
593+
status: corev1.ConditionUnknown,
594+
reason: pod.ReasonExceededNodeResources,
595+
nodeCount: 3,
596+
addNS: true,
597+
},
586598
{
587599
status: corev1.ConditionUnknown,
588600
reason: v1.TaskRunReasonResolvingTaskRef,

0 commit comments

Comments
 (0)