Skip to content

Conversation

@vdemeester
Copy link
Member

@vdemeester vdemeester commented Dec 3, 2025

Changes

  • Stop immediate requeue loops when default-timeout-minutes is "0"
  • Remove redundant hasCondition checks (Knative already deduplicates)

This adds an e2e tests that looks at pipeline logs to see how much reconciler loop there is. If you run it before the fix, it would count more than 1500 reconciler loop, whereas with the fix, only about 10.

/cc @afrittoli @pritidesai @tektoncd/core-maintainers

It took me a while to figure out, and I got some help from Claude (AI) to write the tests. The previous behavior seemed very weird as well, with no timeout, we would, re-queue instantly, which is.. madness 🙃

/kind bug

Fixes #8495

This could be a good candidate to be backported.

Submitter Checklist

As the author of this PR, please check off the items in this checklist:

  • Has Docs if any changes are user facing, including updates to minimum requirements e.g. Kubernetes version bumps
  • Has Tests included if any functionality added or changed
  • pre-commit Passed
  • Follows the commit message standard
  • Meets the Tekton contributor standards (including functionality, content, code)
  • Has a kind label. You can add one by adding a comment on this PR that contains /kind <type>. Valid types are bug, cleanup, design, documentation, feature, flake, misc, question, tep
  • Release notes block below has been updated with any user facing changes (API changes, bug fixes, changes requiring upgrade notices or deprecation warnings). See some examples of good release notes.
  • Release notes contains the string "action required" if the change requires additional action from users switching to the new release

Release Notes

Fix an issue where there was excessive reconciliation in case of no timeout on TaskRun or PipelineRun.

@tekton-robot tekton-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/bug Categorizes issue or PR as related to a bug. labels Dec 3, 2025
@tekton-robot tekton-robot requested review from a team and pritidesai December 3, 2025 10:23
@tekton-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
To complete the pull request process, please ask for approval from vdemeester after the PR has been reviewed.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@tekton-robot tekton-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Dec 3, 2025
@vdemeester vdemeester added this to the v1.8.0 milestone Dec 3, 2025
@vdemeester vdemeester force-pushed the fix-8495-excessive-reconciliation branch from c99df33 to 70e919d Compare December 3, 2025 11:57
@vdemeester
Copy link
Member Author

/hold
Getting help from Claude to figure out the e2e failures 😅 Will remove the hold once I get greens

@tekton-robot tekton-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Dec 3, 2025
Copy link
Member

@twoGiants twoGiants left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job for the fix 😸 👍. My brain got challenged understanding the timeout order... 🧠 ⚡. It looks good though! I would just keep the code a bit more consistent, will aid in future understanding.

See my comments below.

if timeout == config.NoTimeoutDuration {
waitTime = time.Duration(config.FromContextOrDefaults(ctx).Defaults.DefaultTimeoutMinutes) * time.Minute
// Check if we have a specific task timeout to wait for
if pr.Status.FinallyStartTime == nil && taskTimeout != nil && taskTimeout.Duration != config.NoTimeoutDuration {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The introduced checks here and the existing below are quite similar. I would keep the style consistent in both of them. The early returns is the way to go. Then this code is a bit easier to understand. I will add comments in each line where I would change up a bit.

Comment on lines 297 to 298
waitTime := pr.FinallyTimeout().Duration - c.Clock.Since(pr.Status.FinallyStartTime.Time)
return controller.NewRequeueAfter(waitTime)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets use the same variable naming as below. Is clearer.

Suggested change
waitTime := pr.FinallyTimeout().Duration - c.Clock.Since(pr.Status.FinallyStartTime.Time)
return controller.NewRequeueAfter(waitTime)
finallyWaitTime := pr.FinallyTimeout().Duration - c.Clock.Since(pr.Status.FinallyStartTime.Time)
return controller.NewRequeueAfter(finallyWaitTime)

if taskTimeout.Duration == config.NoTimeoutDuration {
waitTime = time.Duration(config.FromContextOrDefaults(ctx).Defaults.DefaultTimeoutMinutes) * time.Minute
waitTime = timeout - elapsed
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add an early return here like above and break the if-else-if apart. Like you have above.

Suggested change
}
return controller.NewRequeueAfter(waitTime)
}

waitTime = time.Duration(config.FromContextOrDefaults(ctx).Defaults.DefaultTimeoutMinutes) * time.Minute
waitTime = timeout - elapsed
}
} else if pr.Status.FinallyStartTime != nil && pr.FinallyTimeout() != nil &&
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Break the else-if and move return controller.NewRequeueAfter(waitTime) into the if.

		}

		if pr.Status.FinallyStartTime != nil && pr.FinallyTimeout() != nil &&
			pr.FinallyTimeout().Duration != config.NoTimeoutDuration {
			finallyWaitTime := pr.FinallyTimeout().Duration - c.Clock.Since(pr.Status.FinallyStartTime.Time)
			if finallyWaitTime < waitTime {
				waitTime = finallyWaitTime
			}
			return controller.NewRequeueAfter(waitTime)
		}
	}
	return nil
}

Can't do a better suggestion on the hidden lines. This is how it should look like

return controller.NewRequeueAfter(waitTime)
}
// Check if we have a finally timeout to wait for
if pr.Status.FinallyStartTime != nil && pr.FinallyTimeout() != nil && pr.FinallyTimeout().Duration != config.NoTimeoutDuration {
Copy link
Member

@twoGiants twoGiants Dec 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check is identical to the check in 311-316. Don't you need this here too?:

if finallyWaitTime < waitTime {
		waitTime = finallyWaitTime
}

- Stop immediate requeue loops when default-timeout-minutes is "0"
- Remove redundant hasCondition checks (Knative already deduplicates)

This adds an e2e tests that looks at pipeline logs to see how much
reconciler loop there is. If you run it before the fix, it would count
more than 1500 reconciler loop, whereas with the fix, only about 10.

Signed-off-by: Vincent Demeester <[email protected]>
Co-Authored-By: Claude <[email protected]>
@vdemeester vdemeester force-pushed the fix-8495-excessive-reconciliation branch from 661ed4e to 9d13377 Compare December 9, 2025 10:13
@vdemeester
Copy link
Member Author

@twoGiants I changed a bit the if/else chains to make it.. less weird.. hopefully it's more readable.

@vdemeester
Copy link
Member Author

/hold cancel

@tekton-robot tekton-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Dec 18, 2025
@vdemeester
Copy link
Member Author

/retest

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Categorizes issue or PR as related to a bug. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

PipelineRun is reconciled thousands of times

3 participants