Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Metro volume expand support #350

Merged
merged 18 commits into from
Oct 7, 2024
Merged
Changes from 3 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
61 changes: 56 additions & 5 deletions pkg/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -1286,9 +1286,26 @@
}, nil
}

func pauseSessionIfMetro(isMetroSession bool, powerStoreClient gopowerstore.Client, ctx context.Context, id string) (gopowerstore.EmptyResponse, error) {

Check warning on line 1289 in pkg/controller/controller.go

View workflow job for this annotation

GitHub Actions / golangci-lint

context-as-argument: context.Context should be the first parameter of a function (revive)
aqu-dell marked this conversation as resolved.
Show resolved Hide resolved
if isMetroSession {
var params *gopowerstore.FailoverParams
return powerStoreClient.ExecuteActionOnReplicationSession(ctx, id, "pause", params)
aqu-dell marked this conversation as resolved.
Show resolved Hide resolved
}

return "", nil
}

func resumeSessionIfMetro(isMetroSession bool, powerStoreClient gopowerstore.Client, ctx context.Context, id string) (gopowerstore.EmptyResponse, error) {

Check warning on line 1298 in pkg/controller/controller.go

View workflow job for this annotation

GitHub Actions / golangci-lint

context-as-argument: context.Context should be the first parameter of a function (revive)
aqu-dell marked this conversation as resolved.
Show resolved Hide resolved
if isMetroSession {
var params *gopowerstore.FailoverParams
powerStoreClient.ExecuteActionOnReplicationSession(ctx, id, "resume", params)
aqu-dell marked this conversation as resolved.
Show resolved Hide resolved
}
return "", nil
}

// ControllerExpandVolume resizes Volume or FileSystem by increasing available volume capacity in the storage array.
func (s *Service) ControllerExpandVolume(ctx context.Context, req *csi.ControllerExpandVolumeRequest) (*csi.ControllerExpandVolumeResponse, error) {
id, arrayID, protocol, _, _, err := array.ParseVolumeID(ctx, req.VolumeId, s.DefaultArray(), nil)
id, arrayID, protocol, _, remoteArrayID, err := array.ParseVolumeID(ctx, req.VolumeId, s.DefaultArray(), nil)
if err != nil {
return nil, status.Errorf(codes.OutOfRange, "unable to parse the volume id")
}
Expand All @@ -1298,24 +1315,58 @@
return nil, status.Errorf(codes.OutOfRange, "volume exceeds allowed limit")
}

powerStoreClient := s.Arrays()[arrayID].Client
aqu-dell marked this conversation as resolved.
Show resolved Hide resolved

if protocol == "scsi" {
vol, err := s.Arrays()[arrayID].Client.GetVolume(ctx, id)
vol, err := powerStoreClient.GetVolume(ctx, id)
if err != nil {
return nil, status.Errorf(codes.OutOfRange, "detected SCSI protocol but wasn't able to fetch the volume info")
}
isMetroSession := remoteArrayID != ""

// get session id
replicationSessionId := ""

Check warning on line 1328 in pkg/controller/controller.go

View workflow job for this annotation

GitHub Actions / golangci-lint

var-naming: var replicationSessionId should be replicationSessionID (revive)
if isMetroSession {
vgs, err := powerStoreClient.GetVolumeGroupsByVolumeID(ctx, req.GetVolumeId())
if err != nil {
return nil, err
}
if len(vgs.VolumeGroup) == 0 {
replicationSessionId = vol.MetroReplicationSessionID
} else {
vg := vgs.VolumeGroup[0]
rs, err := powerStoreClient.GetReplicationSessionByLocalResourceID(ctx, vg.ID)
if err != nil {
return nil, err
aqu-dell marked this conversation as resolved.
Show resolved Hide resolved
}
replicationSessionId = rs.ID
aqu-dell marked this conversation as resolved.
Show resolved Hide resolved
}
}

if vol.Size < requiredBytes {
_, err = s.Arrays()[arrayID].Client.ModifyVolume(context.Background(), &gopowerstore.VolumeModify{Size: requiredBytes}, id)
_, err = pauseSessionIfMetro(isMetroSession, powerStoreClient, ctx, replicationSessionId)
if err != nil {
return nil, err
}

_, err = powerStoreClient.ModifyVolume(context.Background(), &gopowerstore.VolumeModify{Size: requiredBytes}, id)
aqu-dell marked this conversation as resolved.
Show resolved Hide resolved

_, resumeSessionErr := resumeSessionIfMetro(isMetroSession, powerStoreClient, ctx, replicationSessionId)
if resumeSessionErr != nil {
return nil, resumeSessionErr
}

if err != nil {
return nil, err
}
return &csi.ControllerExpandVolumeResponse{CapacityBytes: requiredBytes, NodeExpansionRequired: true}, nil
}
return &csi.ControllerExpandVolumeResponse{}, nil
}
fs, err := s.Arrays()[arrayID].Client.GetFS(ctx, id)
fs, err := powerStoreClient.GetFS(ctx, id)
if err == nil {
if fs.SizeTotal < requiredBytes {
_, err = s.Arrays()[arrayID].Client.ModifyFS(context.Background(), &gopowerstore.FSModify{Size: int(requiredBytes + ReservedSize)}, id)
_, err = powerStoreClient.ModifyFS(context.Background(), &gopowerstore.FSModify{Size: int(requiredBytes + ReservedSize)}, id)
if err != nil {
return nil, err
}
Expand Down
Loading