Skip to content

Commit 4b4f3b8

Browse files
committed
Addressing comments around GetMultiWriter checks.
1 parent a06549f commit 4b4f3b8

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

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

+11
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,17 @@ func (d *CloudDisk) GetKMSKeyName() string {
213213
return ""
214214
}
215215

216+
func (d *CloudDisk) GetMultiWriter() bool {
217+
switch {
218+
case d.disk != nil:
219+
return false
220+
case d.betaDisk != nil:
221+
return d.betaDisk.MultiWriter
222+
default:
223+
return false
224+
}
225+
}
226+
216227
func (d *CloudDisk) GetEnableConfidentialCompute() bool {
217228
switch {
218229
case d.disk != nil:

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

+4
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,10 @@ func (cloud *FakeCloudProvider) ValidateExistingDisk(ctx context.Context, resp *
212212
params.DiskType, respType[len(respType)-1])
213213
}
214214

215+
// We are assuming here that a multiWriter disk could be used as non-multiWriter
216+
if multiWriter && !resp.GetMultiWriter() {
217+
return fmt.Errorf("disk already exists with incompatible capability. Need MultiWriter. Got non-MultiWriter")
218+
}
215219
klog.V(4).Infof("Compatible disk already exists")
216220
return ValidateDiskParameters(resp, params)
217221
}

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

+5
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,11 @@ func (cloud *CloudProvider) ValidateExistingDisk(ctx context.Context, resp *Clou
395395
reqBytes, common.GbToBytes(resp.GetSizeGb()), limBytes)
396396
}
397397

398+
// We are assuming here that a multiWriter disk could be used as non-multiWriter
399+
if multiWriter && !resp.GetMultiWriter() {
400+
return fmt.Errorf("disk already exists with incompatible capability. Need MultiWriter. Got non-MultiWriter")
401+
}
402+
398403
return ValidateDiskParameters(resp, params)
399404
}
400405

0 commit comments

Comments
 (0)