diff --git a/mock/service/controller.go b/mock/service/controller.go index 09c2e011..e759b1b5 100644 --- a/mock/service/controller.go +++ b/mock/service/controller.go @@ -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) } @@ -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 diff --git a/mock/service/service.go b/mock/service/service.go index 924d1d41..c45298fb 100644 --- a/mock/service/service.go +++ b/mock/service/service.go @@ -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