Skip to content

Commit 30c015a

Browse files
authored
Merge pull request #1091 from pwschuurman/automated-cherry-pick-of-#1050-upstream-release-1.7
Automated cherry pick of #1050: list out regional PD in listDisk Call
2 parents a7e0b72 + 53e29cc commit 30c015a

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

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

+15-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ func (cloud *CloudProvider) GetDefaultZone() string {
111111
}
112112

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

126+
// listing out regional disks in the region
127+
rlCall := cloud.service.RegionDisks.List(cloud.project, region)
128+
nextPageToken := "pageToken"
129+
for nextPageToken != "" {
130+
rDiskList, err := rlCall.Do()
131+
if err != nil {
132+
return nil, "", err
133+
}
134+
items = append(items, rDiskList.Items...)
135+
nextPageToken = rDiskList.NextPageToken
136+
rlCall.PageToken(nextPageToken)
137+
}
138+
139+
// listing out zonal disks in all zones of the region
126140
for _, zone := range zones {
127141
lCall := cloud.service.Disks.List(cloud.project, zone)
128142
nextPageToken := "pageToken"

0 commit comments

Comments
 (0)