Skip to content

list out regional PD in listDisk Call #1050

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

Merged
merged 1 commit into from
Sep 27, 2022
Merged
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
16 changes: 15 additions & 1 deletion pkg/gce-cloud-provider/compute/gce-compute.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func (cloud *CloudProvider) GetDefaultZone() string {
}

// ListDisks lists disks based on maxEntries and pageToken only in the project
// and zone that the driver is running in.
// and region that the driver is running in.
func (cloud *CloudProvider) ListDisks(ctx context.Context) ([]*computev1.Disk, string, error) {
region, err := common.GetRegionFromZones([]string{cloud.zone})
if err != nil {
Expand All @@ -123,6 +123,20 @@ func (cloud *CloudProvider) ListDisks(ctx context.Context) ([]*computev1.Disk, s
}
items := []*computev1.Disk{}

// listing out regional disks in the region
rlCall := cloud.service.RegionDisks.List(cloud.project, region)
nextPageToken := "pageToken"
for nextPageToken != "" {
rDiskList, err := rlCall.Do()
if err != nil {
return nil, "", err
}
items = append(items, rDiskList.Items...)
nextPageToken = rDiskList.NextPageToken
rlCall.PageToken(nextPageToken)
}

// listing out zonal disks in all zones of the region
for _, zone := range zones {
lCall := cloud.service.Disks.List(cloud.project, zone)
nextPageToken := "pageToken"
Expand Down