Skip to content

Commit 37e19fd

Browse files
committed
adds the changes to support hyperdisk multi-writer mode and updates to e2e tests
1 parent c29a4ee commit 37e19fd

File tree

4 files changed

+11
-26
lines changed

4 files changed

+11
-26
lines changed

pkg/common/parameters.go

+4
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ type DiskParameters struct {
106106
// Values: {bool}
107107
// Default: false
108108
MultiZoneProvisioning bool
109+
// Values: READ_WRITE_SINGLE, READ_ONLY_MANY, READ_WRITE_MANY
110+
// Default: READ_WRITE_SINGLE
111+
AccessMode string
109112
}
110113

111114
// SnapshotParameters contains normalized and defaulted parameters for snapshots
@@ -148,6 +151,7 @@ func (pp *ParameterProcessor) ExtractAndDefaultParameters(parameters map[string]
148151
Tags: make(map[string]string), // Default
149152
Labels: make(map[string]string), // Default
150153
ResourceTags: make(map[string]string), // Default
154+
AccessMode: "READ_WRITE_SINGLE", // Default
151155
}
152156

153157
for k, v := range extraVolumeLabels {

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

+2
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,8 @@ func (d *CloudDisk) GetMultiWriter() bool {
217217
switch {
218218
case d.disk != nil:
219219
return false
220+
case d.disk != nil && d.disk.AccessMode == "READ_WRITE_MANY":
221+
return true
220222
case d.betaDisk != nil:
221223
return d.betaDisk.MultiWriter
222224
default:

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

-20
Original file line numberDiff line numberDiff line change
@@ -324,8 +324,6 @@ func (cloud *CloudProvider) ListSnapshots(ctx context.Context, filter string) ([
324324
func (cloud *CloudProvider) GetDisk(ctx context.Context, project string, key *meta.Key, gceAPIVersion GCEAPIVersion) (*CloudDisk, error) {
325325
klog.V(5).Infof("Getting disk %v", key)
326326

327-
// Override GCEAPIVersion as hyperdisk is only available in beta and we cannot get the disk-type with get disk call.
328-
gceAPIVersion = GCEAPIVersionBeta
329327
switch key.Type() {
330328
case meta.Zonal:
331329
if gceAPIVersion == GCEAPIVersionBeta {
@@ -407,11 +405,6 @@ func (cloud *CloudProvider) ValidateExistingDisk(ctx context.Context, resp *Clou
407405
reqBytes, common.GbToBytes(resp.GetSizeGb()), limBytes)
408406
}
409407

410-
// We are assuming here that a multiWriter disk could be used as non-multiWriter
411-
if multiWriter && !resp.GetMultiWriter() {
412-
return fmt.Errorf("disk already exists with incompatible capability. Need MultiWriter. Got non-MultiWriter")
413-
}
414-
415408
return ValidateDiskParameters(resp, params)
416409
}
417410

@@ -553,9 +546,6 @@ func convertV1DiskToBetaDisk(v1Disk *computev1.Disk) *computebeta.Disk {
553546
AccessMode: v1Disk.AccessMode,
554547
}
555548

556-
// Hyperdisk doesn't currently support multiWriter (https://cloud.google.com/compute/docs/disks/hyperdisks#limitations),
557-
// but if multiWriter + hyperdisk is supported in the future, we want the PDCSI driver to support this feature without
558-
// any additional code change.
559549
if v1Disk.ProvisionedIops > 0 {
560550
betaDisk.ProvisionedIops = v1Disk.ProvisionedIops
561551
}
@@ -619,9 +609,6 @@ func convertBetaDiskToV1Disk(betaDisk *computebeta.Disk) *computev1.Disk {
619609
AccessMode: betaDisk.AccessMode,
620610
}
621611

622-
// Hyperdisk doesn't currently support multiWriter (https://cloud.google.com/compute/docs/disks/hyperdisks#limitations),
623-
// but if multiWriter + hyperdisk is supported in the future, we want the PDCSI driver to support this feature without
624-
// any additional code change.
625612
if betaDisk.ProvisionedIops > 0 {
626613
v1Disk.ProvisionedIops = betaDisk.ProvisionedIops
627614
}
@@ -651,10 +638,6 @@ func (cloud *CloudProvider) insertRegionalDisk(
651638
gceAPIVersion = GCEAPIVersionV1
652639
)
653640

654-
if multiWriter {
655-
gceAPIVersion = GCEAPIVersionBeta
656-
}
657-
658641
diskToCreate := &computev1.Disk{
659642
Name: volKey.Name,
660643
SizeGb: common.BytesToGbRoundUp(capBytes),
@@ -778,9 +761,6 @@ func (cloud *CloudProvider) insertZonalDisk(
778761
opName string
779762
gceAPIVersion = GCEAPIVersionV1
780763
)
781-
if multiWriter {
782-
gceAPIVersion = GCEAPIVersionBeta
783-
}
784764

785765
diskToCreate := &computev1.Disk{
786766
Name: volKey.Name,

test/e2e/tests/single_zone_e2e_test.go

+5-6
Original file line numberDiff line numberDiff line change
@@ -904,8 +904,7 @@ var _ = Describe("GCE PD CSI Driver", func() {
904904
Expect(err).To(BeNil(), "Failed to go through volume lifecycle")
905905
})
906906

907-
// Pending while multi-writer feature is in Alpha
908-
PIt("Should create and delete multi-writer disk", func() {
907+
It("Should create and delete multi-writer disk", func() {
909908
Expect(testContexts).ToNot(BeEmpty())
910909
testContext := getRandomTestContext()
911910

@@ -916,7 +915,7 @@ var _ = Describe("GCE PD CSI Driver", func() {
916915
zone := "us-east1-a"
917916

918917
// Create and Validate Disk
919-
volName, volID := createAndValidateUniqueZonalMultiWriterDisk(client, p, zone, standardDiskType)
918+
volName, volID := createAndValidateUniqueZonalMultiWriterDisk(client, p, zone, hdbDiskType)
920919

921920
defer func() {
922921
// Delete Disk
@@ -929,16 +928,15 @@ var _ = Describe("GCE PD CSI Driver", func() {
929928
}()
930929
})
931930

932-
// Pending while multi-writer feature is in Alpha
933-
PIt("Should complete entire disk lifecycle with multi-writer disk", func() {
931+
It("Should complete entire disk lifecycle with multi-writer disk", func() {
934932
testContext := getRandomTestContext()
935933

936934
p, z, _ := testContext.Instance.GetIdentity()
937935
client := testContext.Client
938936
instance := testContext.Instance
939937

940938
// Create and Validate Disk
941-
volName, volID := createAndValidateUniqueZonalMultiWriterDisk(client, p, z, standardDiskType)
939+
volName, volID := createAndValidateUniqueZonalMultiWriterDisk(client, p, z, hdbDiskType)
942940

943941
defer func() {
944942
// Delete Disk
@@ -1710,6 +1708,7 @@ func deleteVolumeOrError(client *remote.CsiClient, volID string) {
17101708
func createAndValidateUniqueZonalMultiWriterDisk(client *remote.CsiClient, project, zone string, diskType string) (string, string) {
17111709
// Create Disk
17121710
disk := typeToDisk[diskType]
1711+
disk.params.AccessMode = "READ_WRITE_MANY"
17131712
volName := testNamePrefix + string(uuid.NewUUID())
17141713
volume, err := client.CreateVolumeWithCaps(volName, disk.params, defaultMwSizeGb,
17151714
&csi.TopologyRequirement{

0 commit comments

Comments
 (0)