Skip to content

Commit c9c424e

Browse files
authored
Merge pull request #265 from gnufied/actually-enforce-offline-expansion
Enforce offline volume expansion
2 parents 6c94ad2 + c8940c4 commit c9c424e

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

mock/service/controller.go

+7-2
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,11 @@ func (s *service) ControllerPublishVolume(
227227
v.VolumeContext[ReadOnlyKey] = roVal
228228
s.vols[i] = v
229229

230+
if volInfo, ok := MockVolumes[req.VolumeId]; ok {
231+
volInfo.ISControllerPublished = true
232+
MockVolumes[req.VolumeId] = volInfo
233+
}
234+
230235
if hookVal, hookMsg := s.execHook("ControllerPublishVolumeEnd"); hookVal != codes.OK {
231236
return nil, status.Errorf(hookVal, hookMsg)
232237
}
@@ -623,8 +628,8 @@ func (s *service) ControllerExpandVolume(
623628
return nil, status.Error(codes.NotFound, req.VolumeId)
624629
}
625630

626-
if s.config.DisableOnlineExpansion && MockVolumes[v.GetVolumeId()].ISPublished {
627-
return nil, status.Error(codes.Aborted, "volume is published and online volume expansion is not supported")
631+
if s.config.DisableOnlineExpansion && MockVolumes[v.GetVolumeId()].ISControllerPublished {
632+
return nil, status.Error(codes.FailedPrecondition, "volume is published and online volume expansion is not supported")
628633
}
629634

630635
requestBytes := req.CapacityRange.RequiredBytes

mock/service/service.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,14 @@ type service struct {
109109
}
110110

111111
type Volume struct {
112-
sync.Mutex
113-
VolumeCSI csi.Volume
114-
NodeID string
115-
ISStaged bool
116-
ISPublished bool
117-
ISEphemeral bool
118-
StageTargetPath string
119-
TargetPath string
112+
VolumeCSI csi.Volume
113+
NodeID string
114+
ISStaged bool
115+
ISPublished bool
116+
ISEphemeral bool
117+
ISControllerPublished bool
118+
StageTargetPath string
119+
TargetPath string
120120
}
121121

122122
var MockVolumes map[string]Volume

0 commit comments

Comments
 (0)