Skip to content

Commit 80468c5

Browse files
sjswerdlowtonyzhc
authored andcommitted
Addressing comments around GetMultiWriter checks.
1 parent 5d5d19e commit 80468c5

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,17 @@ func (d *CloudDisk) GetKMSKeyName() string {
224224
return ""
225225
}
226226

227+
func (d *CloudDisk) GetMultiWriter() bool {
228+
switch {
229+
case d.disk != nil:
230+
return false
231+
case d.betaDisk != nil:
232+
return d.betaDisk.MultiWriter
233+
default:
234+
return false
235+
}
236+
}
237+
227238
func (d *CloudDisk) GetEnableConfidentialCompute() bool {
228239
switch {
229240
case d.disk != nil:

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,10 @@ func (cloud *FakeCloudProvider) ValidateExistingDisk(ctx context.Context, resp *
216216
params.DiskType, respType[len(respType)-1])
217217
}
218218

219+
// We are assuming here that a multiWriter disk could be used as non-multiWriter
220+
if multiWriter && !resp.GetMultiWriter() {
221+
return fmt.Errorf("disk already exists with incompatible capability. Need MultiWriter. Got non-MultiWriter")
222+
}
219223
klog.V(4).Infof("Compatible disk already exists")
220224
return ValidateDiskParameters(resp, params)
221225
}

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

Lines changed: 5 additions & 0 deletions
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)