Skip to content

Fix PVC cleanup between on-cluster builds#3676

Open
Itx-Psycho0 wants to merge 1 commit intoknative:mainfrom
Itx-Psycho0:fix/3516-clean-pvc-between-builds
Open

Fix PVC cleanup between on-cluster builds#3676
Itx-Psycho0 wants to merge 1 commit intoknative:mainfrom
Itx-Psycho0:fix/3516-clean-pvc-between-builds

Conversation

@Itx-Psycho0
Copy link
Copy Markdown

Problem

This PR addresses issue #3516, where the PersistentVolumeClaim used for on-cluster builds was being reused without cleanup, causing 'No space left on device' errors after multiple builds.

Solution

The fix ensures that each build starts with a clean PVC by deleting and recreating it before each build. This approach is simpler and more reliable than trying to clean up the PVC contents while it's in use.

Changes

  • Added DeletePersistentVolumeClaim() function in pkg/k8s/persistent_volumes.go to delete a single PVC by name
  • Added WaitForPVCDeletion() function in pkg/k8s/persistent_volumes.go to wait for complete PVC deletion (not just Terminating state)
  • Modified createPipelinePersistentVolumeClaim() in pkg/pipelines/tekton/pipelines_provider.go to:
    1. Check if PVC exists
    2. Delete it if found (ignoring NotFound errors)
    3. Wait for complete deletion
    4. Create a fresh PVC
  • Updated tests in pkg/pipelines/tekton/pipelines_provider_test.go to properly mock the new k8s functions

Testing

  • All unit tests pass
  • Linting checks pass
  • Added test cases for:
    • Successful deletion and recreation when PVC exists
    • Error handling when deletion fails
    • Error handling when waiting for deletion fails

Fixes #3516

This commit addresses issue knative#3516 where the PersistentVolumeClaim used
for on-cluster builds was being reused without cleanup, causing 'No
space left on device' errors after multiple builds.

Changes:
- Added DeletePersistentVolumeClaim() function to delete a single PVC
- Added WaitForPVCDeletion() function to wait for complete PVC deletion
- Modified createPipelinePersistentVolumeClaim() to delete existing PVC
  before creating a fresh one, ensuring clean workspace for each build
- Updated tests to properly mock the new k8s functions

The solution ensures that each build starts with a clean PVC by:
1. Checking if PVC exists
2. Deleting it if found (ignoring NotFound errors)
3. Waiting for complete deletion (not just Terminating state)
4. Creating a fresh PVC

This approach is simpler and more reliable than trying to clean up
the PVC contents while it's in use.
@knative-prow knative-prow Bot requested review from dsimansk and jrangelramos May 7, 2026 22:00
@knative-prow
Copy link
Copy Markdown

knative-prow Bot commented May 7, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Itx-Psycho0
Once this PR has been reviewed and has the lgtm label, please assign dprotaso 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

@knative-prow knative-prow Bot added size/L 🤖 PR changes 100-499 lines, ignoring generated files. needs-ok-to-test 🤖 Needs an org member to approve testing labels May 7, 2026
@knative-prow
Copy link
Copy Markdown

knative-prow Bot commented May 7, 2026

Hi @Itx-Psycho0. Thanks for your PR.

I'm waiting for a knative member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

@Itx-Psycho0
Copy link
Copy Markdown
Author

Hi maintainers,

I've implemented a fix for issue #3516 that addresses the PVC space exhaustion problem during on-cluster builds. The solution deletes and recreates the PVC before each build to ensure a clean workspace.

All unit tests and linting checks pass. I'd appreciate your review when you have a chance.

@lkingland @matejvasek @jrangelramos @gauron99

Thanks!

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

Labels

needs-ok-to-test 🤖 Needs an org member to approve testing size/L 🤖 PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

On-cluster build PersistentVolume fills up across builds

1 participant