Skip to content

Do not fail PipelineRun if pvc creation error is because of exceeded quotas #8903

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

vdemeester
Copy link
Member

Changes

In case of the PVC creation (from volumeclaimtemplate) is due to a
quota error (quota exceeded), do not fail with a permanent error, and
instead mark the PipelineRun as pending. Once there is some quota
available back, it will be able to start.

Signed-off-by: Vincent Demeester vdemeest@redhat.com

Closes #7672

/kind feature

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

PipelineRun do not fail anymore if the pvc creation is due to an exceeded quota ; it will be requeued instead (until quota is available or it times out)

@tekton-robot tekton-robot added the release-note Denotes a PR that will be considered when it comes time to generate release notes. label Jul 22, 2025
@tekton-robot tekton-robot added the kind/feature Categorizes issue or PR as related to a new feature. label Jul 22, 2025
@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.

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/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Jul 22, 2025
@vdemeester
Copy link
Member Author

/wip
I need to update/create some e2e tests and makes sure it times out.

@vdemeester vdemeester added this to the v1.3.0 (LTS) milestone Jul 22, 2025
@vdemeester vdemeester force-pushed the 7672-retry-pvc-quota branch from 4a5edbf to 52464a8 Compare July 22, 2025 10:53
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage-df to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/pipelinerun/pipelinerun.go 91.6% 91.2% -0.4
pkg/reconciler/volumeclaim/pvchandler.go 83.7% 77.4% -6.3

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage-df to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/pipelinerun/pipelinerun.go 91.6% 91.2% -0.4
pkg/reconciler/volumeclaim/pvchandler.go 83.7% 77.4% -6.3

@vdemeester
Copy link
Member Author

/hold

@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 Jul 23, 2025
…quotas

In case of the PVC creation (from volumeclaimtemplate) is due to a
quota error (quota exceeded), do not fail with a permanent error, and
instead mark the PipelineRun as pending. Once there is some quota
available back, it will be able to start.

Signed-off-by: Vincent Demeester <vdemeest@redhat.com>
@vdemeester vdemeester force-pushed the 7672-retry-pvc-quota branch from 52464a8 to 6b0c7ae Compare July 23, 2025 09:22
@tekton-robot tekton-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jul 23, 2025
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage-df to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/pipelinerun/pipelinerun.go 91.6% 91.2% -0.4
pkg/reconciler/volumeclaim/pvchandler.go 83.7% 77.4% -6.3

@vdemeester
Copy link
Member Author

/retest

@vdemeester
Copy link
Member Author

Timeout is taken into account 👼🏼

@twoGiants
Copy link
Member

/assign

@twoGiants
Copy link
Member

/cc @twoGiants

@tekton-robot tekton-robot requested a review from twoGiants July 24, 2025 15:44
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.

Good job, it makes sense to set the status to pending and let it retry 😸 👍.

Now it will re-queue right away. Do you want to make it configurable at some point like suggested in the issue?

My comments are below. I would add unit tests, simplify the conditional logic and remove the re-declaration of the errors in affinity_assistant.go.

@@ -73,14 +80,20 @@ func (c *defaultPVCHandler) CreatePVCFromVolumeClaimTemplate(ctx context.Context
if apierrors.IsAlreadyExists(err) {
Copy link
Member

Choose a reason for hiding this comment

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

Optional: We could use the chance to untangle the conditions a bit. If you pick this suggestion the comment right below can be skipped :).

Suggested change
if apierrors.IsAlreadyExists(err) {
_, getErr := c.clientset.CoreV1().PersistentVolumeClaims(claim.Namespace).Get(ctx, claim.Name, metav1.GetOptions{})
switch {
case apierrors.IsNotFound(getErr):
_, createErr := c.clientset.CoreV1().PersistentVolumeClaims(claim.Namespace).Create(ctx, claim, metav1.CreateOptions{})
if createErr == nil {
c.logger.Infof("Created PersistentVolumeClaim %s in namespace %s", claim.Name, claim.Namespace)
return nil
}
if apierrors.IsAlreadyExists(createErr) {
c.logger.Infof("Tried to create PersistentVolumeClaim %s in namespace %s, but it already exists",
claim.Name, claim.Namespace)
return nil
}
// This is a retry-able error
if apierrors.IsForbidden(createErr) && strings.Contains(createErr.Error(), "exceeded quota") {
return fmt.Errorf("%w: %v", ErrPvcCreationFailedRetryable, createErr.Error())
}
return fmt.Errorf("%w for %s: %w", ErrPvcCreationFailed, claim.Name, createErr)
case getErr != nil:
return fmt.Errorf("%w: failed to retrieve PVC %s: %w", ErrPvcCreationFailed, claim.Name, getErr)
}
}

// This is a retry-able error
return fmt.Errorf("%w: %v", ErrPvcCreationFailedRetryable, err.Error())
}
return fmt.Errorf("%w for %s: %w", ErrPvcCreationFailed, claim.Name, err)
Copy link
Member

Choose a reason for hiding this comment

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

This return and the one in the else right after can be simplified.

Suggested change
return fmt.Errorf("%w for %s: %w", ErrPvcCreationFailed, claim.Name, err)
} else if apierrors.IsForbidden(err) && strings.Contains(err.Error(), "exceeded quota") {
// This is a retry-able error
return fmt.Errorf("%w: %v", ErrPvcCreationFailedRetryable, err.Error())
}
return fmt.Errorf("%w for %s: %w", ErrPvcCreationFailed, claim.Name, err)

Copy link
Member

Choose a reason for hiding this comment

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

Unit tests for the new conditional logic in CreatePVCFromVolumeClaimTemplate should be added.

@@ -50,7 +50,8 @@ const (
)

var (
ErrPvcCreationFailed = errors.New("PVC creation error")
ErrPvcCreationFailed = volumeclaim.ErrPvcCreationFailed
Copy link
Member

Choose a reason for hiding this comment

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

I wouldn't re-declare them here if they are already declared in volumeclaim and public. You don't use them in this file anyway.

@@ -577,54 +577,56 @@ func TestCreateOrUpdateAffinityAssistantsAndPVCs_Failure(t *testing.T) {
name: "pvc creation failed - per workspace",
failureType: "pvc",
aaBehavior: aa.AffinityAssistantPerWorkspace,
expectedErr: fmt.Errorf("%w: failed to create PVC pvc-b9eea16dce: error creating persistentvolumeclaims", ErrPvcCreationFailed),
expectedErr: fmt.Errorf("%w for pvc-b9eea16dce: error creating persistentvolumeclaims", ErrPvcCreationFailed),
Copy link
Member

Choose a reason for hiding this comment

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

You could use volumeclaim.ErrPvcCreationFailed instead, then you don't need to re-declare them in affinity_assistant.go.

@@ -755,6 +755,10 @@ func (c *Reconciler) reconcile(ctx context.Context, pr *v1.PipelineRun, getPipel
pr.Status.MarkFailed(volumeclaim.ReasonCouldntCreateWorkspacePVC,
"Failed to create PVC for PipelineRun %s/%s correctly: %s",
pr.Namespace, pr.Name, err)
case errors.Is(err, ErrPvcCreationFailedRetryable):
Copy link
Member

Choose a reason for hiding this comment

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

Here I would also use it from volumeclaim.ErrPvcCreationFailed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. kind/feature Categorizes issue or PR as related to a new feature. 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.

volumeClaimTemplate and exceeded quota for PVC (and requeues ?)
3 participants