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

RWOP (Read Write Once Pod) support #48

Merged
merged 1 commit into from
Jan 28, 2022
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
11 changes: 11 additions & 0 deletions service/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -2254,6 +2254,10 @@ func valVolumeCaps(
break
case csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER:
break
case csi.VolumeCapability_AccessMode_SINGLE_NODE_SINGLE_WRITER:
break
case csi.VolumeCapability_AccessMode_SINGLE_NODE_MULTI_WRITER:
break
case csi.VolumeCapability_AccessMode_SINGLE_NODE_READER_ONLY:
break
case csi.VolumeCapability_AccessMode_MULTI_NODE_READER_ONLY:
Expand Down Expand Up @@ -2430,6 +2434,13 @@ func (s *service) ControllerGetCapabilities(
},
},
},
{
Type: &csi.ControllerServiceCapability_Rpc{
Rpc: &csi.ControllerServiceCapability_RPC{
Type: csi.ControllerServiceCapability_RPC_SINGLE_NODE_MULTI_WRITER,
},
},
},
},
}, nil
}
Expand Down
19 changes: 14 additions & 5 deletions service/mount.go
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,9 @@ func handlePrivFSMount(
return status.Errorf(codes.Internal, "error performing private mount: %s", err.Error())
}
return nil
} else if accMode.GetMode() == csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER {
} else if (accMode.GetMode() == csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER) ||
(accMode.GetMode() == csi.VolumeCapability_AccessMode_SINGLE_NODE_SINGLE_WRITER) ||
(accMode.GetMode() == csi.VolumeCapability_AccessMode_SINGLE_NODE_MULTI_WRITER) {
if err := gofsutil.FormatAndMount(formatCtx, sysDevice.FullPath, privTgt, fs, mntFlags...); err != nil {
return status.Errorf(codes.Internal, "error performing private mount: %s", err.Error())
}
Expand Down Expand Up @@ -663,7 +665,9 @@ func validateVolumeCapability(volCap *csi.VolumeCapability, readOnly bool) (bool
switch accMode.GetMode() {
case csi.VolumeCapability_AccessMode_UNKNOWN:
return true, mntVol, accMode, "", status.Error(codes.InvalidArgument, "Unknown Access Mode")
case csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER:
case csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER,
csi.VolumeCapability_AccessMode_SINGLE_NODE_SINGLE_WRITER,
csi.VolumeCapability_AccessMode_SINGLE_NODE_MULTI_WRITER:
case csi.VolumeCapability_AccessMode_SINGLE_NODE_READER_ONLY:
case csi.VolumeCapability_AccessMode_MULTI_NODE_READER_ONLY:
multiAccessFlag = "ro"
Expand All @@ -681,7 +685,9 @@ func validateVolumeCapability(volCap *csi.VolumeCapability, readOnly bool) (bool
switch accMode.GetMode() {
case csi.VolumeCapability_AccessMode_UNKNOWN:
return false, mntVol, accMode, "", status.Error(codes.InvalidArgument, "Unknown Access Mode")
case csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER:
case csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER,
csi.VolumeCapability_AccessMode_SINGLE_NODE_SINGLE_WRITER,
csi.VolumeCapability_AccessMode_SINGLE_NODE_MULTI_WRITER:
case csi.VolumeCapability_AccessMode_SINGLE_NODE_READER_ONLY:
case csi.VolumeCapability_AccessMode_MULTI_NODE_READER_ONLY:
multiAccessFlag = "ro"
Expand All @@ -697,10 +703,13 @@ func validateVolumeCapability(volCap *csi.VolumeCapability, readOnly bool) (bool
return isBlock, mntVol, accMode, multiAccessFlag, nil
}

// singleAccessMode returns true if only a single access is allowed SINGLE_NODE_WRITER or SINGLE_NODE_READER_ONLY
// singleAccessMode returns true if only a single access is allowed SINGLE_NODE_WRITER, SINGLE_NODE_SINGLE_WRITER,
// SINGLE_NODE_MULTI_WRITER or SINGLE_NODE_READER_ONLY
func singleAccessMode(accMode *csi.VolumeCapability_AccessMode) bool {
switch accMode.GetMode() {
case csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER:
case csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER,
csi.VolumeCapability_AccessMode_SINGLE_NODE_SINGLE_WRITER,
csi.VolumeCapability_AccessMode_SINGLE_NODE_MULTI_WRITER:
return true
case csi.VolumeCapability_AccessMode_SINGLE_NODE_READER_ONLY:
return true
Expand Down
7 changes: 7 additions & 0 deletions service/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -740,6 +740,13 @@ func (s *service) NodeGetCapabilities(
},
},
},
{
Type: &csi.NodeServiceCapability_Rpc{
Rpc: &csi.NodeServiceCapability_RPC{
Type: csi.NodeServiceCapability_RPC_SINGLE_NODE_MULTI_WRITER,
},
},
},
},
}, nil
}
Expand Down
2 changes: 2 additions & 0 deletions service/storage_group_svc.go
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,8 @@ func (g *storageGroupSvc) addVolumeToSGMVVolumeCheck(ctx context.Context, client
}
switch am.Mode {
case csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER,
csi.VolumeCapability_AccessMode_SINGLE_NODE_SINGLE_WRITER,
csi.VolumeCapability_AccessMode_SINGLE_NODE_MULTI_WRITER,
csi.VolumeCapability_AccessMode_SINGLE_NODE_READER_ONLY:
// Check if the volume is already mapped to some host
if vol.NumberOfFrontEndPaths > 0 {
Expand Down