Skip to content

Commit

Permalink
TEP-0121: Move metrics recorder out of reconcile() to ReconcileKind()
Browse files Browse the repository at this point in the history
Prior to this commit, metrics recording durationAndCountMetrics()
is in reconcile() (instead of ReconcileKind()), which only counts
the taskrun numbers where the taskruns that have no preparation
error / not cancelled right after scheduled / not timed out before
calling reconcile() (for example, be pending for a long time.).

This commit moves durationAndCountMetrics() into ReconcileKind()
to address the issue above.

It's worth mentioning that the recording metrics logic was
originally in the ReconcileKind() function, but the commit 1375219,
aming at addressing the recount issue, **moves that logic to `reconcile()`**
[1] (probably for better code style? 🤔).

[1] 1375219#diff-6e67e9c647bbe2a08807ff5ccbdd7dc9036df373e56b9774d3996f92ab7ceabaL138-L145
  • Loading branch information
XinruZhang authored and tekton-robot committed Dec 15, 2022
1 parent e55c0da commit ed8a2c2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/reconciler/taskrun/taskrun.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ var (
// converge the two. It then updates the Status block of the Task Run
// resource with the current status of the resource.
func (c *Reconciler) ReconcileKind(ctx context.Context, tr *v1beta1.TaskRun) pkgreconciler.Event {
defer c.durationAndCountMetrics(ctx, tr)
logger := logging.FromContext(ctx)
ctx = cloudevent.ToContext(ctx, c.cloudEventClient)
// By this time, params and workspaces should not be propagated for embedded tasks so we cannot
Expand Down Expand Up @@ -452,7 +453,6 @@ func (c *Reconciler) prepare(ctx context.Context, tr *v1beta1.TaskRun) (*v1beta1
// error but it does not sync updates back to etcd. It does not emit events.
// `reconcile` consumes spec and resources returned by `prepare`
func (c *Reconciler) reconcile(ctx context.Context, tr *v1beta1.TaskRun, rtr *resources.ResolvedTaskResources) error {
defer c.durationAndCountMetrics(ctx, tr)
logger := logging.FromContext(ctx)
recorder := controller.GetEventRecorder(ctx)
var err error
Expand Down

0 comments on commit ed8a2c2

Please sign in to comment.