Skip to content

Conversation

@hasanawad94
Copy link
Contributor

@hasanawad94 hasanawad94 commented Aug 19, 2025

This will be relevant to shipwright-io/community#277.
This pr only covers introducing PipelineRuns as an alternative to taskruns to be used for buildruns.
With these changes when BUILDRUN_EXECUTOR controller environment flag is set to PipelineRun the original taskrun will be embedded into a pipelinerun.

Future prs will cover making PipelineRun to define a set of TaskRuns that can run in parallel. This shp covers the details.

Changes

  • Add pipelinerun_runner.go with TektonPipelineRunWrapper implementation
    that wraps Tekton PipelineRuns and injects TaskRun specs into PipelineRun
    structures.
  • Implement ImageBuildRunner and ImageBuildRunnerFactory interfaces for
    PipelineRun support.
  • Add reconciliation logic for PipelineRun status updates, including
    condition handling and failure detection while maintaining original reconcile logic for taskruns.
  • Add UpdateBuildRunUsingPipelineRunCondition function to update BuildRun
    status based on PipelineRun conditions (timeout, cancellation, success,
    failure)
  • Refactor volume checking to use GetUnderlyingTaskRun() method for both
    TaskRun and PipelineRun executors, eliminating the need for separate
    volume checking methods
  • Add RunnerFactories map to support configurable executor selection
    between TaskRun and PipelineRun implementations
  • Update error handling in CreateImageBuildRunner
  • Added unit, integration and e2e tests to ci.

Submitter Checklist

  • Includes tests if functionality changed/was added
  • Includes docs if changes are user-facing
  • Set a kind label on this PR
  • Release notes block has been filled in, or marked NONE

Release Notes

Added support for Tekton PipelineRuns as an alternative to TaskRuns for build execution. Configurable executor selection - users can now choose between TaskRun and PipelineRun executors via configuration.

@openshift-ci openshift-ci bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note Label for when a PR has specified a release note labels Aug 19, 2025
@pull-request-size pull-request-size bot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Aug 19, 2025
@hasanawad94 hasanawad94 force-pushed the add-pipelinerun-reconciliation branch 8 times, most recently from 920c1fe to 83ea44c Compare August 26, 2025 11:03
@hasanawad94 hasanawad94 force-pushed the add-pipelinerun-reconciliation branch from 83ea44c to b7cc447 Compare August 27, 2025 11:55
@pull-request-size pull-request-size bot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Aug 27, 2025
@hasanawad94 hasanawad94 force-pushed the add-pipelinerun-reconciliation branch 11 times, most recently from 3625cbe to 33f0016 Compare September 2, 2025 07:21
@hasanawad94 hasanawad94 marked this pull request as ready for review September 2, 2025 07:26
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Sep 2, 2025
@openshift-ci openshift-ci bot requested review from dorzel and rxinui September 2, 2025 07:26
@adambkaplan
Copy link
Member

nit - it looks like you are using merge commits to keep this branch up to date. This makes it harder to identify which changes are net-new code.

Please use git rebase instead.

@hasanawad94 hasanawad94 force-pushed the add-pipelinerun-reconciliation branch from 5a94962 to edf6f28 Compare October 4, 2025 10:33
@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 4, 2025
@hasanawad94 hasanawad94 force-pushed the add-pipelinerun-reconciliation branch 3 times, most recently from 8f8d704 to 2c6d078 Compare October 5, 2025 07:19
@openshift-merge-robot openshift-merge-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 5, 2025
// Since we only have one task for now in our PipelineRun, we can use the first ChildReference.
// The pod name will be the same as the TaskRun name with a suffix.
firstTaskRef := t.PipelineRun.Status.ChildReferences[0]
return firstTaskRef.Name + "-pod"
Copy link
Member

Choose a reason for hiding this comment

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

Can the TaskRun name be too long so that Tekton does not append -pod but applies some additional magic to shorten it ? In general relying on an implementation detail of Tekton feels incorrect.

And general question: why do we return the name of the first Pod here ? In which context are we using this function (I guess maybe error reporting) and would it make sense to revisit those to see which pod name we should return here.

@hasanawad94 hasanawad94 force-pushed the add-pipelinerun-reconciliation branch 7 times, most recently from 15ffaa5 to 0d89f13 Compare October 8, 2025 12:15
@hasanawad94
Copy link
Contributor Author

Thanks for the review @SaschaSchwarze0. For the GetPodName() method its needed for the metrics collection.
I've removed that uncertain logic relying on the naming and moved it to fetch the pod name from the taskrun in the reconcile function incase of using pipelinerun

// For PipelineRuns, GetPodName() returns empty string, so we need to get the actual pod name
// from the underlying TaskRun. For now, there is only 1 TaskRun per PipelineRun, so we can
// safely use the first TaskRun to get the pod name.
if podName == "" && buildRunner.GetExecutorKind() == "PipelineRun" {
if taskRuns, err := buildRunner.GetUnderlyingTaskRuns(r.client); err == nil && len(taskRuns) > 0 {
podName = taskRuns[0].Status.PodName
}
}

This commit introduces PipelineRun support to the BuildRun
reconciler, enabling Shipwright to use Tekton PipelineRuns as an alternative
to TaskRuns for build execution.

Key changes:
- Add pipelinerun_runner.go with TektonPipelineRunWrapper implementation
  that wraps Tekton PipelineRuns and injects TaskRun specs into PipelineRun
  structures.
- Implement ImageBuildRunner and ImageBuildRunnerFactory interfaces for
  PipelineRun support.
- Add reconciliation logic for PipelineRun status updates, including
  condition handling and failure detection
- Add UpdateBuildRunUsingPipelineRunCondition function to update BuildRun
  status based on PipelineRun conditions (timeout, cancellation, success,
  failure)
- Refactor volume checking to use GetUnderlyingTaskRun() method for both
  TaskRun and PipelineRun executors, eliminating the need for separate
  volume checking methods
- Add RunnerFactories map to support configurable executor selection
  between TaskRun and PipelineRun implementations
- Update error handling in CreateImageBuildRunner
- Add UpdateImageBuildRunFromExecutor to handle updating Buildrun based on
  used executor (pipelinerun or taskrun)

The implementation maintains backward compatibility.

Signed-off-by: Hasan Awad <[email protected]>
@hasanawad94 hasanawad94 force-pushed the add-pipelinerun-reconciliation branch from 0d89f13 to 02f1aaa Compare October 15, 2025 08:38
@ayushsatyam146
Copy link
Member

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Oct 17, 2025
@ayushsatyam146
Copy link
Member

/approve

Copy link
Member

@adambkaplan adambkaplan left a comment

Choose a reason for hiding this comment

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

/approve

This PR has undergone sufficient review and has demonstrated thorough test coverage. Furthermore, the test suites ensure that the current TaskRun reconciliation behavior is enabled by default, and that PipelineRun reconciliation is gated by a feature flag.

I have a few nits around simplifying the make commands invoked for the integration and e2e testing, but these can be addressed in a followup PR/issue.

make test-integration
- name: Test-PipelineRun
run: |
BUILDRUN_EXECUTOR=PipelineRun ginkgo --focus-file="buildruns_to_pipelineruns_test.go" -v test/integration/...
Copy link
Member

Choose a reason for hiding this comment

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

nit (not blocking): ideally would like to have these be arguments to the make target, but I can live with this for now.

TEST_E2E_SERVICEACCOUNT_NAME=pipeline \
TEST_E2E_TIMEOUT_MULTIPLIER=${TEST_E2E_TIMEOUT_MULTIPLIER} \
TEST_E2E_VERIFY_TEKTONOBJECTS=true \
ginkgo --focus="PipelineRun E2E Tests" --procs 8 --timeout=1h --vv test/e2e/v1beta1/
Copy link
Member

Choose a reason for hiding this comment

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

nit (not blocking): ditto on incorporating this into the make target.

TerminationLogPath: terminationLogPathDefault,
GitRewriteRule: false,
VulnerabilityCountLimit: 50,
BuildrunExecutor: "TaskRun",
Copy link
Member

Choose a reason for hiding this comment

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

👍 on default value.

Comment on lines +367 to +370
// set environment variable for executor type
if executor := os.Getenv(controllerBuildrunExecutorEnvVar); executor != "" {
c.BuildrunExecutor = executor
}
Copy link
Member

Choose a reason for hiding this comment

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

nit (not blocking): ideally we should have some validation on this env var value and not accept it at face value.

--randomize-all \
--randomize-suites \
--fail-on-pending \
--skip-file=buildruns_to_pipelineruns_test.go \
Copy link
Member

Choose a reason for hiding this comment

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

nit (not blocking): we should use labels or other Ginkgo-native mechanisms for skipping these tests in the default integration and e2e test suites.

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Oct 22, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: adambkaplan, ayushsatyam146

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

The pull request process is described here

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

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 22, 2025
@openshift-merge-bot openshift-merge-bot bot merged commit b431ca8 into shipwright-io:main Oct 22, 2025
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/feature Categorizes issue or PR as related to a new feature. lgtm Indicates that a PR is ready to be merged. release-note Label for when a PR has specified a release note size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

6 participants