Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions mock/service/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,11 @@ func (s *service) ControllerPublishVolume(
v.VolumeContext[ReadOnlyKey] = roVal
s.vols[i] = v

if volInfo, ok := MockVolumes[req.VolumeId]; ok {
volInfo.ISControllerPublished = true
MockVolumes[req.VolumeId] = volInfo
}

if hookVal, hookMsg := s.execHook("ControllerPublishVolumeEnd"); hookVal != codes.OK {
return nil, status.Errorf(hookVal, hookMsg)
}
Expand Down Expand Up @@ -623,8 +628,8 @@ func (s *service) ControllerExpandVolume(
return nil, status.Error(codes.NotFound, req.VolumeId)
}

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

requestBytes := req.CapacityRange.RequiredBytes
Expand Down
16 changes: 8 additions & 8 deletions mock/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,14 @@ type service struct {
}

type Volume struct {
sync.Mutex
VolumeCSI csi.Volume
NodeID string
ISStaged bool
ISPublished bool
ISEphemeral bool
StageTargetPath string
TargetPath string
VolumeCSI csi.Volume
NodeID string
ISStaged bool
ISPublished bool
ISEphemeral bool
ISControllerPublished bool
StageTargetPath string
TargetPath string
}

var MockVolumes map[string]Volume
Expand Down