Skip to content

Add pvca webhook#1745

Draft
Kostov6 wants to merge 2 commits intogardener:masterfrom
Kostov6:enh/pvca-webhook
Draft

Add pvca webhook#1745
Kostov6 wants to merge 2 commits intogardener:masterfrom
Kostov6:enh/pvca-webhook

Conversation

@Kostov6
Copy link
Copy Markdown
Contributor

@Kostov6 Kostov6 commented Mar 30, 2026

How to categorize this PR?

/area storage
/kind enhancement
/platform aws

What this PR does / why we need it:

TBD

Which issue(s) this PR fixes:
Fixes #

Special notes for your reviewer:

Release note:


@gardener-prow gardener-prow bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. area/storage Storage related kind/enhancement Enhancement, improvement, extension cla: yes Indicates the PR's author has signed the cla-assistant.io CLA. labels Mar 30, 2026
@gardener-prow
Copy link
Copy Markdown

gardener-prow bot commented Mar 30, 2026

[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 matthias-horne 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

@gardener-prow gardener-prow bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Mar 30, 2026
@federated-github-access federated-github-access bot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. and removed ok-to-test Indicates a non-member PR verified by an org member that is safe to test. labels Mar 30, 2026
@github-actions
Copy link
Copy Markdown
Contributor

This change integrates PVC (Persistent Volume Claim) autoscaling capability into the AWS Gardener extension by adding a new dependency and implementing a webhook that automatically sets default cooldown periods for PVC autoscaler resources in shoot clusters.

Walkthrough

  • New Feature: Added PVC autoscaler integration with automatic cooldown duration defaulting for volume scaling policies
  • New Feature: Implemented webhook system to mutate PersistentVolumeClaimAutoscaler resources in shoot clusters
  • Chore: Added pvc-autoscaler dependency to support new autoscaling functionality
  • Test: Added comprehensive test coverage for the new webhook mutator functionality

The webhook ensures that when PVC autoscaler resources are created without explicit cooldown durations, they automatically receive a 6-hour default cooldown period to prevent excessive scaling operations.

Model: claude-sonnet-4-20250514 | Prompt Tokens: 4342 | Completion Tokens: 190

@federated-github-access federated-github-access bot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed ok-to-test Indicates a non-member PR verified by an org member that is safe to test. labels Mar 30, 2026
Copy link
Copy Markdown
Contributor

@plkokanov plkokanov left a comment

Choose a reason for hiding this comment

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

The provider-aws extension can be installed on all types of seeds (gcp, azure, etc) depending on the required DNSRecord type and the cloud provider of the hosted shoots. We have to make sure that the aws-specific PVCA mutation does not happen in such cases.
You can check how this is done here, although I'm not sure if there's a better way to do it. For instance, the seedprovider webhook has a namespace selector that only selects shoot control plane namespaces labeled with seed.gardener.cloud/provider=aws. One thing to note is that the PVCA webhook also has to select resources from the garden namespace.

//
// SPDX-License-Identifier: Apache-2.0

package shootpvca
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is a webhook that runs in the seed and targets resources in the garden and shoot control plane namespaces. I think having shoot in the name is confusing and should be changed also for other occurrences in these files.

return nil, err
}

// This webhook should apply to all namespaces in the shoot cluster.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This webhook should have nothing to do with namespaces in the shoot cluster.

Comment on lines +39 to +44
for i := range pvca.Spec.VolumePolicies {
if pvca.Spec.VolumePolicies[i].ScaleUp != nil &&
pvca.Spec.VolumePolicies[i].ScaleUp.CooldownDuration == nil {
pvca.Spec.VolumePolicies[i].ScaleUp.CooldownDuration = defaultCooldownDuration.DeepCopy()
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We always have to ensure that the CooldownDuration is at least 6 hours, meaning that if it was already set to something smaller, we should overwrite it.

"sigs.k8s.io/controller-runtime/pkg/client"
)

var defaultCooldownDuration = &metav1.Duration{Duration: 6 * time.Hour}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit:

Suggested change
var defaultCooldownDuration = &metav1.Duration{Duration: 6 * time.Hour}
const minCooldownDuration = 6 * time.Hour

Then something like

pvca.Spec.VolumePolicies[i].ScaleUp.CooldownDuration = &metav1.Duration{Duration: minCooldownDuration}

@gardener-prow
Copy link
Copy Markdown

gardener-prow bot commented Mar 31, 2026

@plkokanov: adding LGTM is restricted to approvers and reviewers in OWNERS files.

Details

In response to this:

The provider-aws extension can be installed on all types of seeds (gcp, azure, etc) depending on the required DNSRecord type and the cloud provider of the hosted shoots. We have to make sure that the aws-specific PVCA mutation does not happen in such cases.
You can check how this is done here, although I'm not sure if there's a better way to do it. For instance, the seedprovider webhook has a namespace selector that only selects shoot control plane namespaces labeled with seed.gardener.cloud/provider=aws. One thing to note is that the PVCA webhook also has to select resources from the garden namespace.

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.

@gardener-prow gardener-prow bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 7, 2026
@gardener-prow
Copy link
Copy Markdown

gardener-prow bot commented Apr 7, 2026

PR needs rebase.

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.

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

Labels

area/storage Storage related cla: yes Indicates the PR's author has signed the cla-assistant.io CLA. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. kind/enhancement Enhancement, improvement, extension needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants