Skip to content

fix: validate referenced volumes in PipelineRun executor before creation - #2341

Open
mohit-bhandari45 wants to merge 4 commits into
shipwright-io:mainfrom
mohit-bhandari45:fix-pipelinerun-volume-validation
Open

fix: validate referenced volumes in PipelineRun executor before creation#2341
mohit-bhandari45 wants to merge 4 commits into
shipwright-io:mainfrom
mohit-bhandari45:fix-pipelinerun-volume-validation

Conversation

@mohit-bhandari45

Copy link
Copy Markdown

Changes

The PipelineRun executor mode did not validate referenced volumes (Secrets, ConfigMaps, Projected volumes) before creating the PipelineRun resource in Kubernetes.

During reconciliation, validateExecutorVolumes called GetUnderlyingTaskRuns on the ImageBuildRunner. For a PipelineRun, GetUnderlyingTaskRuns inspects PipelineRun.Status.ChildReferences. However, before the PipelineRun is created in Kubernetes, Status.ChildReferences is empty, causing GetUnderlyingTaskRuns to return an empty list and volume validation to be completely skipped.

As a result, a Build or BuildRun referencing a non-existent Secret or ConfigMap would proceed to create the PipelineRun in Kubernetes instead of failing early with Reason: VolumeDoesNotExist.

Solution

  1. Extracted volume checking logic into a generic helper CheckVolumesExist(ctx, client, namespace, volumes) in resources/volumes.go.
  2. Added CheckPipelineRunVolumesExist(ctx, client, pipelineRun) to iterate over pipelineRun.Spec.PipelineSpec.Tasks (and .Finally) and validate embedded task volumes directly against Kubernetes before resource creation.
  3. Updated validateExecutorVolumes in buildrun.go to inspect the ImageBuildRunner type and validate TektonPipelineRunWrapper volumes directly.
  4. Added unit test coverage for volume helpers in resources/volumes_test.go and reconciler volume validation failure in buildrun_test.go.

Related Issue

Fixes #2325

Type of PR

/kind bug

Submitter Checklist

  • Includes tests if functionality changed/was added
  • Includes docs if changes are user-facing
  • Kind label has been set
  • Release notes block has been filled in, or marked NONE

Release Notes

Fixed an issue where the PipelineRun executor mode skipped pre-flight volume validation for missing Secrets and ConfigMaps before creating the PipelineRun resource.

@openshift-ci

openshift-ci Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@pull-request-size pull-request-size Bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Sep 7, 2026
@openshift-ci openshift-ci Bot added kind/bug Categorizes issue or PR as related to a bug. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Sep 7, 2026
@openshift-ci

openshift-ci Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign apoorvajagtap for approval. For more information see the Code Review Process.

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

@kaizakin

kaizakin commented Sep 7, 2026

Copy link
Copy Markdown
Member

@mohit-bhandari45 please sign your commits

Signed-off-by: mohit-bhandari45 <mohitbhandari852@gmail.com>
Signed-off-by: mohit-bhandari45 <mohitbhandari852@gmail.com>
Signed-off-by: mohit-bhandari45 <mohitbhandari852@gmail.com>
Signed-off-by: mohit-bhandari45 <mohitbhandari852@gmail.com>
@mohit-bhandari45
mohit-bhandari45 force-pushed the fix-pipelinerun-volume-validation branch from 00f26e5 to 3f480a4 Compare September 7, 2026 17:42
@mohit-bhandari45

Copy link
Copy Markdown
Author

@kaizakin Almost forget, done now.

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

Labels

do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. kind/bug Categorizes issue or PR as related to a bug. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

PipelineRun executor skips volume validation before creation

3 participants