Skip to content

Commit 6af5e68

Browse files
committed
shared-pd addressing comments and fixing e2e build error
1 parent cb15d04 commit 6af5e68

File tree

3 files changed

+20
-19
lines changed

3 files changed

+20
-19
lines changed

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

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ package gcecloudprovider
1717
import (
1818
"strings"
1919

20-
computev1 "google.golang.org/api/compute/v1"
2120
computealpha "google.golang.org/api/compute/v0.alpha"
21+
computev1 "google.golang.org/api/compute/v1"
2222
)
2323

2424
type CloudDisk struct {
@@ -133,6 +133,10 @@ func (d *CloudDisk) GetStatus() string {
133133
return d.ZonalDisk.Status
134134
case Regional:
135135
return d.RegionalDisk.Status
136+
case ZonalAlpha:
137+
return d.ZonalAlphaDisk.Status
138+
case RegionalAlpha:
139+
return d.RegionalAlphaDisk.Status
136140
default:
137141
return "Unknown"
138142
}
@@ -236,18 +240,26 @@ func (d *CloudDisk) GetSnapshotId() string {
236240

237241
func (d *CloudDisk) GetKMSKeyName() string {
238242
var dek *computev1.CustomerEncryptionKey
243+
var dekAlpha *computealpha.CustomerEncryptionKey
239244
switch d.Type() {
240245
case Zonal:
241246
dek = d.ZonalDisk.DiskEncryptionKey
242247
case Regional:
243248
dek = d.RegionalDisk.DiskEncryptionKey
249+
case ZonalAlpha:
250+
dekAlpha = d.ZonalAlphaDisk.DiskEncryptionKey
251+
case RegionalAlpha:
252+
dekAlpha = d.RegionalAlphaDisk.DiskEncryptionKey
244253
default:
245254
return ""
246255
}
247-
if dek == nil {
248-
return ""
256+
257+
if dek != nil {
258+
return dek.KmsKeyName
259+
} else if dekAlpha != nil {
260+
return dekAlpha.KmsKeyName
249261
}
250-
return dek.KmsKeyName
262+
return ""
251263
}
252264

253265
func (d *CloudDisk) GetMultiWriter() bool {

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

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -291,11 +291,11 @@ func ValidateDiskParameters(disk *CloudDisk, params common.DiskParameters) error
291291
return fmt.Errorf("actual pd type %s did not match the expected param %s", disk.GetPDType(), params.DiskType)
292292
}
293293

294-
if params.ReplicationType == "none" && disk.Type() != Zonal {
294+
if params.ReplicationType == "none" && disk.Type() != Zonal && disk.Type() != ZonalAlpha {
295295
return fmt.Errorf("actual disk replication type %v did not match expected param %s", disk.Type(), params.ReplicationType)
296296
}
297297

298-
if params.ReplicationType == "regional-pd" && disk.Type() != Regional {
298+
if params.ReplicationType == "regional-pd" && disk.Type() != Regional && disk.Type() != RegionalAlpha {
299299
return fmt.Errorf("actual disk replication type %v did not match expected param %s", disk.Type(), "regional-pd")
300300
}
301301

@@ -393,7 +393,7 @@ func (cloud *CloudProvider) insertRegionalDisk(ctx context.Context, volKey *meta
393393
}
394394
if err != nil {
395395
if IsGCEError(err, "alreadyExists") {
396-
disk, err := cloud.GetDisk(ctx, volKey, GCEAPIVersionV1)
396+
disk, err := cloud.GetDisk(ctx, volKey, gceAPIVersion)
397397
if err != nil {
398398
return err
399399
}
@@ -413,7 +413,7 @@ func (cloud *CloudProvider) insertRegionalDisk(ctx context.Context, volKey *meta
413413
err = cloud.waitForRegionalOp(ctx, opName, volKey.Region)
414414
if err != nil {
415415
if IsGCEError(err, "alreadyExists") {
416-
disk, err := cloud.GetDisk(ctx, volKey, GCEAPIVersionV1)
416+
disk, err := cloud.GetDisk(ctx, volKey, gceAPIVersion)
417417
if err != nil {
418418
return err
419419
}
@@ -723,16 +723,6 @@ func opIsDone(op *computev1.Operation) (bool, error) {
723723
return true, nil
724724
}
725725

726-
func alphaOpIsDone(op *computealpha.Operation) (bool, error) {
727-
if op == nil || op.Status != operationStatusDone {
728-
return false, nil
729-
}
730-
if op.Error != nil && len(op.Error.Errors) > 0 && op.Error.Errors[0] != nil {
731-
return true, fmt.Errorf("operation %v failed (%v): %v", op.Name, op.Error.Errors[0].Code, op.Error.Errors[0].Message)
732-
}
733-
return true, nil
734-
}
735-
736726
func (cloud *CloudProvider) GetInstanceOrError(ctx context.Context, instanceZone, instanceName string) (*computev1.Instance, error) {
737727
klog.V(5).Infof("Getting instance %v from zone %v", instanceName, instanceZone)
738728
svc := cloud.service

test/e2e/tests/single_zone_e2e_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ import (
3737
"google.golang.org/api/iterator"
3838
kmspb "google.golang.org/genproto/googleapis/cloud/kms/v1"
3939
fieldmask "google.golang.org/genproto/protobuf/field_mask"
40-
testutils "sigs.k8s.io/gcp-compute-persistent-disk-csi-driver/test/e2e/utils"
4140
)
4241

4342
const (

0 commit comments

Comments
 (0)