Skip to content
Merged
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
23 changes: 17 additions & 6 deletions .github/workflows/integration-test.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
name: Intergration test
name: Integration test

on:
pull_request
Expand All @@ -26,8 +26,8 @@ jobs:

- name: Build csi-snapshot-metadata container image
run: |
# make build-csi-snapshot-metadata
# minikube image build -f ./cmd/csi-snapshot-metadata/Dockerfile -t gcr.io/k8s-staging-sig-storage/csi-snapshot-metadata:test .
make build-csi-snapshot-metadata
minikube image build -f ./cmd/csi-snapshot-metadata/Dockerfile -t gcr.io/k8s-staging-sig-storage/csi-snapshot-metadata:test .

- name: Deploy snapshot-controller
run: |
Expand All @@ -46,7 +46,7 @@ jobs:

git clone https://github.com/kubernetes-csi/csi-driver-host-path.git ~/csi-driver-host-path

CSI_SNAPSHOT_METADATA_REGISTRY="gcr.io/k8s-staging-sig-storage" UPDATE_RBAC_RULES="false" CSI_SNAPSHOT_METADATA_TAG="main" SNAPSHOT_METADATA_TESTS=true HOSTPATHPLUGIN_REGISTRY="gcr.io/k8s-staging-sig-storage" HOSTPATHPLUGIN_TAG="canary" ~/csi-driver-host-path/deploy/kubernetes-latest/deploy.sh
CSI_SNAPSHOT_METADATA_REGISTRY="gcr.io/k8s-staging-sig-storage" UPDATE_RBAC_RULES="false" CSI_SNAPSHOT_METADATA_TAG="test" SNAPSHOT_METADATA_TESTS=true HOSTPATHPLUGIN_REGISTRY="gcr.io/k8s-staging-sig-storage" HOSTPATHPLUGIN_TAG="canary" ~/csi-driver-host-path/deploy/kubernetes-latest/deploy.sh

kubectl apply -f ./deploy/example/csi-driver/testdata/

Expand Down Expand Up @@ -160,12 +160,23 @@ jobs:
kubectl cp ./snapshot-metadata-lister default/backup-app-client:/snapshot-metadata-lister -c run-client
kubectl cp ./snapshot-metadata-verifier default/backup-app-client:/snapshot-metadata-verifier -c run-client

echo "Execute external-snapshot-metadata-client to list changed blocks between snap-1 and snap-2"
echo "Execute external-snapshot-metadata-client to list changed blocks between snap-1 and snap-2 using snapshot names"
kubectl exec backup-app-client -- /snapshot-metadata-lister -max-results 10 -previous-snapshot snap-1 -snapshot snap-2 -starting-offset 0 -namespace default -kubeconfig=""

echo "Execute external-snapshot-metadata-client to verify the data between snap-1 and snap-2"
VSC_NAME=`kubectl get volumesnapshot snap-1 -o jsonpath="{.status.boundVolumeSnapshotContentName}"`
echo "VolumeSnapshotContent for VolumeSnapshot snap-1 is [$VSC_NAME]"
SNAP_HANDLE=`kubectl get volumesnapshotcontent $VSC_NAME -o jsonpath="{.status.snapshotHandle}"`
echo "CSI snapshot handle of VolumeSnapshot snap-1 is [$SNAP_HANDLE]"

echo "Execute external-snapshot-metadata-client to list changed blocks between snap-1 and snap-2 using the CSI handle"
kubectl exec backup-app-client -- /snapshot-metadata-lister -max-results 10 -previous-snapshot-id "$SNAP_HANDLE" -snapshot snap-2 -starting-offset 0 -namespace default -kubeconfig=""

echo "Execute external-snapshot-metadata-client to verify the data between snap-1 and snap-2 using snapshot names"
kubectl exec backup-app-client -- /snapshot-metadata-verifier -max-results 10 -previous-snapshot snap-1 -snapshot snap-2 -starting-offset 0 -namespace default -kubeconfig="" -source-device-path /dev/source -target-device-path /dev/target

echo "Execute external-snapshot-metadata-client to verify the data between snap-1 and snap-2 using the CSI handle"
kubectl exec backup-app-client -- /snapshot-metadata-verifier -max-results 10 -previous-snapshot-id "$SNAP_HANDLE" -snapshot snap-2 -starting-offset 0 -namespace default -kubeconfig="" -source-device-path /dev/source -target-device-path /dev/target

echo "Write more data into source-device to test negative case"
kubectl exec -i backup-app-client -- sh -c "dd if=/dev/urandom of=/dev/source bs=4K count=6 oflag=direct"

Expand Down
15 changes: 12 additions & 3 deletions examples/snapshot-metadata-lister/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,26 @@ const (

%[1]s -n Namespace -s Snapshot [Additional flags ...]

2. Display changed block metadata between two snapshots
2. Display changed block metadata between two snapshots, using the previous snapshot object name

%[1]s -n Namespace -s Snapshot -p PreviousSnapshot [Additional flags ...]

3. Display the full help message
3. Display changed block metadata between two snapshots, using the CSI handle of the previous snapshot

%[1]s -n Namespace -s Snapshot -P PreviousSnapshotID [Additional flags ...]

4. Display the full help message

%[1]s -h
`
usageFmt = `This command displays metadata on the content of a VolumeSnapshot object.
If a previous VolumeSnapshot object is also specified then the metadata
describes the content changes between the two snapshots, which must both
be from the same PersistentVolume.
be from the same PersistentVolume. The previous VolumeSnapshot object can
be specified either by name or by its CSI snapshot handle, obtained from
the Status.SnapshotHandle field of its associated VolumeSnapshotContent
object. The CSI handle takes precedence over the name, in case both are
specified.

The command is usually invoked in a Pod in the cluster, as the gRPC client
needs to resolve the DNS address in the SnapshotMetadataService CR.
Expand All @@ -75,6 +83,7 @@ func parseFlags() {

stringFlag(&args.Namespace, "namespace", "n", "", "The Namespace containing the VolumeSnapshot objects.")
stringFlag(&args.SnapshotName, "snapshot", "s", "", "The name of the VolumeSnapshot for which metadata is to be displayed.")
stringFlag(&args.PrevSnapshotID, "previous-snapshot-id", "P", "", "The CSI handle of an earlier VolumeSnapshot against which changed block metadata is to be displayed.")
Copy link
Contributor

Choose a reason for hiding this comment

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

Just capital "P" maybe a bit confusion, how about p-id or something else?

Copy link
Contributor Author

@carlbraganza carlbraganza Sep 23, 2025

Choose a reason for hiding this comment

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

The P is the short flag and was chosen because the short flag for the name is p. The long flag is -previous-snapshot-id.

stringFlag(&args.PrevSnapshotName, "previous-snapshot", "p", "", "The name of an earlier VolumeSnapshot against which changed block metadata is to be displayed.")
stringFlag(&outputFormat, "output-format", "o", "table", "The format of the output. Possible values: \"table\" or \"json\".")

Expand Down
20 changes: 15 additions & 5 deletions examples/snapshot-metadata-verifier/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,26 @@ const (

%[1]s -n Namespace -s Snapshot -src /dev/source -tgt /dev/target [Additional flags ...]

2. Verify changed block metadata between two snapshots
2. Verify changed block metadata between two snapshots, using the previous snapshot object name

%[1]s -n Namespace -s Snapshot -p PreviousSnapshot -src /dev/source -tgt /dev/target [Additional flags ...]

3. Display the full help message
3. Verify changed block metadata between two snapshots, using the CSI handle of the previous snapshot

%[1]s -n Namespace -s Snapshot -P PreviousSnapshotID -src /dev/source -tgt /dev/target [Additional flags ...]


4. Display the full help message

%[1]s -h
`
usageFmt = `This command verifies allocated blocks of a VolumeSnapshot object.
If a previous VolumeSnapshot object is also specified then changed blocks between
the two snapshots, which must both be from the same PersistentVolume, are verified.
The previous VolumeSnapshot object can be specified either by name or by its CSI
snapshot handle, obtained from the Status.SnapshotHandle field of its associated
VolumeSnapshotContent object. The CSI handle takes precedence over the name, in
case both are specified.

The command is usually invoked in a Pod in the cluster, as the gRPC client
needs to resolve the DNS address in the SnapshotMetadataService CR.
Expand All @@ -73,10 +82,11 @@ func parseFlags() {
}

stringFlag(&args.Namespace, "namespace", "n", "", "The Namespace containing the VolumeSnapshot objects.")
stringFlag(&args.SnapshotName, "snapshot", "s", "", "The name of the VolumeSnapshot for which metadata is to be displayed.")
stringFlag(&args.PrevSnapshotName, "previous-snapshot", "p", "", "The name of an earlier VolumeSnapshot against which changed block metadata is to be displayed.")
stringFlag(&args.SnapshotName, "snapshot", "s", "", "The name of the VolumeSnapshot for which metadata is to be verified.")
stringFlag(&args.PrevSnapshotID, "previous-snapshot-id", "P", "", "The CSI handle of an earlier VolumeSnapshot against which changed block metadata is to be verified.")
stringFlag(&args.PrevSnapshotName, "previous-snapshot", "p", "", "The name of an earlier VolumeSnapshot against which changed block metadata is to be verified.")
stringFlag(&sourceDevicePath, "source-device-path", "src", "", "Path of the source device. This device should be the PVC in block mode restored from the snapshot which is passed as the '-snapshot' flag.")
stringFlag(&targetDevicePath, "target-device-path", "tgt", "", "Path of the target device. This device should be a PVC in block mode restored from the snapshot which is passed as the '-previous-snapshot' flag or a fresh PVC in block mode in case the flag is not passed.")
stringFlag(&targetDevicePath, "target-device-path", "tgt", "", "Path of the target device. This device should be a PVC in block mode restored from the snapshot which is passed as the '-previous-snapshot' or '-previous-snapshot-id' flags, or a fresh PVC in block mode in case the flags are not passed.")

if home := homedir.HomeDir(); home != "" {
flag.StringVar(&kubeConfig, "kubeconfig", filepath.Join(home, ".kube", "config"), "Path to the kubeconfig file.")
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ require (
k8s.io/apiserver v0.34.0
k8s.io/client-go v0.34.0
k8s.io/klog/v2 v2.130.1
k8s.io/utils v0.0.0-20250604170112-4c0f3b243397
)

require (
Expand Down Expand Up @@ -71,7 +72,6 @@ require (
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/component-base v0.34.0 // indirect
k8s.io/kube-openapi v0.0.0-20250710124328-f3f2b991d03b // indirect
k8s.io/utils v0.0.0-20250604170112-4c0f3b243397 // indirect
sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8 // indirect
sigs.k8s.io/randfill v1.0.0 // indirect
sigs.k8s.io/structured-merge-diff/v6 v6.3.0 // indirect
Expand Down
Loading