Skip to content

Add snapshot topology support for Immediate binding (KEP-5943) - #1552

Open
mdzraf wants to merge 1 commit into
kubernetes-csi:masterfrom
mdzraf:snapshotTopologyPOC
Open

Add snapshot topology support for Immediate binding (KEP-5943)#1552
mdzraf wants to merge 1 commit into
kubernetes-csi:masterfrom
mdzraf:snapshotTopologyPOC

Conversation

@mdzraf

@mdzraf mdzraf commented Jul 29, 2026

Copy link
Copy Markdown
Member

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 NodeAffinity and StorageClass.AllowedTopologies. This functionality is gated behind the VolumeSnapshotTopology feature 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?:

Introduce VolumeSnapshotTopology Feature Gate Along with Functionality to Check for Topology Intersection

@kubernetes-prow kubernetes-prow Bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. 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. labels Jul 29, 2026
@kubernetes-prow kubernetes-prow Bot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jul 29, 2026
@kubernetes-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

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

@kubernetes-prow kubernetes-prow Bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jul 29, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 VolumeSnapshotTopology feature gate and wires it into provisioning to constrain CreateVolume accessibility requirements for snapshot-sourced PVCs with Immediate binding.
  • Adds intersectSnapshotTopology logic (plus unit tests) to compute the intersection of snapshot NodeAffinity and StorageClass.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.

Comment on lines +745 to +747
slices.SortFunc(intersected, topologyTerm.compare)
intersected = slices.CompactFunc(intersected, slices.Equal)
return toCSITopology(intersected)
Comment on lines +715 to +716
// - A nil, empty result means the two constraints are incompatible; callers
// should treat this as a fatal provisioning error.
Comment on lines +743 to +754
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))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. 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

None yet

Development

Successfully merging this pull request may close these issues.

2 participants