Add snapshot topology support for Immediate binding (KEP-5943) - #1552
Add snapshot topology support for Immediate binding (KEP-5943)#1552mdzraf wants to merge 1 commit into
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: mdzraf The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
05fccd2 to
3e6cc19
Compare
There was a problem hiding this comment.
Pull request overview
This PR adds alpha-gated support for VolumeSnapshot topology during Immediate volume binding by intersecting a snapshot’s topology constraints with StorageClass.AllowedTopologies, ensuring volumes restored from snapshots are provisioned where the snapshot is accessible (KEP-5943). It also temporarily vendors a fork of the external-snapshotter client to consume the new snapshot topology fields.
Changes:
- Introduces the
VolumeSnapshotTopologyfeature gate and wires it into provisioning to constrainCreateVolumeaccessibility requirements for snapshot-sourced PVCs with Immediate binding. - Adds
intersectSnapshotTopologylogic (plus unit tests) to compute the intersection of snapshotNodeAffinityandStorageClass.AllowedTopologies. - Vendors a forked external-snapshotter client containing new API fields (
VolumeSnapshotContentSpec.NodeAffinity,VolumeSnapshotClass.AllowedTopologies), and updates module replacement metadata.
Reviewed changes
Copilot reviewed 5 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| vendor/modules.txt | Updates vendoring metadata to reflect replacing external-snapshotter client with a fork. |
| vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumesnapshot/v1/zz_generated.deepcopy.go | Updates deepcopy generation for new snapshot API fields. |
| vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumesnapshot/v1/types.go | Adds new alpha topology fields to VolumeSnapshot API types (vendored). |
| pkg/features/features.go | Adds the VolumeSnapshotTopology feature gate definition and default state. |
| pkg/controller/topology.go | Implements snapshot/StorageClass topology intersection used for Immediate binding. |
| pkg/controller/snapshot_topology_test.go | Adds unit tests for intersectSnapshotTopology. |
| pkg/controller/controller.go | Threads snapshot NodeAffinity from VolumeSnapshotContent into provisioning and applies intersection when the feature gate is enabled. |
| go.sum | Updates checksums for the forked external-snapshotter client module. |
| go.mod | Adds a temporary replace to a forked external-snapshotter client pending upstream release. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| slices.SortFunc(intersected, topologyTerm.compare) | ||
| intersected = slices.CompactFunc(intersected, slices.Equal) | ||
| return toCSITopology(intersected) |
| // - A nil, empty result means the two constraints are incompatible; callers | ||
| // should treat this as a fatal provisioning error. |
| if utilfeature.DefaultFeatureGate.Enabled(features.VolumeSnapshotTopology) && | ||
| rc.snapshot && selectedNodeName == "" && len(snapshotNodeAffinity) > 0 { | ||
| intersected := intersectSnapshotTopology(sc.AllowedTopologies, snapshotNodeAffinity) | ||
| if len(intersected) == 0 { | ||
| return nil, controller.ProvisioningFinished, fmt.Errorf("no compatible topology: snapshot %s NodeAffinity does not intersect StorageClass %s AllowedTopologies, so the volume cannot be provisioned where the snapshot is accessible", dataSource.Name, sc.Name) | ||
| } | ||
| req.AccessibilityRequirements = &csi.TopologyRequirement{ | ||
| Requisite: intersected, | ||
| Preferred: intersected, | ||
| } | ||
| klog.V(2).Infof("prepareProvision: constrained snapshot-sourced PVC %s to %d topology terms from the intersection of snapshot NodeAffinity and StorageClass.AllowedTopologies", claim.Name, len(intersected)) | ||
| } |
What type of PR is this?
/kind feature
What this PR does / why we need it:
This PR introduces the changes necessary in the provisioner to be able to check for Volume Snapshot Topology and see if there is any intersection between the snapshot's
NodeAffinityandStorageClass.AllowedTopologies. This functionality is gated behind theVolumeSnapshotTopologyfeature gate.This is part of the implementation for kubernetes/enhancements#5943
Special notes for your reviewer:
/hold
As noted in the TODO comment, the current implementation references a custom fork of the external snapshotter and will be switched to the released version of it once the PR to introduce topology for volume snapshots is merged.
Does this PR introduce a user-facing change?: