Skip to content
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

Add pageToken response check to ListSnapshots gRPC API #2004

Merged
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
2 changes: 2 additions & 0 deletions pkg/gce-cloud-provider/compute/gce-compute.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ func (cloud *CloudProvider) ListSnapshots(ctx context.Context, filter string) ([
return nil, "", err
}
items = append(items, snapshotList.Items...)
nextPageToken = snapshotList.NextPageToken
}
return items, "", nil
}
Expand Down Expand Up @@ -1310,6 +1311,7 @@ func (cloud *CloudProvider) ListImages(ctx context.Context, filter string) ([]*c
return nil, "", err
}
items = append(items, imageList.Items...)
nextPageToken = imageList.NextPageToken
}
return items, "", nil
}
Expand Down
8 changes: 8 additions & 0 deletions test/e2e/tests/single_zone_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1065,6 +1065,10 @@ var _ = Describe("GCE PD CSI Driver", func() {
})
Expect(err).To(BeNil(), "Could not wait for snapshot be ready")

snapshots, err := client.ListSnapshots()
Expect(err).To(BeNil(), "Could not list snapshots")
Expect(snapshots).To(ContainElement(snapshotID), "Couldn't find snapshot ID")

defer func() {
// Delete Disk
err := client.DeleteVolume(volID)
Expand Down Expand Up @@ -1124,6 +1128,10 @@ var _ = Describe("GCE PD CSI Driver", func() {
Expect(err).To(BeNil(), "Failed to parse snapshot ID")
Expect(snapshotType).To(Equal(common.DiskImageType), "Expected images type in snapshot ID")

snapshots, err := client.ListSnapshots()
Expect(err).To(BeNil(), "Could not list snapshots")
Expect(snapshots).To(ContainElement(snapshotID), "Couldn't find snapshot ID")

defer func() {
// Delete Disk
err := client.DeleteVolume(volID)
Expand Down
14 changes: 14 additions & 0 deletions test/remote/client-wrappers.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,20 @@ func (c *CsiClient) NodeGetVolumeStats(volumeID, volumePath string) (available,
return
}

func (c *CsiClient) ListSnapshots() ([]string, error) {
lsr := &csipb.ListSnapshotsRequest{}
resp, err := c.ctrlClient.ListSnapshots(context.Background(), lsr)
if err != nil {
return nil, err
}

snapshots := []string{}
for _, e := range resp.Entries {
snapshots = append(snapshots, e.Snapshot.SnapshotId)
}
return snapshots, nil
}

func (c *CsiClient) CreateSnapshot(snapshotName, sourceVolumeId string, params map[string]string) (string, error) {

csr := &csipb.CreateSnapshotRequest{
Expand Down