Skip to content

Commit

Permalink
check namespace config for node throttle metric
Browse files Browse the repository at this point in the history
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
  • Loading branch information
gabemontero authored and tekton-robot committed Aug 20, 2024
1 parent 3429744 commit ecad3fa
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkg/taskrunmetrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,11 @@ func (r *Recorder) RunningTaskRuns(ctx context.Context, lister listers.TaskRunLi
metrics.Record(ctx, runningTRsThrottledByQuota.M(float64(cnt)))
}
for ns, cnt := range trsThrottledByNode {
ctx, err := tag.New(ctx, []tag.Mutator{tag.Insert(namespaceTag, ns)}...)
var mutators []tag.Mutator
if addNamespaceLabelToQuotaThrottleMetric {
mutators = []tag.Mutator{tag.Insert(namespaceTag, ns)}
}
ctx, err := tag.New(ctx, mutators...)
if err != nil {
return err
}
Expand Down
12 changes: 12 additions & 0 deletions pkg/taskrunmetrics/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,18 @@ func TestRecordRunningTaskRunsThrottledCounts(t *testing.T) {
reason: pod.ReasonExceededNodeResources,
nodeCount: 3,
},
{
status: corev1.ConditionUnknown,
reason: pod.ReasonExceededResourceQuota,
quotaCount: 3,
addNS: true,
},
{
status: corev1.ConditionUnknown,
reason: pod.ReasonExceededNodeResources,
nodeCount: 3,
addNS: true,
},
{
status: corev1.ConditionUnknown,
reason: v1.TaskRunReasonResolvingTaskRef,
Expand Down

0 comments on commit ecad3fa

Please sign in to comment.