Skip to content

Add ControllerServer.GetSnapshot CSI procedure #606

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

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ spec:
serviceAccountName: csi-attacher
containers:
- name: csi-attacher
image: registry.k8s.io/sig-storage/csi-attacher:v4.8.0
image: registry.k8s.io/sig-storage/csi-attacher:v4.8.1
args:
- --v=5
- --csi-address=/csi/csi.sock
Expand Down
4 changes: 2 additions & 2 deletions deploy/kubernetes-1.30-test/hostpath/csi-hostpath-plugin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ spec:
- --health-port=9898

- name: csi-external-health-monitor-controller
image: registry.k8s.io/sig-storage/csi-external-health-monitor-controller:v0.14.0
image: registry.k8s.io/sig-storage/csi-external-health-monitor-controller:v0.15.0
args:
- "--v=5"
- "--csi-address=$(ADDRESS)"
Expand All @@ -97,7 +97,7 @@ spec:
mountPath: /csi

- name: node-driver-registrar
image: registry.k8s.io/sig-storage/csi-node-driver-registrar:v2.13.0
image: registry.k8s.io/sig-storage/csi-node-driver-registrar:v2.14.0
args:
- --v=5
- --csi-address=/csi/csi.sock
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ spec:
serviceAccountName: csi-provisioner
containers:
- name: csi-provisioner
image: registry.k8s.io/sig-storage/csi-provisioner:v5.2.0
image: registry.k8s.io/sig-storage/csi-provisioner:v5.3.0
args:
- -v=5
- --csi-address=/csi/csi.sock
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ spec:
serviceAccountName: csi-resizer
containers:
- name: csi-resizer
image: registry.k8s.io/sig-storage/csi-resizer:v1.13.1
image: registry.k8s.io/sig-storage/csi-resizer:v1.13.2
args:
- -v=5
- -csi-address=/csi/csi.sock
Expand Down
12 changes: 6 additions & 6 deletions deploy/kubernetes-1.30/hostpath/csi-hostpath-plugin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ spec:
name: dev-dir

- name: csi-external-health-monitor-controller
image: registry.k8s.io/sig-storage/csi-external-health-monitor-controller:v0.14.0
image: registry.k8s.io/sig-storage/csi-external-health-monitor-controller:v0.15.0
args:
- "--v=5"
- "--csi-address=$(ADDRESS)"
Expand All @@ -295,7 +295,7 @@ spec:
mountPath: /csi

- name: node-driver-registrar
image: registry.k8s.io/sig-storage/csi-node-driver-registrar:v2.13.0
image: registry.k8s.io/sig-storage/csi-node-driver-registrar:v2.14.0
args:
- --v=5
- --csi-address=/csi/csi.sock
Expand Down Expand Up @@ -329,7 +329,7 @@ spec:
- --health-port=9898

- name: csi-attacher
image: registry.k8s.io/sig-storage/csi-attacher:v4.8.0
image: registry.k8s.io/sig-storage/csi-attacher:v4.8.1
args:
- --v=5
- --csi-address=/csi/csi.sock
Expand All @@ -343,7 +343,7 @@ spec:
name: socket-dir

- name: csi-provisioner
image: registry.k8s.io/sig-storage/csi-provisioner:v5.2.0
image: registry.k8s.io/sig-storage/csi-provisioner:v5.3.0
args:
- -v=5
- --csi-address=/csi/csi.sock
Expand All @@ -359,7 +359,7 @@ spec:
name: socket-dir

- name: csi-resizer
image: registry.k8s.io/sig-storage/csi-resizer:v1.13.1
image: registry.k8s.io/sig-storage/csi-resizer:v1.13.2
args:
- -v=5
- -csi-address=/csi/csi.sock
Expand All @@ -373,7 +373,7 @@ spec:
name: socket-dir

- name: csi-snapshotter
image: registry.k8s.io/sig-storage/csi-snapshotter:v8.2.0
image: registry.k8s.io/sig-storage/csi-snapshotter:v8.2.1
args:
- -v=5
- --csi-address=/csi/csi.sock
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ spec:
serviceAccountName: csi-provisioner
containers:
- name: csi-provisioner
image: registry.k8s.io/sig-storage/csi-provisioner:v5.2.0
image: registry.k8s.io/sig-storage/csi-provisioner:v5.3.0
args:
- -v=5
- --csi-address=/csi/csi.sock
Expand Down Expand Up @@ -60,7 +60,7 @@ spec:
name: socket-dir

- name: node-driver-registrar
image: registry.k8s.io/sig-storage/csi-node-driver-registrar:v2.12.0
image: registry.k8s.io/sig-storage/csi-node-driver-registrar:v2.14.0
args:
- --v=5
- --csi-address=/csi/csi.sock
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.24.0
toolchain go1.24.3

require (
github.com/container-storage-interface/spec v1.11.0
github.com/container-storage-interface/spec v1.11.1-0.20250515121015-a539b4f9fe41
github.com/kubernetes-csi/csi-lib-utils v0.20.0
github.com/pborman/uuid v1.2.1
github.com/stretchr/testify v1.10.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ github.com/blang/semver/v4 v4.0.0 h1:1PFHFE6yCCTv8C1TeyNNarDzntLi7wMI5i/pzqYIsAM
github.com/blang/semver/v4 v4.0.0/go.mod h1:IbckMUScFkM3pff0VJDNKRiT6TG/YpiHIM2yvyW5YoQ=
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/container-storage-interface/spec v1.11.0 h1:H/YKTOeUZwHtyPOr9raR+HgFmGluGCklulxDYxSdVNM=
github.com/container-storage-interface/spec v1.11.0/go.mod h1:DtUvaQszPml1YJfIK7c00mlv6/g4wNMLanLgiUbKFRI=
github.com/container-storage-interface/spec v1.11.1-0.20250515121015-a539b4f9fe41 h1:7+UfUxukJlnEVGALQzUcCYXP/ISyS/VZJ7DPpAQxROY=
github.com/container-storage-interface/spec v1.11.1-0.20250515121015-a539b4f9fe41/go.mod h1:DtUvaQszPml1YJfIK7c00mlv6/g4wNMLanLgiUbKFRI=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/fxamacker/cbor/v2 v2.7.0 h1:iM5WgngdRBanHcxugY4JySA0nk1wZorNOpTgCMedv5E=
Expand Down
34 changes: 34 additions & 0 deletions pkg/hostpath/controllerserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,39 @@ func (hp *hostPath) ListSnapshots(ctx context.Context, req *csi.ListSnapshotsReq
}, nil
}

func (hp *hostPath) GetSnapshot(ctx context.Context, req *csi.GetSnapshotRequest) (*csi.GetSnapshotResponse, error) {
if err := hp.validateControllerServiceRequest(csi.ControllerServiceCapability_RPC_GET_SNAPSHOT); err != nil {
klog.V(3).Infof("invalid get snapshot req: %v", req)
return nil, err
}

// Lock before acting on global state. A production-quality
// driver might use more fine-grained locking.
hp.mutex.Lock()
defer hp.mutex.Unlock()

// case 1: SnapshotId is not empty, return snapshots that match the snapshot id,
// none if not found.
if len(req.GetSnapshotId()) == 0 {
}

snapshotID := req.SnapshotId
snapshot, err := hp.state.GetSnapshotByID(snapshotID)
if err != nil {
return nil, status.Errorf(codes.NotFound, "Snapshot with ID %q not found: %v", snapshotID, err)
}

return &csi.GetSnapshotResponse{
Snapshot: &csi.Snapshot{
SnapshotId: snapshot.Id,
SourceVolumeId: snapshot.VolID,
CreationTime: snapshot.CreationTime,
SizeBytes: snapshot.SizeBytes,
ReadyToUse: snapshot.ReadyToUse,
},
}, nil
}

func (hp *hostPath) ControllerExpandVolume(ctx context.Context, req *csi.ControllerExpandVolumeRequest) (*csi.ControllerExpandVolumeResponse, error) {
if !hp.config.EnableVolumeExpansion {
return nil, status.Error(codes.Unimplemented, "ControllerExpandVolume is not supported")
Expand Down Expand Up @@ -878,6 +911,7 @@ func (hp *hostPath) getControllerServiceCapabilities() []*csi.ControllerServiceC
csi.ControllerServiceCapability_RPC_GET_CAPACITY,
csi.ControllerServiceCapability_RPC_CREATE_DELETE_SNAPSHOT,
csi.ControllerServiceCapability_RPC_LIST_SNAPSHOTS,
csi.ControllerServiceCapability_RPC_GET_SNAPSHOT,
csi.ControllerServiceCapability_RPC_LIST_VOLUMES,
csi.ControllerServiceCapability_RPC_CLONE_VOLUME,
csi.ControllerServiceCapability_RPC_VOLUME_CONDITION,
Expand Down
4 changes: 2 additions & 2 deletions release-tools/prow.sh
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,8 @@ configvar CSI_PROW_SIDECAR_E2E_PATH "${CSI_PROW_SIDECAR_E2E_IMPORT_PATH}" "CSI S
# csi.sock as a TCP service for use by the csi-sanity command, which runs outside
# of the cluster. The alternative would have been to (cross-)compile csi-sanity
# and install it inside the cluster, which is not necessarily easier.
configvar CSI_PROW_SANITY_REPO https://github.com/kubernetes-csi/csi-test "csi-test repo"
configvar CSI_PROW_SANITY_VERSION v5.3.1 "csi-test version"
configvar CSI_PROW_SANITY_REPO https://github.com/nixpanic/csi-test "csi-test repo"
configvar CSI_PROW_SANITY_VERSION GetSnapshot "csi-test version"
configvar CSI_PROW_SANITY_PACKAGE_PATH github.com/kubernetes-csi/csi-test "csi-test package"
configvar CSI_PROW_SANITY_SERVICE "hostpath-service" "Kubernetes TCP service name that exposes csi.sock"
configvar CSI_PROW_SANITY_POD "csi-hostpathplugin-0" "Kubernetes pod with CSI driver"
Expand Down
Loading