Skip to content

Commit abf18aa

Browse files
authored
Merge pull request #2020 from k8s-infra-cherrypick-robot/cherry-pick-2004-to-release-1.17
[release-1.17] Add pageToken response check to ListSnapshots gRPC API
2 parents c5eaa04 + 5216b16 commit abf18aa

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

pkg/gce-cloud-provider/compute/gce-compute.go

+2
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,7 @@ func (cloud *CloudProvider) ListSnapshots(ctx context.Context, filter string) ([
315315
return nil, "", err
316316
}
317317
items = append(items, snapshotList.Items...)
318+
nextPageToken = snapshotList.NextPageToken
318319
}
319320
return items, "", nil
320321
}
@@ -1310,6 +1311,7 @@ func (cloud *CloudProvider) ListImages(ctx context.Context, filter string) ([]*c
13101311
return nil, "", err
13111312
}
13121313
items = append(items, imageList.Items...)
1314+
nextPageToken = imageList.NextPageToken
13131315
}
13141316
return items, "", nil
13151317
}

test/e2e/tests/single_zone_e2e_test.go

+8
Original file line numberDiff line numberDiff line change
@@ -1065,6 +1065,10 @@ var _ = Describe("GCE PD CSI Driver", func() {
10651065
})
10661066
Expect(err).To(BeNil(), "Could not wait for snapshot be ready")
10671067

1068+
snapshots, err := client.ListSnapshots()
1069+
Expect(err).To(BeNil(), "Could not list snapshots")
1070+
Expect(snapshots).To(ContainElement(snapshotID), "Couldn't find snapshot ID")
1071+
10681072
defer func() {
10691073
// Delete Disk
10701074
err := client.DeleteVolume(volID)
@@ -1124,6 +1128,10 @@ var _ = Describe("GCE PD CSI Driver", func() {
11241128
Expect(err).To(BeNil(), "Failed to parse snapshot ID")
11251129
Expect(snapshotType).To(Equal(common.DiskImageType), "Expected images type in snapshot ID")
11261130

1131+
snapshots, err := client.ListSnapshots()
1132+
Expect(err).To(BeNil(), "Could not list snapshots")
1133+
Expect(snapshots).To(ContainElement(snapshotID), "Couldn't find snapshot ID")
1134+
11271135
defer func() {
11281136
// Delete Disk
11291137
err := client.DeleteVolume(volID)

test/remote/client-wrappers.go

+14
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,20 @@ func (c *CsiClient) NodeGetVolumeStats(volumeID, volumePath string) (available,
310310
return
311311
}
312312

313+
func (c *CsiClient) ListSnapshots() ([]string, error) {
314+
lsr := &csipb.ListSnapshotsRequest{}
315+
resp, err := c.ctrlClient.ListSnapshots(context.Background(), lsr)
316+
if err != nil {
317+
return nil, err
318+
}
319+
320+
snapshots := []string{}
321+
for _, e := range resp.Entries {
322+
snapshots = append(snapshots, e.Snapshot.SnapshotId)
323+
}
324+
return snapshots, nil
325+
}
326+
313327
func (c *CsiClient) CreateSnapshot(snapshotName, sourceVolumeId string, params map[string]string) (string, error) {
314328

315329
csr := &csipb.CreateSnapshotRequest{

0 commit comments

Comments
 (0)