Repository: kubernetes-sigs/gcp-compute-persistent-disk-csi-driver
Pull request #643 (2020-10-28 19:07:30)

Migrate from alpha to beta compute APIs
**What type of PR is this?**

/kind cleanup

**What this PR does / why we need it**:

The only Disk feature that required an alpha API (multiwriter) is now in beta.
We keep the infrastructure to be able to swap API versions, but it has been simplified to reduce code duplication.

**Special notes for your reviewer**:

Builds on top of #642

**Does this PR introduce a user-facing change?**:

```release-note
NONE
```


k8s-ci-robot: [APPROVALNOTIFIER] This PR is **NOT APPROVED**

This pull-request has been approved by: *<a href="https://github.com/kubernetes-sigs/gcp-compute-persistent-disk-csi-driver/pull/643#" title="Author self-approved">alculquicondor</a>*
To complete the [pull request process](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process), please assign **jingxu97** after the PR has been reviewed.
You can assign the PR to them by writing `/assign @jingxu97` in a comment when ready.

The full list of commands accepted by this bot can be found [here](https://go.k8s.io/bot-commands?repo=kubernetes-sigs%2Fgcp-compute-persistent-disk-csi-driver).

<details open>
Needs approval from an approver in each of these files:

- **[OWNERS](https://github.com/kubernetes-sigs/gcp-compute-persistent-disk-csi-driver/blob/master/OWNERS)**

Approvers can indicate their approval by writing `/approve` in a comment
Approvers can cancel approval by writing `/approve cancel` in a comment
</details>
<!-- META={"approvers":["jingxu97"]} -->
alculquicondor: /assign @saikat-royc 
k8s-ci-robot: [APPROVALNOTIFIER] This PR is **NOT APPROVED**

This pull-request has been approved by: *<a href="https://github.com/kubernetes-sigs/gcp-compute-persistent-disk-csi-driver/pull/643#" title="Author self-approved">alculquicondor</a>*
To complete the [pull request process](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process), please assign **saikat-royc** after the PR has been reviewed.
You can assign the PR to them by writing `/assign @saikat-royc` in a comment when ready.

The full list of commands accepted by this bot can be found [here](https://go.k8s.io/bot-commands?repo=kubernetes-sigs%2Fgcp-compute-persistent-disk-csi-driver).

<details open>
Needs approval from an approver in each of these files:

- **[OWNERS](https://github.com/kubernetes-sigs/gcp-compute-persistent-disk-csi-driver/blob/master/OWNERS)**

Approvers can indicate their approval by writing `/approve` in a comment
Approvers can cancel approval by writing `/approve cancel` in a comment
</details>
<!-- META={"approvers":["saikat-royc"]} -->

Patch:
diff --git a/pkg/gce-cloud-provider/compute/cloud-disk.go b/pkg/gce-cloud-provider/compute/cloud-disk.go
index be04fe03..86243d98 100644
--- a/pkg/gce-cloud-provider/compute/cloud-disk.go
+++ b/pkg/gce-cloud-provider/compute/cloud-disk.go
@@ -17,126 +17,89 @@ package gcecloudprovider
 import (
 	"strings"
 
-	computealpha "google.golang.org/api/compute/v0.alpha"
+	"github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/meta"
+	computebeta "google.golang.org/api/compute/v0.beta"
 	computev1 "google.golang.org/api/compute/v1"
 )
 
 type CloudDisk struct {
-	ZonalDisk         *computev1.Disk
-	RegionalDisk      *computev1.Disk
-	ZonalAlphaDisk    *computealpha.Disk
-	RegionalAlphaDisk *computealpha.Disk
+	disk     *computev1.Disk
+	betaDisk *computebeta.Disk
 }
 
 type CloudDiskType string
 
-const (
-	// Zonal key type.
-	Zonal = "zonal"
-	// Regional key type.
-	Regional = "regional"
-	// ZonalAlpha key type.
-	ZonalAlpha = "zonalAlpha"
-	// RegionalAlpha key type.
-	RegionalAlpha = "regionalAlpha"
-	// Global key type.
-	Global = "global"
-)
-
-func ZonalCloudDisk(disk *computev1.Disk) *CloudDisk {
+func CloudDiskFromV1(disk *computev1.Disk) *CloudDisk {
 	return &CloudDisk{
-		ZonalDisk: disk,
+		disk: disk,
 	}
 }
 
-func RegionalCloudDisk(disk *computev1.Disk) *CloudDisk {
+func CloudDiskFromBeta(disk *computebeta.Disk) *CloudDisk {
 	return &CloudDisk{
-		RegionalDisk: disk,
+		betaDisk: disk,
 	}
 }
 
-func ZonalAlphaCloudDisk(disk *computealpha.Disk) *CloudDisk {
-	return &CloudDisk{
-		ZonalAlphaDisk: disk,
-	}
-}
-
-func RegionalAlphaCloudDisk(disk *computealpha.Disk) *CloudDisk {
-	return &CloudDisk{
-		RegionalAlphaDisk: disk,
+func (d *CloudDisk) LocationType() meta.KeyType {
+	var zone, region string
+	switch {
+	case d.disk != nil:
+		zone = d.disk.Zone
+		region = d.disk.Region
+	case d.betaDisk != nil:
+		zone = d.betaDisk.Zone
+		region = d.betaDisk.Region
 	}
-}
-
-func (d *CloudDisk) Type() CloudDiskType {
 	switch {
-	case d.ZonalDisk != nil:
-		return Zonal
-	case d.RegionalDisk != nil:
-		return Regional
-	case d.ZonalAlphaDisk != nil:
-		return ZonalAlpha
-	case d.RegionalAlphaDisk != nil:
-		return RegionalAlpha
+	case zone != "":
+		return meta.Zonal
+	case region != "":
+		return meta.Regional
 	default:
-		return Global
+		return meta.Global
 	}
 }
 
 func (d *CloudDisk) GetUsers() []string {
-	switch d.Type() {
-	case Zonal:
-		return d.ZonalDisk.Users
-	case Regional:
-		return d.RegionalDisk.Users
-	case ZonalAlpha:
-		return d.ZonalAlphaDisk.Users
-	case RegionalAlpha:
-		return d.RegionalAlphaDisk.Users
+	switch {
+	case d.disk != nil:
+		return d.disk.Users
+	case d.betaDisk != nil:
+		return d.betaDisk.Users
 	default:
 		return nil
 	}
 }
 
 func (d *CloudDisk) GetName() string {
-	switch d.Type() {
-	case Zonal:
-		return d.ZonalDisk.Name
-	case Regional:
-		return d.RegionalDisk.Name
-	case ZonalAlpha:
-		return d.ZonalAlphaDisk.Name
-	case RegionalAlpha:
-		return d.RegionalAlphaDisk.Name
+	switch {
+	case d.disk != nil:
+		return d.disk.Name
+	case d.betaDisk != nil:
+		return d.betaDisk.Name
 	default:
 		return ""
 	}
 }
 
 func (d *CloudDisk) GetKind() string {
-	switch d.Type() {
-	case Zonal:
-		return d.ZonalDisk.Kind
-	case Regional:
-		return d.RegionalDisk.Kind
-	case ZonalAlpha:
-		return d.ZonalAlphaDisk.Kind
-	case RegionalAlpha:
-		return d.RegionalAlphaDisk.Kind
+	switch {
+	case d.disk != nil:
+		return d.disk.Kind
+	case d.betaDisk != nil:
+		return d.betaDisk.Kind
 	default:
 		return ""
 	}
 }
 
 func (d *CloudDisk) GetStatus() string {
-	switch d.Type() {
-	case Zonal:
-		return d.ZonalDisk.Status
-	case Regional:
-		return d.RegionalDisk.Status
-	case ZonalAlpha:
-		return d.ZonalAlphaDisk.Status
-	case RegionalAlpha:
-		return d.RegionalAlphaDisk.Status
+	switch {
+	case d.disk != nil:
+		return d.disk.Status
+	case d.betaDisk != nil:
+		return d.betaDisk.Status
 	default:
 		return "Unknown"
 	}
@@ -147,15 +110,11 @@ func (d *CloudDisk) GetStatus() string {
 // validated, it is just passed verbatium from GCP.
 func (d *CloudDisk) GetPDType() string {
 	var pdType string
-	switch d.Type() {
-	case Zonal:
-		pdType = d.ZonalDisk.Type
-	case Regional:
-		pdType = d.RegionalDisk.Type
-	case ZonalAlpha:
-		pdType = d.ZonalAlphaDisk.Type
-	case RegionalAlpha:
-		pdType = d.RegionalAlphaDisk.Type
+	switch {
+	case d.disk != nil:
+		pdType = d.disk.Type
+	case d.betaDisk != nil:
+		pdType = d.betaDisk.Type
 	default:
 		return ""
 	}
@@ -164,30 +123,22 @@ func (d *CloudDisk) GetPDType() string {
 }
 
 func (d *CloudDisk) GetSelfLink() string {
-	switch d.Type() {
-	case Zonal:
-		return d.ZonalDisk.SelfLink
-	case Regional:
-		return d.RegionalDisk.SelfLink
-	case ZonalAlpha:
-		return d.ZonalAlphaDisk.SelfLink
-	case RegionalAlpha:
-		return d.RegionalAlphaDisk.SelfLink
+	switch {
+	case d.disk != nil:
+		return d.disk.SelfLink
+	case d.betaDisk != nil:
+		return d.betaDisk.SelfLink
 	default:
 		return ""
 	}
 }
 
 func (d *CloudDisk) GetSizeGb() int64 {
-	switch d.Type() {
-	case Zonal:
-		return d.ZonalDisk.SizeGb
-	case Regional:
-		return d.RegionalDisk.SizeGb
-	case ZonalAlpha:
-		return d.ZonalAlphaDisk.SizeGb
-	case RegionalAlpha:
-		return d.RegionalAlphaDisk.SizeGb
+	switch {
+	case d.disk != nil:
+		return d.disk.SizeGb
+	case d.betaDisk != nil:
+		return d.betaDisk.SizeGb
 	default:
 		return -1
 	}
@@ -196,82 +147,56 @@ func (d *CloudDisk) GetSizeGb() int64 {
 // setSizeGb sets the size of the disk used ONLY
 // for testing purposes.
 func (d *CloudDisk) setSizeGb(size int64) {
-	switch d.Type() {
-	case Zonal:
-		d.ZonalDisk.SizeGb = size
-	case Regional:
-		d.RegionalDisk.SizeGb = size
-	case ZonalAlpha:
-		d.ZonalAlphaDisk.SizeGb = size
-	case RegionalAlpha:
-		d.RegionalAlphaDisk.SizeGb = size
+	switch {
+	case d.disk != nil:
+		d.disk.SizeGb = size
+	case d.betaDisk != nil:
+		d.betaDisk.SizeGb = size
 	}
 }
 
 func (d *CloudDisk) GetZone() string {
-	switch d.Type() {
-	case Zonal:
-		return d.ZonalDisk.Zone
-	case Regional:
-		return d.RegionalDisk.Zone
-	case ZonalAlpha:
-		return d.ZonalAlphaDisk.Zone
-	case RegionalAlpha:
-		return d.RegionalAlphaDisk.Zone
+	switch {
+	case d.disk != nil:
+		return d.disk.Zone
+	case d.betaDisk != nil:
+		return d.betaDisk.Zone
 	default:
 		return ""
 	}
 }
 
 func (d *CloudDisk) GetSnapshotId() string {
-	switch d.Type() {
-	case Zonal:
-		return d.ZonalDisk.SourceSnapshotId
-	case Regional:
-		return d.RegionalDisk.SourceSnapshotId
-	case ZonalAlpha:
-		return d.ZonalAlphaDisk.SourceSnapshotId
-	case RegionalAlpha:
-		return d.RegionalAlphaDisk.SourceSnapshotId
+	switch {
+	case d.disk != nil:
+		return d.disk.SourceSnapshotId
+	case d.betaDisk != nil:
+		return d.betaDisk.SourceSnapshotId
 	default:
 		return ""
 	}
 }
 
 func (d *CloudDisk) GetKMSKeyName() string {
-	var dek *computev1.CustomerEncryptionKey
-	var dekAlpha *computealpha.CustomerEncryptionKey
-	switch d.Type() {
-	case Zonal:
-		dek = d.ZonalDisk.DiskEncryptionKey
-	case Regional:
-		dek = d.RegionalDisk.DiskEncryptionKey
-	case ZonalAlpha:
-		dekAlpha = d.ZonalAlphaDisk.DiskEncryptionKey
-	case RegionalAlpha:
-		dekAlpha = d.RegionalAlphaDisk.DiskEncryptionKey
-	default:
-		return ""
-	}
-
-	if dek != nil {
-		return dek.KmsKeyName
-	} else if dekAlpha != nil {
-		return dekAlpha.KmsKeyName
+	switch {
+	case d.disk != nil:
+		if dek := d.disk.DiskEncryptionKey; dek != nil {
+			return dek.KmsKeyName
+		}
+	case d.betaDisk != nil:
+		if dek := d.betaDisk.DiskEncryptionKey; dek != nil {
+			return dek.KmsKeyName
+		}
 	}
 	return ""
 }
 
 func (d *CloudDisk) GetMultiWriter() bool {
-	switch d.Type() {
-	case Zonal:
-		return false
-	case Regional:
+	switch {
+	case d.disk != nil:
 		return false
-	case ZonalAlpha:
-		return d.ZonalAlphaDisk.MultiWriter
-	case RegionalAlpha:
-		return d.RegionalAlphaDisk.MultiWriter
+	case d.betaDisk != nil:
+		return d.betaDisk.MultiWriter
 	default:
 		return false
 	}
diff --git a/pkg/gce-cloud-provider/compute/fake-gce.go b/pkg/gce-cloud-provider/compute/fake-gce.go
index e61e0686..93da6fb5 100644
--- a/pkg/gce-cloud-provider/compute/fake-gce.go
+++ b/pkg/gce-cloud-provider/compute/fake-gce.go
@@ -134,9 +134,9 @@ func (cloud *FakeCloudProvider) ListDisks(ctx context.Context, maxEntries int64,
 	}
 
 	for name, cd := range cloud.disks {
-		// Only return zonal disks for simplicity
+		// Only return v1 disks for simplicity
 		if !seen.Has(name) {
-			d = append(d, cd.ZonalDisk)
+			d = append(d, cd.disk)
 			seen.Insert(name)
 			count++
 		}
@@ -260,45 +260,31 @@ func (cloud *FakeCloudProvider) InsertDisk(ctx context.Context, volKey *meta.Key
 		}
 	}
 
-	var diskToCreate *CloudDisk
+	computeDisk := &computev1.Disk{
+		Name:             volKey.Name,
+		SizeGb:           common.BytesToGb(capBytes),
+		Description:      "Disk created by GCE-PD CSI Driver",
+		Type:             cloud.GetDiskTypeURI(volKey, params.DiskType),
+		SourceSnapshotId: snapshotID,
+		Status:           cloud.mockDiskStatus,
+	}
+	if params.DiskEncryptionKMSKey != "" {
+		computeDisk.DiskEncryptionKey = &computev1.CustomerEncryptionKey{
+			KmsKeyName: params.DiskEncryptionKMSKey,
+		}
+	}
 	switch volKey.Type() {
 	case meta.Zonal:
-		diskToCreateGA := &computev1.Disk{
-			Name:             volKey.Name,
-			SizeGb:           common.BytesToGb(capBytes),
-			Description:      "Disk created by GCE-PD CSI Driver",
-			Type:             cloud.GetDiskTypeURI(volKey, params.DiskType),
-			SelfLink:         fmt.Sprintf("projects/%s/zones/%s/disks/%s", cloud.project, volKey.Zone, volKey.Name),
-			SourceSnapshotId: snapshotID,
-			Status:           cloud.mockDiskStatus,
-		}
-		if params.DiskEncryptionKMSKey != "" {
-			diskToCreateGA.DiskEncryptionKey = &computev1.CustomerEncryptionKey{
-				KmsKeyName: params.DiskEncryptionKMSKey,
-			}
-		}
-		diskToCreate = ZonalCloudDisk(diskToCreateGA)
+		computeDisk.Zone = volKey.Zone
+		computeDisk.SelfLink = fmt.Sprintf("projects/%s/zones/%s/disks/%s", cloud.project, volKey.Zone, volKey.Name)
 	case meta.Regional:
-		diskToCreateV1 := &computev1.Disk{
-			Name:             volKey.Name,
-			SizeGb:           common.BytesToGb(capBytes),
-			Description:      "Regional disk created by GCE-PD CSI Driver",
-			Type:             cloud.GetDiskTypeURI(volKey, params.DiskType),
-			SelfLink:         fmt.Sprintf("projects/%s/regions/%s/disks/%s", cloud.project, volKey.Region, volKey.Name),
-			SourceSnapshotId: snapshotID,
-			Status:           cloud.mockDiskStatus,
-		}
-		if params.DiskEncryptionKMSKey != "" {
-			diskToCreateV1.DiskEncryptionKey = &computev1.CustomerEncryptionKey{
-				KmsKeyName: params.DiskEncryptionKMSKey,
-			}
-		}
-		diskToCreate = RegionalCloudDisk(diskToCreateV1)
+		computeDisk.Region = volKey.Region
+		computeDisk.SelfLink = fmt.Sprintf("projects/%s/regions/%s/disks/%s", cloud.project, volKey.Region, volKey.Name)
 	default:
 		return fmt.Errorf("could not create disk, key was neither zonal nor regional, instead got: %v", volKey.String())
 	}
 
-	cloud.disks[volKey.Name] = diskToCreate
+	cloud.disks[volKey.Name] = CloudDiskFromV1(computeDisk)
 	return nil
 }
 
@@ -456,9 +442,9 @@ func (cloud *FakeCloudProvider) ValidateExistingSnapshot(resp *computev1.Snapsho
 
 func (cloud *FakeCloudProvider) GetDiskSourceURI(volKey *meta.Key) string {
 	switch volKey.Type() {
-	case Zonal:
+	case meta.Zonal:
 		return cloud.getZonalDiskSourceURI(volKey.Name, volKey.Zone)
-	case Regional:
+	case meta.Regional:
 		return cloud.getRegionalDiskSourceURI(volKey.Name, volKey.Region)
 	default:
 		return ""
diff --git a/pkg/gce-cloud-provider/compute/gce-compute.go b/pkg/gce-cloud-provider/compute/gce-compute.go
index 37b173b0..afca4bba 100644
--- a/pkg/gce-cloud-provider/compute/gce-compute.go
+++ b/pkg/gce-cloud-provider/compute/gce-compute.go
@@ -15,16 +15,15 @@ limitations under the License.
 package gcecloudprovider
 
 import (
+	"context"
 	"encoding/json"
 	"fmt"
 	"strings"
 	"time"
 
-	"context"
-
 	"github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/meta"
 	csi "github.com/container-storage-interface/spec/lib/go/csi"
-	computealpha "google.golang.org/api/compute/v0.alpha"
+	computebeta "google.golang.org/api/compute/v0.beta"
 	computev1 "google.golang.org/api/compute/v1"
 	"google.golang.org/grpc/codes"
 	"google.golang.org/grpc/status"
@@ -46,7 +45,7 @@ const (
 	// V1 key type
 	GCEAPIVersionV1 GCEAPIVersion = "v1"
 	// Alpha key type
-	GCEAPIVersionAlpha GCEAPIVersion = "alpha"
+	GCEAPIVersionBeta GCEAPIVersion = "beta"
 )
 
 type GCECompute interface {
@@ -193,20 +192,20 @@ func (cloud *CloudProvider) GetDisk(ctx context.Context, key *meta.Key, gceAPIVe
 	klog.V(5).Infof("Getting disk %v", key)
 	switch key.Type() {
 	case meta.Zonal:
-		if gceAPIVersion == GCEAPIVersionAlpha {
-			disk, err := cloud.getZonalAlphaDiskOrError(ctx, key.Zone, key.Name)
-			return ZonalAlphaCloudDisk(disk), err
+		if gceAPIVersion == GCEAPIVersionBeta {
+			disk, err := cloud.getZonalBetaDiskOrError(ctx, key.Zone, key.Name)
+			return CloudDiskFromBeta(disk), err
 		} else {
 			disk, err := cloud.getZonalDiskOrError(ctx, key.Zone, key.Name)
-			return ZonalCloudDisk(disk), err
+			return CloudDiskFromV1(disk), err
 		}
 	case meta.Regional:
-		if gceAPIVersion == GCEAPIVersionAlpha {
+		if gceAPIVersion == GCEAPIVersionBeta {
 			disk, err := cloud.getRegionalAlphaDiskOrError(ctx, key.Region, key.Name)
-			return RegionalAlphaCloudDisk(disk), err
+			return CloudDiskFromBeta(disk), err
 		} else {
 			disk, err := cloud.getRegionalDiskOrError(ctx, key.Region, key.Name)
-			return RegionalCloudDisk(disk), err
+			return CloudDiskFromV1(disk), err
 		}
 	default:
 		return nil, fmt.Errorf("key was neither zonal nor regional, got: %v", key.String())
@@ -233,18 +232,18 @@ func (cloud *CloudProvider) getRegionalDiskOrError(ctx context.Context, volumeRe
 	return disk, nil
 }
 
-func (cloud *CloudProvider) getZonalAlphaDiskOrError(ctx context.Context, volumeZone, volumeName string) (*computealpha.Disk, error) {
+func (cloud *CloudProvider) getZonalBetaDiskOrError(ctx context.Context, volumeZone, volumeName string) (*computebeta.Disk, error) {
 	project := cloud.project
-	disk, err := cloud.alphaService.Disks.Get(project, volumeZone, volumeName).Context(ctx).Do()
+	disk, err := cloud.betaService.Disks.Get(project, volumeZone, volumeName).Context(ctx).Do()
 	if err != nil {
 		return nil, err
 	}
 	return disk, nil
 }
 
-func (cloud *CloudProvider) getRegionalAlphaDiskOrError(ctx context.Context, volumeRegion, volumeName string) (*computealpha.Disk, error) {
+func (cloud *CloudProvider) getRegionalAlphaDiskOrError(ctx context.Context, volumeRegion, volumeName string) (*computebeta.Disk, error) {
 	project := cloud.project
-	disk, err := cloud.alphaService.RegionDisks.Get(project, volumeRegion, volumeName).Context(ctx).Do()
+	disk, err := cloud.betaService.RegionDisks.Get(project, volumeRegion, volumeName).Context(ctx).Do()
 	if err != nil {
 		return nil, err
 	}
@@ -293,12 +292,9 @@ func ValidateDiskParameters(disk *CloudDisk, params common.DiskParameters) error
 		return fmt.Errorf("actual pd type %s did not match the expected param %s", disk.GetPDType(), params.DiskType)
 	}
 
-	if params.ReplicationType == "none" && disk.Type() != Zonal && disk.Type() != ZonalAlpha {
-		return fmt.Errorf("actual disk replication type %v did not match expected param %s", disk.Type(), params.ReplicationType)
-	}
-
-	if params.ReplicationType == "regional-pd" && disk.Type() != Regional && disk.Type() != RegionalAlpha {
-		return fmt.Errorf("actual disk replication type %v did not match expected param %s", disk.Type(), "regional-pd")
+	locationType := disk.LocationType()
+	if (params.ReplicationType == "none" && locationType != meta.Zonal) || (params.ReplicationType == "regional-pd" && locationType != meta.Regional) {
+		return fmt.Errorf("actual disk replication type %v did not match expected param %s", locationType, params.ReplicationType)
 	}
 
 	if !kmsKeyEqual(
@@ -334,8 +330,8 @@ func (cloud *CloudProvider) InsertDisk(ctx context.Context, volKey *meta.Key, pa
 	}
 }
 
-func convertV1CustomerEncryptionKeyToAlpha(v1Key *computev1.CustomerEncryptionKey) *computealpha.CustomerEncryptionKey {
-	return &computealpha.CustomerEncryptionKey{
+func convertV1CustomerEncryptionKeyToBeta(v1Key *computev1.CustomerEncryptionKey) *computebeta.CustomerEncryptionKey {
+	return &computebeta.CustomerEncryptionKey{
 		KmsKeyName:      v1Key.KmsKeyName,
 		RawKey:          v1Key.RawKey,
 		Sha256:          v1Key.Sha256,
@@ -344,15 +340,15 @@ func convertV1CustomerEncryptionKeyToAlpha(v1Key *computev1.CustomerEncryptionKe
 	}
 }
 
-func convertV1DiskToAlphaDisk(v1Disk *computev1.Disk) *computealpha.Disk {
-	var dek *computealpha.CustomerEncryptionKey = nil
+func convertV1DiskToBetaDisk(v1Disk *computev1.Disk) *computebeta.Disk {
+	var dek *computebeta.CustomerEncryptionKey = nil
 
 	if v1Disk.DiskEncryptionKey != nil {
-		dek = convertV1CustomerEncryptionKeyToAlpha(v1Disk.DiskEncryptionKey)
+		dek = convertV1CustomerEncryptionKeyToBeta(v1Disk.DiskEncryptionKey)
 	}
 
 	// Note: this is an incomplete list. It only includes the fields we use for disk creation.
-	return &computealpha.Disk{
+	return &computebeta.Disk{
 		Name:              v1Disk.Name,
 		SizeGb:            v1Disk.SizeGb,
 		Description:       v1Disk.Description,
@@ -380,7 +376,7 @@ func (cloud *CloudProvider) insertRegionalDisk(
 	)
 
 	if multiWriter {
-		gceAPIVersion = GCEAPIVersionAlpha
+		gceAPIVersion = GCEAPIVersionBeta
 	}
 
 	diskToCreate := &computev1.Disk{
@@ -401,11 +397,11 @@ func (cloud *CloudProvider) insertRegionalDisk(
 		}
 	}
 
-	if gceAPIVersion == GCEAPIVersionAlpha {
-		var insertOp *computealpha.Operation
-		alphaDiskToCreate := convertV1DiskToAlphaDisk(diskToCreate)
-		alphaDiskToCreate.MultiWriter = multiWriter
-		insertOp, err = cloud.alphaService.RegionDisks.Insert(cloud.project, volKey.Region, alphaDiskToCreate).Context(ctx).Do()
+	if gceAPIVersion == GCEAPIVersionBeta {
+		var insertOp *computebeta.Operation
+		betaDiskToCreate := convertV1DiskToBetaDisk(diskToCreate)
+		betaDiskToCreate.MultiWriter = multiWriter
+		insertOp, err = cloud.betaService.RegionDisks.Insert(cloud.project, volKey.Region, betaDiskToCreate).Context(ctx).Do()
 		if insertOp != nil {
 			opName = insertOp.Name
 		}
@@ -473,7 +469,7 @@ func (cloud *CloudProvider) insertZonalDisk(
 	)
 
 	if multiWriter {
-		gceAPIVersion = GCEAPIVersionAlpha
+		gceAPIVersion = GCEAPIVersionBeta
 	}
 
 	diskToCreate := &computev1.Disk{
@@ -493,11 +489,11 @@ func (cloud *CloudProvider) insertZonalDisk(
 		}
 	}
 
-	if gceAPIVersion == GCEAPIVersionAlpha {
-		var insertOp *computealpha.Operation
-		alphaDiskToCreate := convertV1DiskToAlphaDisk(diskToCreate)
-		alphaDiskToCreate.MultiWriter = multiWriter
-		insertOp, err = cloud.alphaService.Disks.Insert(cloud.project, volKey.Zone, alphaDiskToCreate).Context(ctx).Do()
+	if gceAPIVersion == GCEAPIVersionBeta {
+		var insertOp *computebeta.Operation
+		betaDiskToCreate := convertV1DiskToBetaDisk(diskToCreate)
+		betaDiskToCreate.MultiWriter = multiWriter
+		insertOp, err = cloud.betaService.Disks.Insert(cloud.project, volKey.Zone, betaDiskToCreate).Context(ctx).Do()
 		if insertOp != nil {
 			opName = insertOp.Name
 		}
@@ -637,9 +633,9 @@ func (cloud *CloudProvider) DetachDisk(ctx context.Context, deviceName, instance
 
 func (cloud *CloudProvider) GetDiskSourceURI(volKey *meta.Key) string {
 	switch volKey.Type() {
-	case Zonal:
+	case meta.Zonal:
 		return cloud.getZonalDiskSourceURI(volKey.Name, volKey.Zone)
-	case Regional:
+	case meta.Regional:
 		return cloud.getRegionalDiskSourceURI(volKey.Name, volKey.Region)
 	default:
 		return ""
diff --git a/pkg/gce-cloud-provider/compute/gce.go b/pkg/gce-cloud-provider/compute/gce.go
index 0686a68e..2385889b 100644
--- a/pkg/gce-cloud-provider/compute/gce.go
+++ b/pkg/gce-cloud-provider/compute/gce.go
@@ -23,11 +23,12 @@ import (
 	"time"
 
 	"golang.org/x/oauth2/google"
+	"google.golang.org/api/option"
 	"gopkg.in/gcfg.v1"
 
 	"cloud.google.com/go/compute/metadata"
 	"golang.org/x/oauth2"
-	alpha "google.golang.org/api/compute/v0.alpha"
+	computebeta "google.golang.org/api/compute/v0.beta"
 	"google.golang.org/api/compute/v1"
 	"google.golang.org/api/googleapi"
 	"k8s.io/apimachinery/pkg/util/wait"
@@ -51,12 +52,12 @@ const (
 )
 
 type CloudProvider struct {
-	service      *compute.Service
-	alphaService *alpha.Service
-	project      string
-	zone         string
+	service     *compute.Service
+	betaService *computebeta.Service
+	project     string
+	zone        string
 
-	zonesCache map[string]([]string)
+	zonesCache map[string][]string
 }
 
 var _ GCECompute = &CloudProvider{}
@@ -92,7 +93,7 @@ func CreateCloudProvider(ctx context.Context, vendorVersion string, configPath s
 		return nil, err
 	}
 
-	alphasvc, err := createAlphaCloudService(ctx, vendorVersion, tokenSource)
+	betasvc, err := createBetaCloudService(ctx, vendorVersion, tokenSource)
 	if err != nil {
 		return nil, err
 	}
@@ -103,11 +104,11 @@ func CreateCloudProvider(ctx context.Context, vendorVersion string, configPath s
 	}
 
 	return &CloudProvider{
-		service:      svc,
-		alphaService: alphasvc,
-		project:      project,
-		zone:         zone,
-		zonesCache:   make(map[string]([]string)),
+		service:     svc,
+		betaService: betasvc,
+		project:     project,
+		zone:        zone,
+		zonesCache:  make(map[string]([]string)),
 	}, nil
 
 }
@@ -158,12 +159,12 @@ func readConfig(configPath string) (*ConfigFile, error) {
 	return cfg, nil
 }
 
-func createAlphaCloudService(ctx context.Context, vendorVersion string, tokenSource oauth2.TokenSource) (*alpha.Service, error) {
+func createBetaCloudService(ctx context.Context, vendorVersion string, tokenSource oauth2.TokenSource) (*computebeta.Service, error) {
 	client, err := newOauthClient(ctx, tokenSource)
 	if err != nil {
 		return nil, err
 	}
-	service, err := alpha.New(client)
+	service, err := computebeta.NewService(ctx, option.WithHTTPClient(client))
 	if err != nil {
 		return nil, err
 	}
diff --git a/pkg/gce-pd-csi-driver/controller.go b/pkg/gce-pd-csi-driver/controller.go
index bde1d4b2..6974b18a 100644
--- a/pkg/gce-pd-csi-driver/controller.go
+++ b/pkg/gce-pd-csi-driver/controller.go
@@ -115,7 +115,7 @@ func (gceCS *GCEControllerServer) CreateVolume(ctx context.Context, req *csi.Cre
 	gceAPIVersion := gce.GCEAPIVersionV1
 	multiWriter, _ := getMultiWriterFromCapabilities(volumeCapabilities)
 	if multiWriter {
-		gceAPIVersion = gce.GCEAPIVersionAlpha
+		gceAPIVersion = gce.GCEAPIVersionBeta
 	}
 	// Determine the zone or zones+region of the disk
 	var zones []string
@@ -1033,7 +1033,7 @@ func createRegionalDisk(ctx context.Context, cloudProvider gce.GCECompute, name
 
 	gceAPIVersion := gce.GCEAPIVersionV1
 	if multiWriter {
-		gceAPIVersion = gce.GCEAPIVersionAlpha
+		gceAPIVersion = gce.GCEAPIVersionBeta
 	}
 
 	disk, err := cloudProvider.GetDisk(ctx, meta.RegionalKey(name, region), gceAPIVersion)
@@ -1055,7 +1055,7 @@ func createSingleZoneDisk(ctx context.Context, cloudProvider gce.GCECompute, nam
 
 	gceAPIVersion := gce.GCEAPIVersionV1
 	if multiWriter {
-		gceAPIVersion = gce.GCEAPIVersionAlpha
+		gceAPIVersion = gce.GCEAPIVersionBeta
 	}
 	disk, err := cloudProvider.GetDisk(ctx, meta.ZonalKey(name, diskZone), gceAPIVersion)
 	if err != nil {


Test patch:
diff --git a/pkg/gce-cloud-provider/compute/gce-compute_test.go b/pkg/gce-cloud-provider/compute/gce-compute_test.go
index 9a0b7864..1a9c9f6e 100644
--- a/pkg/gce-cloud-provider/compute/gce-compute_test.go
+++ b/pkg/gce-cloud-provider/compute/gce-compute_test.go
@@ -66,24 +66,22 @@ func TestValidateDiskParameters(t *testing.T) {
 
 	for i, tc := range testCases {
 		// Arrange
-		existingDisk := &CloudDisk{
-			ZonalDisk: &computev1.Disk{
-				Id:                546559531467326555,
-				CreationTimestamp: "2020-07-24T17:20:06.292-07:00",
-				Name:              "test-disk",
-				SizeGb:            500,
-				Zone:              "https://www.googleapis.com/compute/v1/projects/my-project/zones/us-central1-c",
-				Status:            "READY",
-				SelfLink:          "https://www.googleapis.com/compute/v1/projects/my-project/zones/us-central1-c/disks/test-disk",
-				Type:              "https://www.googleapis.com/compute/v1/projects/my-project/zones/us-central1-c/diskTypes/pd-standard",
-				DiskEncryptionKey: &computev1.CustomerEncryptionKey{
-					KmsKeyName: tc.fetchedKMSKey,
-				},
-				LabelFingerprint:       "42WmSpB8rSM=",
-				PhysicalBlockSizeBytes: 4096,
-				Kind:                   "compute#disk",
+		existingDisk := CloudDiskFromV1(&computev1.Disk{
+			Id:                546559531467326555,
+			CreationTimestamp: "2020-07-24T17:20:06.292-07:00",
+			Name:              "test-disk",
+			SizeGb:            500,
+			Zone:              "https://www.googleapis.com/compute/v1/projects/my-project/zones/us-central1-c",
+			Status:            "READY",
+			SelfLink:          "https://www.googleapis.com/compute/v1/projects/my-project/zones/us-central1-c/disks/test-disk",
+			Type:              "https://www.googleapis.com/compute/v1/projects/my-project/zones/us-central1-c/diskTypes/pd-standard",
+			DiskEncryptionKey: &computev1.CustomerEncryptionKey{
+				KmsKeyName: tc.fetchedKMSKey,
 			},
-		}
+			LabelFingerprint:       "42WmSpB8rSM=",
+			PhysicalBlockSizeBytes: 4096,
+			Kind:                   "compute#disk",
+		})
 
 		storageClassParams := common.DiskParameters{
 			DiskType:             "pd-standard",
diff --git a/pkg/gce-pd-csi-driver/controller_test.go b/pkg/gce-pd-csi-driver/controller_test.go
index 1e7bf863..e712f9a1 100644
--- a/pkg/gce-pd-csi-driver/controller_test.go
+++ b/pkg/gce-pd-csi-driver/controller_test.go
@@ -751,10 +751,10 @@ func TestListVolumeArgs(t *testing.T) {
 	for _, tc := range testCases {
 		t.Run(tc.name, func(t *testing.T) {
 			// Setup new driver each time so no interference
-			d := []*gce.CloudDisk{}
+			var d []*gce.CloudDisk
 			for i := 0; i < 600; i++ {
 				// Create 600 dummy disks
-				d = append(d, &gce.CloudDisk{ZonalDisk: &compute.Disk{Name: fmt.Sprintf("%v", i)}})
+				d = append(d, gce.CloudDiskFromV1(&compute.Disk{Name: fmt.Sprintf("%v", i)}))
 			}
 			gceDriver := initGCEDriver(t, d)
 			lvr := &csi.ListVolumesRequest{
@@ -890,7 +890,7 @@ func TestCreateVolumeRandomRequisiteTopology(t *testing.T) {
 }
 
 func createZonalCloudDisk(name string) *gce.CloudDisk {
-	return gce.ZonalCloudDisk(&compute.Disk{
+	return gce.CloudDiskFromV1(&compute.Disk{
 		Name: name,
 	})
 }
diff --git a/test/run-k8s-integration-ci.sh b/test/run-k8s-integration-ci.sh
index d4863df2..c530b5a9 100755
--- a/test/run-k8s-integration-ci.sh
+++ b/test/run-k8s-integration-ci.sh
@@ -71,7 +71,7 @@ else
   base_cmd="${base_cmd} --gce-region=${gce_region}"
 fi
 
-if [ -n "$gke_node_version" ]; then
+if [ -z "$gke_node_version" ]; then
   base_cmd="${base_cmd} --gke-node-version=${gke_node_version}"
 fi