ci: fix all linter errors found in golangci-lint

Fixing all the linter errors found in golang-ci
lint v1.46.2

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
Madhu Rajanna 2022-06-01 15:47:19 +05:30 committed by mergify[bot]
parent 9e5cad173d
commit 1952a9b4b3
56 changed files with 348 additions and 195 deletions

View File

@ -59,7 +59,6 @@ func getConfig() *retestConfig {
if len(strings.Split(os.Getenv("GITHUB_REPOSITORY"), "/")) == 2 { if len(strings.Split(os.Getenv("GITHUB_REPOSITORY"), "/")) == 2 {
return strings.Split(os.Getenv("GITHUB_REPOSITORY"), "/")[0], strings.Split(os.Getenv("GITHUB_REPOSITORY"), "/")[1] return strings.Split(os.Getenv("GITHUB_REPOSITORY"), "/")[0], strings.Split(os.Getenv("GITHUB_REPOSITORY"), "/")[1]
} }
} }
return "", "" return "", ""
}() }()
@ -168,7 +167,7 @@ func main() {
log.Printf("failed to create comment %v\n", err) log.Printf("failed to create comment %v\n", err)
continue continue
} }
//Post comment with target URL for retesting // Post comment with target URL for retesting
msg = fmt.Sprintf("@%s %q test failed. Logs are available at [location](%s) for debugging", re.GetUser().GetLogin(), r.GetContext(), r.GetTargetURL()) msg = fmt.Sprintf("@%s %q test failed. Logs are available at [location](%s) for debugging", re.GetUser().GetLogin(), r.GetContext(), r.GetTargetURL())
comment.Body = github.String(msg) comment.Body = github.String(msg)
_, _, err = c.client.Issues.CreateComment(context.TODO(), c.owner, c.repo, prNumber, comment) _, _, err = c.client.Issues.CreateComment(context.TODO(), c.owner, c.repo, prNumber, comment)

View File

@ -55,7 +55,7 @@ func TestNewSecurityContextConstraints(t *testing.T) {
rookValues := SecurityContextConstraintsValues{ rookValues := SecurityContextConstraintsValues{
Namespace: "rook-ceph", Namespace: "rook-ceph",
Deployer: "rook", Deployer: "rook",
} }
getSCC := func() { getSCC := func() {
@ -77,7 +77,7 @@ func TestNewSecurityContextConstraintsYAML(t *testing.T) {
t.Parallel() t.Parallel()
var ( var (
err error err error
yaml string yaml string
) )

View File

@ -514,8 +514,8 @@ var _ = Describe(cephfsType, func() {
e2elog.Failf("failed to list pods for Deployment: %v", err) e2elog.Failf("failed to list pods for Deployment: %v", err)
} }
doStat := func(podName string) (stdErr string, err error) { doStat := func(podName string) (string, error) {
_, stdErr, err = execCommandInContainerByPodName( _, stdErr, execErr := execCommandInContainerByPodName(
f, f,
fmt.Sprintf("stat %s", depl.Spec.Template.Spec.Containers[0].VolumeMounts[0].MountPath), fmt.Sprintf("stat %s", depl.Spec.Template.Spec.Containers[0].VolumeMounts[0].MountPath),
depl.Namespace, depl.Namespace,
@ -523,7 +523,7 @@ var _ = Describe(cephfsType, func() {
depl.Spec.Template.Spec.Containers[0].Name, depl.Spec.Template.Spec.Containers[0].Name,
) )
return stdErr, err return stdErr, execErr
} }
ensureStatSucceeds := func(podName string) error { ensureStatSucceeds := func(podName string) error {
stdErr, statErr := doStat(podName) stdErr, statErr := doStat(podName)

View File

@ -60,7 +60,8 @@ func createCephfsStorageClass(
c kubernetes.Interface, c kubernetes.Interface,
f *framework.Framework, f *framework.Framework,
enablePool bool, enablePool bool,
params map[string]string) error { params map[string]string,
) error {
scPath := fmt.Sprintf("%s/%s", cephFSExamplePath, "storageclass.yaml") scPath := fmt.Sprintf("%s/%s", cephFSExamplePath, "storageclass.yaml")
sc, err := getStorageClass(scPath) sc, err := getStorageClass(scPath)
if err != nil { if err != nil {
@ -253,7 +254,8 @@ func getSnapName(snapNamespace, snapName string) (string, error) {
func deleteBackingCephFSSubvolumeSnapshot( func deleteBackingCephFSSubvolumeSnapshot(
f *framework.Framework, f *framework.Framework,
pvc *v1.PersistentVolumeClaim, pvc *v1.PersistentVolumeClaim,
snap *snapapi.VolumeSnapshot) error { snap *snapapi.VolumeSnapshot,
) error {
snapshotName, err := getSnapName(snap.Namespace, snap.Name) snapshotName, err := getSnapName(snap.Namespace, snap.Name)
if err != nil { if err != nil {
return err return err

View File

@ -30,7 +30,8 @@ func validateBiggerCloneFromPVC(f *framework.Framework,
pvcPath, pvcPath,
appPath, appPath,
pvcClonePath, pvcClonePath,
appClonePath string) error { appClonePath string,
) error {
const ( const (
size = "1Gi" size = "1Gi"
newSize = "2Gi" newSize = "2Gi"

View File

@ -95,7 +95,8 @@ func createConfigMap(pluginPath string, c kubernetes.Interface, f *framework.Fra
func createCustomConfigMap( func createCustomConfigMap(
c kubernetes.Interface, c kubernetes.Interface,
pluginPath string, pluginPath string,
clusterInfo map[string]map[string]string) error { clusterInfo map[string]map[string]string,
) error {
path := pluginPath + configMap path := pluginPath + configMap
cm := v1.ConfigMap{} cm := v1.ConfigMap{}
err := unmarshal(path, &cm) err := unmarshal(path, &cm)

View File

@ -40,7 +40,8 @@ func execCommandInPodWithName(
cmdString, cmdString,
podName, podName,
containerName, containerName,
nameSpace string) (string, string, error) { nameSpace string,
) (string, string, error) {
cmd := []string{"/bin/sh", "-c", cmdString} cmd := []string{"/bin/sh", "-c", cmdString}
podOpt := framework.ExecOptions{ podOpt := framework.ExecOptions{
Command: cmd, Command: cmd,

View File

@ -143,7 +143,8 @@ func createNFSStorageClass(
c clientset.Interface, c clientset.Interface,
f *framework.Framework, f *framework.Framework,
enablePool bool, enablePool bool,
params map[string]string) error { params map[string]string,
) error {
scPath := fmt.Sprintf("%s/%s", nfsExamplePath, "storageclass.yaml") scPath := fmt.Sprintf("%s/%s", nfsExamplePath, "storageclass.yaml")
sc, err := getStorageClass(scPath) sc, err := getStorageClass(scPath)
if err != nil { if err != nil {

View File

@ -136,7 +136,8 @@ func findPodAndContainerName(f *framework.Framework, ns, cn string, opt *metav1.
func getCommandInPodOpts( func getCommandInPodOpts(
f *framework.Framework, f *framework.Framework,
c, ns, cn string, c, ns, cn string,
opt *metav1.ListOptions) (framework.ExecOptions, error) { opt *metav1.ListOptions,
) (framework.ExecOptions, error) {
cmd := []string{"/bin/sh", "-c", c} cmd := []string{"/bin/sh", "-c", c}
pName, cName, err := findPodAndContainerName(f, ns, cn, opt) pName, cName, err := findPodAndContainerName(f, ns, cn, opt)
if err != nil { if err != nil {
@ -161,7 +162,8 @@ func getCommandInPodOpts(
// stderr is returned as a string, and err will be set on a failure. // stderr is returned as a string, and err will be set on a failure.
func execCommandInDaemonsetPod( func execCommandInDaemonsetPod(
f *framework.Framework, f *framework.Framework,
c, daemonsetName, nodeName, containerName, ns string) (string, error) { c, daemonsetName, nodeName, containerName, ns string,
) (string, error) {
selector, err := getDaemonSetLabelSelector(f, ns, daemonsetName) selector, err := getDaemonSetLabelSelector(f, ns, daemonsetName)
if err != nil { if err != nil {
return "", err return "", err
@ -224,7 +226,8 @@ func execCommandInPod(f *framework.Framework, c, ns string, opt *metav1.ListOpti
} }
func execCommandInContainer( func execCommandInContainer(
f *framework.Framework, c, ns, cn string, opt *metav1.ListOptions) (string, string, error) { f *framework.Framework, c, ns, cn string, opt *metav1.ListOptions,
) (string, string, error) {
podOpt, err := getCommandInPodOpts(f, c, ns, cn, opt) podOpt, err := getCommandInPodOpts(f, c, ns, cn, opt)
if err != nil { if err != nil {
return "", "", err return "", "", err
@ -468,7 +471,8 @@ func validateRWOPPodCreation(
f *framework.Framework, f *framework.Framework,
pvc *v1.PersistentVolumeClaim, pvc *v1.PersistentVolumeClaim,
app *v1.Pod, app *v1.Pod,
baseAppName string) error { baseAppName string,
) error {
var err error var err error
// create one more app with same PVC // create one more app with same PVC
name := fmt.Sprintf("%s%d", f.UniqueName, deployTimeout) name := fmt.Sprintf("%s%d", f.UniqueName, deployTimeout)

View File

@ -239,7 +239,8 @@ func getPersistentVolume(c kubernetes.Interface, name string) (*v1.PersistentVol
func getPVCAndPV( func getPVCAndPV(
c kubernetes.Interface, c kubernetes.Interface,
pvcName, pvcNamespace string) (*v1.PersistentVolumeClaim, *v1.PersistentVolume, error) { pvcName, pvcNamespace string,
) (*v1.PersistentVolumeClaim, *v1.PersistentVolume, error) {
pvc, err := getPersistentVolumeClaim(c, pvcNamespace, pvcName) pvc, err := getPersistentVolumeClaim(c, pvcNamespace, pvcName)
if err != nil { if err != nil {
return nil, nil, fmt.Errorf("failed to get PVC: %w", err) return nil, nil, fmt.Errorf("failed to get PVC: %w", err)

View File

@ -117,7 +117,8 @@ func createRBDStorageClass(
f *framework.Framework, f *framework.Framework,
name string, name string,
scOptions, parameters map[string]string, scOptions, parameters map[string]string,
policy v1.PersistentVolumeReclaimPolicy) error { policy v1.PersistentVolumeReclaimPolicy,
) error {
scPath := fmt.Sprintf("%s/%s", rbdExamplePath, "storageclass.yaml") scPath := fmt.Sprintf("%s/%s", rbdExamplePath, "storageclass.yaml")
sc, err := getStorageClass(scPath) sc, err := getStorageClass(scPath)
if err != nil { if err != nil {
@ -281,7 +282,7 @@ func getImageMeta(rbdImageSpec, metaKey string, f *framework.Framework) (string,
return "", err return "", err
} }
if stdErr != "" { if stdErr != "" {
return strings.TrimSpace(stdOut), fmt.Errorf(stdErr) return strings.TrimSpace(stdOut), fmt.Errorf("%s", stdErr)
} }
return strings.TrimSpace(stdOut), nil return strings.TrimSpace(stdOut), nil
@ -757,7 +758,8 @@ func checkPVCImageInPool(f *framework.Framework, pvc *v1.PersistentVolumeClaim,
func checkPVCDataPoolForImageInPool( func checkPVCDataPoolForImageInPool(
f *framework.Framework, f *framework.Framework,
pvc *v1.PersistentVolumeClaim, pvc *v1.PersistentVolumeClaim,
pool, dataPool string) error { pool, dataPool string,
) error {
stdOut, err := getPVCImageInfoInPool(f, pvc, pool) stdOut, err := getPVCImageInfoInPool(f, pvc, pool)
if err != nil { if err != nil {
return err return err

View File

@ -300,7 +300,8 @@ func validateBiggerPVCFromSnapshot(f *framework.Framework,
appPath, appPath,
snapPath, snapPath,
pvcClonePath, pvcClonePath,
appClonePath string) error { appClonePath string,
) error {
const ( const (
size = "1Gi" size = "1Gi"
newSize = "2Gi" newSize = "2Gi"

View File

@ -41,7 +41,8 @@ const (
func getStaticPV( func getStaticPV(
name, volName, size, secretName, secretNS, sc, driverName string, name, volName, size, secretName, secretNS, sc, driverName string,
blockPV bool, blockPV bool,
options, annotations map[string]string, policy v1.PersistentVolumeReclaimPolicy) *v1.PersistentVolume { options, annotations map[string]string, policy v1.PersistentVolumeReclaimPolicy,
) *v1.PersistentVolume {
pv := &v1.PersistentVolume{ pv := &v1.PersistentVolume{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: name, Name: name,
@ -491,7 +492,8 @@ func validateRBDStaticResize(
app *v1.Pod, app *v1.Pod,
appOpt *metav1.ListOptions, appOpt *metav1.ListOptions,
pvc *v1.PersistentVolumeClaim, pvc *v1.PersistentVolumeClaim,
rbdImageName string) error { rbdImageName string,
) error {
// resize rbd image // resize rbd image
size := staticPVNewSize size := staticPVNewSize
cmd := fmt.Sprintf( cmd := fmt.Sprintf(

View File

@ -341,7 +341,8 @@ func createPVCAndApp(
f *framework.Framework, f *framework.Framework,
pvc *v1.PersistentVolumeClaim, pvc *v1.PersistentVolumeClaim,
app *v1.Pod, app *v1.Pod,
pvcTimeout int) error { pvcTimeout int,
) error {
if name != "" { if name != "" {
pvc.Name = name pvc.Name = name
app.Name = name app.Name = name
@ -361,7 +362,8 @@ func createPVCAndDeploymentApp(
f *framework.Framework, f *framework.Framework,
pvc *v1.PersistentVolumeClaim, pvc *v1.PersistentVolumeClaim,
app *appsv1.Deployment, app *appsv1.Deployment,
pvcTimeout int) error { pvcTimeout int,
) error {
err := createPVCAndvalidatePV(f.ClientSet, pvc, pvcTimeout) err := createPVCAndvalidatePV(f.ClientSet, pvc, pvcTimeout)
if err != nil { if err != nil {
return err return err
@ -414,7 +416,8 @@ func validatePVCAndDeploymentAppBinding(
func deletePVCAndDeploymentApp( func deletePVCAndDeploymentApp(
f *framework.Framework, f *framework.Framework,
pvc *v1.PersistentVolumeClaim, pvc *v1.PersistentVolumeClaim,
app *appsv1.Deployment) error { app *appsv1.Deployment,
) error {
err := deleteDeploymentApp(f.ClientSet, app.Name, app.Namespace, deployTimeout) err := deleteDeploymentApp(f.ClientSet, app.Name, app.Namespace, deployTimeout)
if err != nil { if err != nil {
return err return err
@ -445,7 +448,8 @@ func deletePVCAndApp(name string, f *framework.Framework, pvc *v1.PersistentVolu
func createPVCAndAppBinding( func createPVCAndAppBinding(
pvcPath, appPath string, pvcPath, appPath string,
f *framework.Framework, f *framework.Framework,
pvcTimeout int) (*v1.PersistentVolumeClaim, *v1.Pod, error) { pvcTimeout int,
) (*v1.PersistentVolumeClaim, *v1.Pod, error) {
pvc, err := loadPVC(pvcPath) pvc, err := loadPVC(pvcPath)
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err
@ -486,7 +490,7 @@ func getMountType(selector, mountPath string, f *framework.Framework) (string, e
return "", err return "", err
} }
if stdErr != "" { if stdErr != "" {
return strings.TrimSpace(stdOut), fmt.Errorf(stdErr) return strings.TrimSpace(stdOut), fmt.Errorf("%s", stdErr)
} }
return strings.TrimSpace(stdOut), nil return strings.TrimSpace(stdOut), nil
@ -802,7 +806,8 @@ func validatePVCClone(
dataPool string, dataPool string,
kms kmsConfig, kms kmsConfig,
validatePVC validateFunc, validatePVC validateFunc,
f *framework.Framework) { f *framework.Framework,
) {
var wg sync.WaitGroup var wg sync.WaitGroup
wgErrs := make([]error, totalCount) wgErrs := make([]error, totalCount)
chErrs := make([]error, totalCount) chErrs := make([]error, totalCount)
@ -1013,7 +1018,8 @@ func validatePVCSnapshot(
totalCount int, totalCount int,
pvcPath, appPath, snapshotPath, pvcClonePath, appClonePath string, pvcPath, appPath, snapshotPath, pvcClonePath, appClonePath string,
kms, restoreKMS kmsConfig, restoreSCName, kms, restoreKMS kmsConfig, restoreSCName,
dataPool string, f *framework.Framework) { dataPool string, f *framework.Framework,
) {
var wg sync.WaitGroup var wg sync.WaitGroup
wgErrs := make([]error, totalCount) wgErrs := make([]error, totalCount)
chErrs := make([]error, totalCount) chErrs := make([]error, totalCount)
@ -1358,7 +1364,8 @@ func validatePVCSnapshot(
func validateController( func validateController(
f *framework.Framework, f *framework.Framework,
pvcPath, appPath, scPath string, pvcPath, appPath, scPath string,
scOptions, scParams map[string]string) error { scOptions, scParams map[string]string,
) error {
size := "1Gi" size := "1Gi"
poolName := defaultRBDPool poolName := defaultRBDPool
expandSize := "10Gi" expandSize := "10Gi"

View File

@ -59,7 +59,8 @@ func (cs *ControllerServer) createBackingVolume(
volOptions, volOptions,
parentVolOpt *store.VolumeOptions, parentVolOpt *store.VolumeOptions,
pvID *store.VolumeIdentifier, pvID *store.VolumeIdentifier,
sID *store.SnapshotIdentifier) error { sID *store.SnapshotIdentifier,
) error {
var err error var err error
volClient := core.NewSubVolume(volOptions.GetConnection(), &volOptions.SubVolume, volOptions.ClusterID) volClient := core.NewSubVolume(volOptions.GetConnection(), &volOptions.SubVolume, volOptions.ClusterID)
@ -113,7 +114,8 @@ func (cs *ControllerServer) createBackingVolume(
func checkContentSource( func checkContentSource(
ctx context.Context, ctx context.Context,
req *csi.CreateVolumeRequest, req *csi.CreateVolumeRequest,
cr *util.Credentials) (*store.VolumeOptions, *store.VolumeIdentifier, *store.SnapshotIdentifier, error) { cr *util.Credentials,
) (*store.VolumeOptions, *store.VolumeIdentifier, *store.SnapshotIdentifier, error) {
if req.VolumeContentSource == nil { if req.VolumeContentSource == nil {
return nil, nil, nil, nil return nil, nil, nil, nil
} }
@ -155,7 +157,8 @@ func checkValidCreateVolumeRequest(
vol, vol,
parentVol *store.VolumeOptions, parentVol *store.VolumeOptions,
pvID *store.VolumeIdentifier, pvID *store.VolumeIdentifier,
sID *store.SnapshotIdentifier) error { sID *store.SnapshotIdentifier,
) error {
switch { switch {
case pvID != nil: case pvID != nil:
if vol.Size < parentVol.Size { if vol.Size < parentVol.Size {
@ -182,7 +185,8 @@ func checkValidCreateVolumeRequest(
// nolint:gocognit,gocyclo,nestif,cyclop // TODO: reduce complexity // nolint:gocognit,gocyclo,nestif,cyclop // TODO: reduce complexity
func (cs *ControllerServer) CreateVolume( func (cs *ControllerServer) CreateVolume(
ctx context.Context, ctx context.Context,
req *csi.CreateVolumeRequest) (*csi.CreateVolumeResponse, error) { req *csi.CreateVolumeRequest,
) (*csi.CreateVolumeResponse, error) {
if err := cs.validateCreateVolumeRequest(req); err != nil { if err := cs.validateCreateVolumeRequest(req); err != nil {
log.ErrorLog(ctx, "CreateVolumeRequest validation failed: %v", err) log.ErrorLog(ctx, "CreateVolumeRequest validation failed: %v", err)
@ -279,12 +283,11 @@ func (cs *ControllerServer) CreateVolume(
VolumeContext: volumeContext, VolumeContext: volumeContext,
} }
if volOptions.Topology != nil { if volOptions.Topology != nil {
volume.AccessibleTopology = volume.AccessibleTopology = []*csi.Topology{
[]*csi.Topology{ {
{ Segments: volOptions.Topology,
Segments: volOptions.Topology, },
}, }
}
} }
return &csi.CreateVolumeResponse{Volume: volume}, nil return &csi.CreateVolumeResponse{Volume: volume}, nil
@ -353,12 +356,11 @@ func (cs *ControllerServer) CreateVolume(
VolumeContext: volumeContext, VolumeContext: volumeContext,
} }
if volOptions.Topology != nil { if volOptions.Topology != nil {
volume.AccessibleTopology = volume.AccessibleTopology = []*csi.Topology{
[]*csi.Topology{ {
{ Segments: volOptions.Topology,
Segments: volOptions.Topology, },
}, }
}
} }
return &csi.CreateVolumeResponse{Volume: volume}, nil return &csi.CreateVolumeResponse{Volume: volume}, nil
@ -367,7 +369,8 @@ func (cs *ControllerServer) CreateVolume(
// DeleteVolume deletes the volume in backend and its reservation. // DeleteVolume deletes the volume in backend and its reservation.
func (cs *ControllerServer) DeleteVolume( func (cs *ControllerServer) DeleteVolume(
ctx context.Context, ctx context.Context,
req *csi.DeleteVolumeRequest) (*csi.DeleteVolumeResponse, error) { req *csi.DeleteVolumeRequest,
) (*csi.DeleteVolumeResponse, error) {
if err := cs.validateDeleteVolumeRequest(); err != nil { if err := cs.validateDeleteVolumeRequest(); err != nil {
log.ErrorLog(ctx, "DeleteVolumeRequest validation failed: %v", err) log.ErrorLog(ctx, "DeleteVolumeRequest validation failed: %v", err)
@ -474,7 +477,8 @@ func (cs *ControllerServer) DeleteVolume(
// are supported. // are supported.
func (cs *ControllerServer) ValidateVolumeCapabilities( func (cs *ControllerServer) ValidateVolumeCapabilities(
ctx context.Context, ctx context.Context,
req *csi.ValidateVolumeCapabilitiesRequest) (*csi.ValidateVolumeCapabilitiesResponse, error) { req *csi.ValidateVolumeCapabilitiesRequest,
) (*csi.ValidateVolumeCapabilitiesResponse, error) {
// Cephfs doesn't support Block volume // Cephfs doesn't support Block volume
for _, capability := range req.VolumeCapabilities { for _, capability := range req.VolumeCapabilities {
if capability.GetBlock() != nil { if capability.GetBlock() != nil {
@ -492,7 +496,8 @@ func (cs *ControllerServer) ValidateVolumeCapabilities(
// ControllerExpandVolume expands CephFS Volumes on demand based on resizer request. // ControllerExpandVolume expands CephFS Volumes on demand based on resizer request.
func (cs *ControllerServer) ControllerExpandVolume( func (cs *ControllerServer) ControllerExpandVolume(
ctx context.Context, ctx context.Context,
req *csi.ControllerExpandVolumeRequest) (*csi.ControllerExpandVolumeResponse, error) { req *csi.ControllerExpandVolumeRequest,
) (*csi.ControllerExpandVolumeResponse, error) {
if err := cs.validateExpandVolumeRequest(req); err != nil { if err := cs.validateExpandVolumeRequest(req); err != nil {
log.ErrorLog(ctx, "ControllerExpandVolumeRequest validation failed: %v", err) log.ErrorLog(ctx, "ControllerExpandVolumeRequest validation failed: %v", err)
@ -551,7 +556,8 @@ func (cs *ControllerServer) ControllerExpandVolume(
// nolint:gocyclo,cyclop // golangci-lint did not catch this earlier, needs to get fixed late // nolint:gocyclo,cyclop // golangci-lint did not catch this earlier, needs to get fixed late
func (cs *ControllerServer) CreateSnapshot( func (cs *ControllerServer) CreateSnapshot(
ctx context.Context, ctx context.Context,
req *csi.CreateSnapshotRequest) (*csi.CreateSnapshotResponse, error) { req *csi.CreateSnapshotRequest,
) (*csi.CreateSnapshotResponse, error) {
if err := cs.validateSnapshotReq(ctx, req); err != nil { if err := cs.validateSnapshotReq(ctx, req); err != nil {
return nil, err return nil, err
} }
@ -714,7 +720,8 @@ func (cs *ControllerServer) CreateSnapshot(
func doSnapshot( func doSnapshot(
ctx context.Context, ctx context.Context,
volOpt *store.VolumeOptions, volOpt *store.VolumeOptions,
snapshotName string) (core.SnapshotInfo, error) { snapshotName string,
) (core.SnapshotInfo, error) {
snapID := fsutil.VolumeID(snapshotName) snapID := fsutil.VolumeID(snapshotName)
snap := core.SnapshotInfo{} snap := core.SnapshotInfo{}
snapClient := core.NewSnapshot(volOpt.GetConnection(), snapshotName, &volOpt.SubVolume) snapClient := core.NewSnapshot(volOpt.GetConnection(), snapshotName, &volOpt.SubVolume)
@ -775,7 +782,8 @@ func (cs *ControllerServer) validateSnapshotReq(ctx context.Context, req *csi.Cr
// snapshot metadata from store. // snapshot metadata from store.
func (cs *ControllerServer) DeleteSnapshot( func (cs *ControllerServer) DeleteSnapshot(
ctx context.Context, ctx context.Context,
req *csi.DeleteSnapshotRequest) (*csi.DeleteSnapshotResponse, error) { req *csi.DeleteSnapshotRequest,
) (*csi.DeleteSnapshotResponse, error) {
if err := cs.Driver.ValidateControllerServiceRequest( if err := cs.Driver.ValidateControllerServiceRequest(
csi.ControllerServiceCapability_RPC_CREATE_DELETE_SNAPSHOT); err != nil { csi.ControllerServiceCapability_RPC_CREATE_DELETE_SNAPSHOT); err != nil {
log.ErrorLog(ctx, "invalid delete snapshot req: %v", protosanitizer.StripSecrets(req)) log.ErrorLog(ctx, "invalid delete snapshot req: %v", protosanitizer.StripSecrets(req))

View File

@ -64,7 +64,8 @@ func (cs cephFSCloneState) toError() error {
// CreateCloneFromSubvolume creates a clone from a subvolume. // CreateCloneFromSubvolume creates a clone from a subvolume.
func (s *subVolumeClient) CreateCloneFromSubvolume( func (s *subVolumeClient) CreateCloneFromSubvolume(
ctx context.Context, ctx context.Context,
parentvolOpt *SubVolume) error { parentvolOpt *SubVolume,
) error {
snapshotID := s.VolID snapshotID := s.VolID
snapClient := NewSnapshot(s.conn, snapshotID, parentvolOpt) snapClient := NewSnapshot(s.conn, snapshotID, parentvolOpt)
err := snapClient.CreateSnapshot(ctx) err := snapClient.CreateSnapshot(ctx)
@ -159,7 +160,8 @@ func (s *subVolumeClient) CreateCloneFromSubvolume(
// CleanupSnapshotFromSubvolume removes the snapshot from the subvolume. // CleanupSnapshotFromSubvolume removes the snapshot from the subvolume.
func (s *subVolumeClient) CleanupSnapshotFromSubvolume( func (s *subVolumeClient) CleanupSnapshotFromSubvolume(
ctx context.Context, parentVol *SubVolume) error { ctx context.Context, parentVol *SubVolume,
) error {
// snapshot name is same as clone name as we need a name which can be // snapshot name is same as clone name as we need a name which can be
// identified during PVC-PVC cloning. // identified during PVC-PVC cloning.
snapShotID := s.VolID snapShotID := s.VolID
@ -193,7 +195,8 @@ func (s *subVolumeClient) CleanupSnapshotFromSubvolume(
// CreateSnapshotFromSubvolume creates a clone from subvolume snapshot. // CreateSnapshotFromSubvolume creates a clone from subvolume snapshot.
func (s *subVolumeClient) CreateCloneFromSnapshot( func (s *subVolumeClient) CreateCloneFromSnapshot(
ctx context.Context, snap Snapshot) error { ctx context.Context, snap Snapshot,
) error {
snapID := snap.SnapshotID snapID := snap.SnapshotID
snapClient := NewSnapshot(s.conn, snapID, snap.SubVolume) snapClient := NewSnapshot(s.conn, snapID, snap.SubVolume)
err := snapClient.CloneSnapshot(ctx, s.SubVolume) err := snapClient.CloneSnapshot(ctx, s.SubVolume)

View File

@ -33,7 +33,8 @@ type IdentityServer struct {
// GetPluginCapabilities returns available capabilities of the ceph driver. // GetPluginCapabilities returns available capabilities of the ceph driver.
func (is *IdentityServer) GetPluginCapabilities( func (is *IdentityServer) GetPluginCapabilities(
ctx context.Context, ctx context.Context,
req *csi.GetPluginCapabilitiesRequest) (*csi.GetPluginCapabilitiesResponse, error) { req *csi.GetPluginCapabilitiesRequest,
) (*csi.GetPluginCapabilitiesResponse, error) {
return &csi.GetPluginCapabilitiesResponse{ return &csi.GetPluginCapabilitiesResponse{
Capabilities: []*csi.PluginCapability{ Capabilities: []*csi.PluginCapability{
{ {

View File

@ -107,7 +107,8 @@ func (m *FuseMounter) Mount(
ctx context.Context, ctx context.Context,
mountPoint string, mountPoint string,
cr *util.Credentials, cr *util.Credentials,
volOptions *store.VolumeOptions) error { volOptions *store.VolumeOptions,
) error {
if err := util.CreateMountPoint(mountPoint); err != nil { if err := util.CreateMountPoint(mountPoint); err != nil {
return err return err
} }

View File

@ -72,7 +72,8 @@ func (m *KernelMounter) Mount(
ctx context.Context, ctx context.Context,
mountPoint string, mountPoint string,
cr *util.Credentials, cr *util.Credentials,
volOptions *store.VolumeOptions) error { volOptions *store.VolumeOptions,
) error {
if err := util.CreateMountPoint(mountPoint); err != nil { if err := util.CreateMountPoint(mountPoint); err != nil {
return err return err
} }

View File

@ -47,7 +47,8 @@ type NodeServer struct {
func getCredentialsForVolume( func getCredentialsForVolume(
volOptions *store.VolumeOptions, volOptions *store.VolumeOptions,
secrets map[string]string) (*util.Credentials, error) { secrets map[string]string,
) (*util.Credentials, error) {
var ( var (
err error err error
cr *util.Credentials cr *util.Credentials
@ -103,7 +104,8 @@ func (ns *NodeServer) getVolumeOptions(
// NodeStageVolume mounts the volume to a staging path on the node. // NodeStageVolume mounts the volume to a staging path on the node.
func (ns *NodeServer) NodeStageVolume( func (ns *NodeServer) NodeStageVolume(
ctx context.Context, ctx context.Context,
req *csi.NodeStageVolumeRequest) (*csi.NodeStageVolumeResponse, error) { req *csi.NodeStageVolumeRequest,
) (*csi.NodeStageVolumeResponse, error) {
if err := util.ValidateNodeStageVolumeRequest(req); err != nil { if err := util.ValidateNodeStageVolumeRequest(req); err != nil {
return nil, err return nil, err
} }
@ -253,7 +255,8 @@ func (*NodeServer) mount(
// path. // path.
func (ns *NodeServer) NodePublishVolume( func (ns *NodeServer) NodePublishVolume(
ctx context.Context, ctx context.Context,
req *csi.NodePublishVolumeRequest) (*csi.NodePublishVolumeResponse, error) { req *csi.NodePublishVolumeRequest,
) (*csi.NodePublishVolumeResponse, error) {
mountOptions := []string{"bind", "_netdev"} mountOptions := []string{"bind", "_netdev"}
if err := util.ValidateNodePublishVolumeRequest(req); err != nil { if err := util.ValidateNodePublishVolumeRequest(req); err != nil {
return nil, err return nil, err
@ -336,7 +339,8 @@ func (ns *NodeServer) NodePublishVolume(
// NodeUnpublishVolume unmounts the volume from the target path. // NodeUnpublishVolume unmounts the volume from the target path.
func (ns *NodeServer) NodeUnpublishVolume( func (ns *NodeServer) NodeUnpublishVolume(
ctx context.Context, ctx context.Context,
req *csi.NodeUnpublishVolumeRequest) (*csi.NodeUnpublishVolumeResponse, error) { req *csi.NodeUnpublishVolumeRequest,
) (*csi.NodeUnpublishVolumeResponse, error) {
var err error var err error
if err = util.ValidateNodeUnpublishVolumeRequest(req); err != nil { if err = util.ValidateNodeUnpublishVolumeRequest(req); err != nil {
return nil, err return nil, err
@ -391,7 +395,8 @@ func (ns *NodeServer) NodeUnpublishVolume(
// NodeUnstageVolume unstages the volume from the staging path. // NodeUnstageVolume unstages the volume from the staging path.
func (ns *NodeServer) NodeUnstageVolume( func (ns *NodeServer) NodeUnstageVolume(
ctx context.Context, ctx context.Context,
req *csi.NodeUnstageVolumeRequest) (*csi.NodeUnstageVolumeResponse, error) { req *csi.NodeUnstageVolumeRequest,
) (*csi.NodeUnstageVolumeResponse, error) {
var err error var err error
if err = util.ValidateNodeUnstageVolumeRequest(req); err != nil { if err = util.ValidateNodeUnstageVolumeRequest(req); err != nil {
return nil, err return nil, err
@ -451,7 +456,8 @@ func (ns *NodeServer) NodeUnstageVolume(
// NodeGetCapabilities returns the supported capabilities of the node server. // NodeGetCapabilities returns the supported capabilities of the node server.
func (ns *NodeServer) NodeGetCapabilities( func (ns *NodeServer) NodeGetCapabilities(
ctx context.Context, ctx context.Context,
req *csi.NodeGetCapabilitiesRequest) (*csi.NodeGetCapabilitiesResponse, error) { req *csi.NodeGetCapabilitiesRequest,
) (*csi.NodeGetCapabilitiesResponse, error) {
return &csi.NodeGetCapabilitiesResponse{ return &csi.NodeGetCapabilitiesResponse{
Capabilities: []*csi.NodeServiceCapability{ Capabilities: []*csi.NodeServiceCapability{
{ {
@ -482,7 +488,8 @@ func (ns *NodeServer) NodeGetCapabilities(
// NodeGetVolumeStats returns volume stats. // NodeGetVolumeStats returns volume stats.
func (ns *NodeServer) NodeGetVolumeStats( func (ns *NodeServer) NodeGetVolumeStats(
ctx context.Context, ctx context.Context,
req *csi.NodeGetVolumeStatsRequest) (*csi.NodeGetVolumeStatsResponse, error) { req *csi.NodeGetVolumeStatsRequest,
) (*csi.NodeGetVolumeStatsResponse, error) {
var err error var err error
targetPath := req.GetVolumePath() targetPath := req.GetVolumePath()
if targetPath == "" { if targetPath == "" {

View File

@ -77,7 +77,8 @@ func CheckVolExists(ctx context.Context,
pvID *VolumeIdentifier, pvID *VolumeIdentifier,
sID *SnapshotIdentifier, sID *SnapshotIdentifier,
cr *util.Credentials) (*VolumeIdentifier, error) { cr *util.Credentials,
) (*VolumeIdentifier, error) {
var vid VolumeIdentifier var vid VolumeIdentifier
// Connect to cephfs' default radosNamespace (csi) // Connect to cephfs' default radosNamespace (csi)
j, err := VolJournal.Connect(volOptions.Monitors, fsutil.RadosNamespace, cr) j, err := VolJournal.Connect(volOptions.Monitors, fsutil.RadosNamespace, cr)
@ -205,7 +206,8 @@ func UndoVolReservation(
ctx context.Context, ctx context.Context,
volOptions *VolumeOptions, volOptions *VolumeOptions,
vid VolumeIdentifier, vid VolumeIdentifier,
secret map[string]string) error { secret map[string]string,
) error {
cr, err := util.NewAdminCredentials(secret) cr, err := util.NewAdminCredentials(secret)
if err != nil { if err != nil {
return err return err
@ -294,7 +296,8 @@ func ReserveSnap(
volOptions *VolumeOptions, volOptions *VolumeOptions,
parentSubVolName string, parentSubVolName string,
snap *SnapshotOption, snap *SnapshotOption,
cr *util.Credentials) (*SnapshotIdentifier, error) { cr *util.Credentials,
) (*SnapshotIdentifier, error) {
var ( var (
vid SnapshotIdentifier vid SnapshotIdentifier
imageUUID string imageUUID string
@ -335,7 +338,8 @@ func UndoSnapReservation(
volOptions *VolumeOptions, volOptions *VolumeOptions,
vid SnapshotIdentifier, vid SnapshotIdentifier,
snapName string, snapName string,
cr *util.Credentials) error { cr *util.Credentials,
) error {
// Connect to cephfs' default radosNamespace (csi) // Connect to cephfs' default radosNamespace (csi)
j, err := SnapJournal.Connect(volOptions.Monitors, fsutil.RadosNamespace, cr) j, err := SnapJournal.Connect(volOptions.Monitors, fsutil.RadosNamespace, cr)
if err != nil { if err != nil {
@ -367,7 +371,8 @@ func CheckSnapExists(
ctx context.Context, ctx context.Context,
volOptions *VolumeOptions, volOptions *VolumeOptions,
snap *SnapshotOption, snap *SnapshotOption,
cr *util.Credentials) (*SnapshotIdentifier, *core.SnapshotInfo, error) { cr *util.Credentials,
) (*SnapshotIdentifier, *core.SnapshotInfo, error) {
// Connect to cephfs' default radosNamespace (csi) // Connect to cephfs' default radosNamespace (csi)
j, err := SnapJournal.Connect(volOptions.Monitors, fsutil.RadosNamespace, cr) j, err := SnapJournal.Connect(volOptions.Monitors, fsutil.RadosNamespace, cr)
if err != nil { if err != nil {

View File

@ -187,7 +187,8 @@ func (vo *VolumeOptions) GetConnection() *util.ClusterConnection {
// NewVolumeOptions generates a new instance of volumeOptions from the provided // NewVolumeOptions generates a new instance of volumeOptions from the provided
// CSI request parameters. // CSI request parameters.
func NewVolumeOptions(ctx context.Context, requestName string, req *csi.CreateVolumeRequest, func NewVolumeOptions(ctx context.Context, requestName string, req *csi.CreateVolumeRequest,
cr *util.Credentials) (*VolumeOptions, error) { cr *util.Credentials,
) (*VolumeOptions, error) {
var ( var (
opts VolumeOptions opts VolumeOptions
err error err error
@ -268,7 +269,8 @@ func NewVolumeOptions(ctx context.Context, requestName string, req *csi.CreateVo
func NewVolumeOptionsFromVolID( func NewVolumeOptionsFromVolID(
ctx context.Context, ctx context.Context,
volID string, volID string,
volOpt, secrets map[string]string) (*VolumeOptions, *VolumeIdentifier, error) { volOpt, secrets map[string]string,
) (*VolumeOptions, *VolumeIdentifier, error) {
var ( var (
vi util.CSIIdentifier vi util.CSIIdentifier
volOptions VolumeOptions volOptions VolumeOptions
@ -383,7 +385,8 @@ func NewVolumeOptionsFromVolID(
// VolumeIdentifier from the provided CSI volume context. // VolumeIdentifier from the provided CSI volume context.
func NewVolumeOptionsFromMonitorList( func NewVolumeOptionsFromMonitorList(
volID string, volID string,
options, secrets map[string]string) (*VolumeOptions, *VolumeIdentifier, error) { options, secrets map[string]string,
) (*VolumeOptions, *VolumeIdentifier, error) {
var ( var (
opts VolumeOptions opts VolumeOptions
vid VolumeIdentifier vid VolumeIdentifier
@ -446,7 +449,8 @@ func NewVolumeOptionsFromMonitorList(
// detected to be a statically provisioned volume. // detected to be a statically provisioned volume.
func NewVolumeOptionsFromStaticVolume( func NewVolumeOptionsFromStaticVolume(
volID string, volID string,
options map[string]string) (*VolumeOptions, *VolumeIdentifier, error) { options map[string]string,
) (*VolumeOptions, *VolumeIdentifier, error) {
var ( var (
opts VolumeOptions opts VolumeOptions
vid VolumeIdentifier vid VolumeIdentifier
@ -515,7 +519,8 @@ func NewVolumeOptionsFromStaticVolume(
func NewSnapshotOptionsFromID( func NewSnapshotOptionsFromID(
ctx context.Context, ctx context.Context,
snapID string, snapID string,
cr *util.Credentials) (*VolumeOptions, *core.SnapshotInfo, *SnapshotIdentifier, error) { cr *util.Credentials,
) (*VolumeOptions, *core.SnapshotInfo, *SnapshotIdentifier, error) {
var ( var (
vi util.CSIIdentifier vi util.CSIIdentifier
volOptions VolumeOptions volOptions VolumeOptions

View File

@ -93,7 +93,8 @@ func add(mgr manager.Manager, r reconcile.Reconciler) error {
func (r *ReconcilePersistentVolume) getCredentials( func (r *ReconcilePersistentVolume) getCredentials(
ctx context.Context, ctx context.Context,
name, name,
namespace string) (*util.Credentials, error) { namespace string,
) (*util.Credentials, error) {
var cr *util.Credentials var cr *util.Credentials
if name == "" || namespace == "" { if name == "" || namespace == "" {
@ -199,7 +200,8 @@ func (r ReconcilePersistentVolume) reconcilePV(ctx context.Context, obj runtime.
// Reconcile reconciles the PersistentVolume object and creates a new omap entries // Reconcile reconciles the PersistentVolume object and creates a new omap entries
// for the volume. // for the volume.
func (r *ReconcilePersistentVolume) Reconcile(ctx context.Context, func (r *ReconcilePersistentVolume) Reconcile(ctx context.Context,
request reconcile.Request) (reconcile.Result, error) { request reconcile.Request,
) (reconcile.Result, error) {
pv := &corev1.PersistentVolume{} pv := &corev1.PersistentVolume{}
err := r.client.Get(ctx, request.NamespacedName, pv) err := r.client.Get(ctx, request.NamespacedName, pv)
if err != nil { if err != nil {

View File

@ -39,7 +39,8 @@ func NewNetworkFence(
ctx context.Context, ctx context.Context,
cr *util.Credentials, cr *util.Credentials,
cidrs []*fence.CIDR, cidrs []*fence.CIDR,
fenceOptions map[string]string) (*NetworkFence, error) { fenceOptions map[string]string,
) (*NetworkFence, error) {
var err error var err error
nwFence := &NetworkFence{} nwFence := &NetworkFence{}

View File

@ -49,7 +49,8 @@ func (is *IdentityServer) RegisterService(server grpc.ServiceRegistrar) {
// GetIdentity returns available capabilities of the rbd driver. // GetIdentity returns available capabilities of the rbd driver.
func (is *IdentityServer) GetIdentity( func (is *IdentityServer) GetIdentity(
ctx context.Context, ctx context.Context,
req *identity.GetIdentityRequest) (*identity.GetIdentityResponse, error) { req *identity.GetIdentityRequest,
) (*identity.GetIdentityResponse, error) {
// only include Name and VendorVersion, Manifest is optional // only include Name and VendorVersion, Manifest is optional
res := &identity.GetIdentityResponse{ res := &identity.GetIdentityResponse{
Name: is.config.DriverName, Name: is.config.DriverName,
@ -62,7 +63,8 @@ func (is *IdentityServer) GetIdentity(
// GetCapabilities returns available capabilities of the rbd driver. // GetCapabilities returns available capabilities of the rbd driver.
func (is *IdentityServer) GetCapabilities( func (is *IdentityServer) GetCapabilities(
ctx context.Context, ctx context.Context,
req *identity.GetCapabilitiesRequest) (*identity.GetCapabilitiesResponse, error) { req *identity.GetCapabilitiesRequest,
) (*identity.GetCapabilitiesResponse, error) {
// build the list of capabilities, depending on the config // build the list of capabilities, depending on the config
caps := make([]*identity.Capability, 0) caps := make([]*identity.Capability, 0)
@ -121,7 +123,8 @@ func (is *IdentityServer) GetCapabilities(
// still healthy. // still healthy.
func (is *IdentityServer) Probe( func (is *IdentityServer) Probe(
ctx context.Context, ctx context.Context,
req *identity.ProbeRequest) (*identity.ProbeResponse, error) { req *identity.ProbeRequest,
) (*identity.ProbeResponse, error) {
// there is nothing that would cause a delay in getting ready // there is nothing that would cause a delay in getting ready
res := &identity.ProbeResponse{ res := &identity.ProbeResponse{
Ready: &wrapperspb.BoolValue{Value: true}, Ready: &wrapperspb.BoolValue{Value: true},

View File

@ -60,7 +60,8 @@ func validateNetworkFenceReq(fenceClients []*fence.CIDR, options map[string]stri
// to the malicious clients to prevent data corruption. // to the malicious clients to prevent data corruption.
func (fcs *FenceControllerServer) FenceClusterNetwork( func (fcs *FenceControllerServer) FenceClusterNetwork(
ctx context.Context, ctx context.Context,
req *fence.FenceClusterNetworkRequest) (*fence.FenceClusterNetworkResponse, error) { req *fence.FenceClusterNetworkRequest,
) (*fence.FenceClusterNetworkResponse, error) {
err := validateNetworkFenceReq(req.GetCidrs(), req.Parameters) err := validateNetworkFenceReq(req.GetCidrs(), req.Parameters)
if err != nil { if err != nil {
return nil, status.Error(codes.InvalidArgument, err.Error()) return nil, status.Error(codes.InvalidArgument, err.Error())
@ -88,7 +89,8 @@ func (fcs *FenceControllerServer) FenceClusterNetwork(
// UnfenceClusterNetwork unblocks the access to a CIDR block by removing the network fence. // UnfenceClusterNetwork unblocks the access to a CIDR block by removing the network fence.
func (fcs *FenceControllerServer) UnfenceClusterNetwork( func (fcs *FenceControllerServer) UnfenceClusterNetwork(
ctx context.Context, ctx context.Context,
req *fence.UnfenceClusterNetworkRequest) (*fence.UnfenceClusterNetworkResponse, error) { req *fence.UnfenceClusterNetworkRequest,
) (*fence.UnfenceClusterNetworkResponse, error) {
err := validateNetworkFenceReq(req.GetCidrs(), req.Parameters) err := validateNetworkFenceReq(req.GetCidrs(), req.Parameters)
if err != nil { if err != nil {
return nil, status.Error(codes.InvalidArgument, err.Error()) return nil, status.Error(codes.InvalidArgument, err.Error())

View File

@ -49,7 +49,8 @@ func (rscs *ReclaimSpaceControllerServer) RegisterService(server grpc.ServiceReg
func (rscs *ReclaimSpaceControllerServer) ControllerReclaimSpace( func (rscs *ReclaimSpaceControllerServer) ControllerReclaimSpace(
ctx context.Context, ctx context.Context,
req *rs.ControllerReclaimSpaceRequest) (*rs.ControllerReclaimSpaceResponse, error) { req *rs.ControllerReclaimSpaceRequest,
) (*rs.ControllerReclaimSpaceResponse, error) {
volumeID := req.GetVolumeId() volumeID := req.GetVolumeId()
if volumeID == "" { if volumeID == "" {
return nil, status.Error(codes.InvalidArgument, "empty volume ID in request") return nil, status.Error(codes.InvalidArgument, "empty volume ID in request")
@ -97,10 +98,10 @@ func (rsns *ReclaimSpaceNodeServer) RegisterService(server grpc.ServiceRegistrar
// an error is returned to prevent potential data corruption. // an error is returned to prevent potential data corruption.
func (rsns *ReclaimSpaceNodeServer) NodeReclaimSpace( func (rsns *ReclaimSpaceNodeServer) NodeReclaimSpace(
ctx context.Context, ctx context.Context,
req *rs.NodeReclaimSpaceRequest) (*rs.NodeReclaimSpaceResponse, error) { req *rs.NodeReclaimSpaceRequest,
) (*rs.NodeReclaimSpaceResponse, error) {
// volumeID is a required attribute, it is part of the path to run the // volumeID is a required attribute, it is part of the path to run the
// space reducing command on // space reducing command on
// nolint:ifshort // volumeID is incorrectly assumed to be used only once
volumeID := req.GetVolumeId() volumeID := req.GetVolumeId()
if volumeID == "" { if volumeID == "" {
return nil, status.Error(codes.InvalidArgument, "empty volume ID in request") return nil, status.Error(codes.InvalidArgument, "empty volume ID in request")

View File

@ -34,28 +34,32 @@ type DefaultControllerServer struct {
// ControllerPublishVolume publish volume on node. // ControllerPublishVolume publish volume on node.
func (cs *DefaultControllerServer) ControllerPublishVolume( func (cs *DefaultControllerServer) ControllerPublishVolume(
ctx context.Context, ctx context.Context,
req *csi.ControllerPublishVolumeRequest) (*csi.ControllerPublishVolumeResponse, error) { req *csi.ControllerPublishVolumeRequest,
) (*csi.ControllerPublishVolumeResponse, error) {
return nil, status.Error(codes.Unimplemented, "") return nil, status.Error(codes.Unimplemented, "")
} }
// ControllerUnpublishVolume unpublish on node. // ControllerUnpublishVolume unpublish on node.
func (cs *DefaultControllerServer) ControllerUnpublishVolume( func (cs *DefaultControllerServer) ControllerUnpublishVolume(
ctx context.Context, ctx context.Context,
req *csi.ControllerUnpublishVolumeRequest) (*csi.ControllerUnpublishVolumeResponse, error) { req *csi.ControllerUnpublishVolumeRequest,
) (*csi.ControllerUnpublishVolumeResponse, error) {
return nil, status.Error(codes.Unimplemented, "") return nil, status.Error(codes.Unimplemented, "")
} }
// ListVolumes lists volumes. // ListVolumes lists volumes.
func (cs *DefaultControllerServer) ListVolumes( func (cs *DefaultControllerServer) ListVolumes(
ctx context.Context, ctx context.Context,
req *csi.ListVolumesRequest) (*csi.ListVolumesResponse, error) { req *csi.ListVolumesRequest,
) (*csi.ListVolumesResponse, error) {
return nil, status.Error(codes.Unimplemented, "") return nil, status.Error(codes.Unimplemented, "")
} }
// GetCapacity get volume capacity. // GetCapacity get volume capacity.
func (cs *DefaultControllerServer) GetCapacity( func (cs *DefaultControllerServer) GetCapacity(
ctx context.Context, ctx context.Context,
req *csi.GetCapacityRequest) (*csi.GetCapacityResponse, error) { req *csi.GetCapacityRequest,
) (*csi.GetCapacityResponse, error) {
return nil, status.Error(codes.Unimplemented, "") return nil, status.Error(codes.Unimplemented, "")
} }
@ -63,7 +67,8 @@ func (cs *DefaultControllerServer) GetCapacity(
// Default supports all capabilities. // Default supports all capabilities.
func (cs *DefaultControllerServer) ControllerGetCapabilities( func (cs *DefaultControllerServer) ControllerGetCapabilities(
ctx context.Context, ctx context.Context,
req *csi.ControllerGetCapabilitiesRequest) (*csi.ControllerGetCapabilitiesResponse, error) { req *csi.ControllerGetCapabilitiesRequest,
) (*csi.ControllerGetCapabilitiesResponse, error) {
log.TraceLog(ctx, "Using default ControllerGetCapabilities") log.TraceLog(ctx, "Using default ControllerGetCapabilities")
if cs.Driver == nil { if cs.Driver == nil {
return nil, status.Error(codes.Unimplemented, "Controller server is not enabled") return nil, status.Error(codes.Unimplemented, "Controller server is not enabled")
@ -77,13 +82,15 @@ func (cs *DefaultControllerServer) ControllerGetCapabilities(
// ListSnapshots lists snapshots. // ListSnapshots lists snapshots.
func (cs *DefaultControllerServer) ListSnapshots( func (cs *DefaultControllerServer) ListSnapshots(
ctx context.Context, ctx context.Context,
req *csi.ListSnapshotsRequest) (*csi.ListSnapshotsResponse, error) { req *csi.ListSnapshotsRequest,
) (*csi.ListSnapshotsResponse, error) {
return nil, status.Error(codes.Unimplemented, "") return nil, status.Error(codes.Unimplemented, "")
} }
// ControllerGetVolume fetch volume information. // ControllerGetVolume fetch volume information.
func (cs *DefaultControllerServer) ControllerGetVolume( func (cs *DefaultControllerServer) ControllerGetVolume(
ctx context.Context, ctx context.Context,
req *csi.ControllerGetVolumeRequest) (*csi.ControllerGetVolumeResponse, error) { req *csi.ControllerGetVolumeRequest,
) (*csi.ControllerGetVolumeResponse, error) {
return nil, status.Error(codes.Unimplemented, "") return nil, status.Error(codes.Unimplemented, "")
} }

View File

@ -100,7 +100,8 @@ func (d *CSIDriver) AddControllerServiceCapabilities(cl []csi.ControllerServiceC
// AddVolumeCapabilityAccessModes stores volume access modes. // AddVolumeCapabilityAccessModes stores volume access modes.
func (d *CSIDriver) AddVolumeCapabilityAccessModes( func (d *CSIDriver) AddVolumeCapabilityAccessModes(
vc []csi.VolumeCapability_AccessMode_Mode) []*csi.VolumeCapability_AccessMode { vc []csi.VolumeCapability_AccessMode_Mode,
) []*csi.VolumeCapability_AccessMode {
vca := make([]*csi.VolumeCapability_AccessMode, 0, len(vc)) vca := make([]*csi.VolumeCapability_AccessMode, 0, len(vc))
for _, c := range vc { for _, c := range vc {
log.DefaultLog("Enabling volume access mode: %v", c.String()) log.DefaultLog("Enabling volume access mode: %v", c.String())

View File

@ -34,7 +34,8 @@ type DefaultIdentityServer struct {
// GetPluginInfo returns plugin information. // GetPluginInfo returns plugin information.
func (ids *DefaultIdentityServer) GetPluginInfo( func (ids *DefaultIdentityServer) GetPluginInfo(
ctx context.Context, ctx context.Context,
req *csi.GetPluginInfoRequest) (*csi.GetPluginInfoResponse, error) { req *csi.GetPluginInfoRequest,
) (*csi.GetPluginInfoResponse, error) {
log.TraceLog(ctx, "Using default GetPluginInfo") log.TraceLog(ctx, "Using default GetPluginInfo")
if ids.Driver.name == "" { if ids.Driver.name == "" {
@ -59,7 +60,8 @@ func (ids *DefaultIdentityServer) Probe(ctx context.Context, req *csi.ProbeReque
// GetPluginCapabilities returns plugin capabilities. // GetPluginCapabilities returns plugin capabilities.
func (ids *DefaultIdentityServer) GetPluginCapabilities( func (ids *DefaultIdentityServer) GetPluginCapabilities(
ctx context.Context, ctx context.Context,
req *csi.GetPluginCapabilitiesRequest) (*csi.GetPluginCapabilitiesResponse, error) { req *csi.GetPluginCapabilitiesRequest,
) (*csi.GetPluginCapabilitiesResponse, error) {
log.TraceLog(ctx, "Using default capabilities") log.TraceLog(ctx, "Using default capabilities")
return &csi.GetPluginCapabilitiesResponse{ return &csi.GetPluginCapabilitiesResponse{

View File

@ -35,14 +35,16 @@ type DefaultNodeServer struct {
// NodeExpandVolume returns unimplemented response. // NodeExpandVolume returns unimplemented response.
func (ns *DefaultNodeServer) NodeExpandVolume( func (ns *DefaultNodeServer) NodeExpandVolume(
ctx context.Context, ctx context.Context,
req *csi.NodeExpandVolumeRequest) (*csi.NodeExpandVolumeResponse, error) { req *csi.NodeExpandVolumeRequest,
) (*csi.NodeExpandVolumeResponse, error) {
return nil, status.Error(codes.Unimplemented, "") return nil, status.Error(codes.Unimplemented, "")
} }
// NodeGetInfo returns node ID. // NodeGetInfo returns node ID.
func (ns *DefaultNodeServer) NodeGetInfo( func (ns *DefaultNodeServer) NodeGetInfo(
ctx context.Context, ctx context.Context,
req *csi.NodeGetInfoRequest) (*csi.NodeGetInfoResponse, error) { req *csi.NodeGetInfoRequest,
) (*csi.NodeGetInfoResponse, error) {
log.TraceLog(ctx, "Using default NodeGetInfo") log.TraceLog(ctx, "Using default NodeGetInfo")
csiTopology := &csi.Topology{ csiTopology := &csi.Topology{
@ -58,7 +60,8 @@ func (ns *DefaultNodeServer) NodeGetInfo(
// NodeGetCapabilities returns RPC unknown capability. // NodeGetCapabilities returns RPC unknown capability.
func (ns *DefaultNodeServer) NodeGetCapabilities( func (ns *DefaultNodeServer) NodeGetCapabilities(
ctx context.Context, ctx context.Context,
req *csi.NodeGetCapabilitiesRequest) (*csi.NodeGetCapabilitiesResponse, error) { req *csi.NodeGetCapabilitiesRequest,
) (*csi.NodeGetCapabilitiesResponse, error) {
log.TraceLog(ctx, "Using default NodeGetCapabilities") log.TraceLog(ctx, "Using default NodeGetCapabilities")
return &csi.NodeGetCapabilitiesResponse{ return &csi.NodeGetCapabilitiesResponse{

View File

@ -173,7 +173,8 @@ func contextIDInjector(
ctx context.Context, ctx context.Context,
req interface{}, req interface{},
info *grpc.UnaryServerInfo, info *grpc.UnaryServerInfo,
handler grpc.UnaryHandler) (resp interface{}, err error) { handler grpc.UnaryHandler,
) (interface{}, error) {
atomic.AddUint64(&id, 1) atomic.AddUint64(&id, 1)
ctx = context.WithValue(ctx, log.CtxKey, id) ctx = context.WithValue(ctx, log.CtxKey, id)
if reqID := getReqID(req); reqID != "" { if reqID := getReqID(req); reqID != "" {
@ -187,7 +188,8 @@ func logGRPC(
ctx context.Context, ctx context.Context,
req interface{}, req interface{},
info *grpc.UnaryServerInfo, info *grpc.UnaryServerInfo,
handler grpc.UnaryHandler) (interface{}, error) { handler grpc.UnaryHandler,
) (interface{}, error) {
log.ExtendedLog(ctx, "GRPC call: %s", info.FullMethod) log.ExtendedLog(ctx, "GRPC call: %s", info.FullMethod)
if isReplicationRequest(req) { if isReplicationRequest(req) {
log.TraceLog(ctx, "GRPC request: %s", rp.StripReplicationSecrets(req)) log.TraceLog(ctx, "GRPC request: %s", rp.StripReplicationSecrets(req))
@ -205,11 +207,13 @@ func logGRPC(
return resp, err return resp, err
} }
//nolint:nonamedreturns // named return used to send recovered panic error.
func panicHandler( func panicHandler(
ctx context.Context, ctx context.Context,
req interface{}, req interface{},
info *grpc.UnaryServerInfo, info *grpc.UnaryServerInfo,
handler grpc.UnaryHandler) (resp interface{}, err error) { handler grpc.UnaryHandler,
) (resp interface{}, err error) {
defer func() { defer func() {
if r := recover(); r != nil { if r := recover(); r != nil {
klog.Errorf("panic occurred: %v", r) klog.Errorf("panic occurred: %v", r)

View File

@ -34,7 +34,8 @@ const chunkSize int64 = 512
func getOMapValues( func getOMapValues(
ctx context.Context, ctx context.Context,
conn *Connection, conn *Connection,
poolName, namespace, oid, prefix string, keys []string) (map[string]string, error) { poolName, namespace, oid, prefix string, keys []string,
) (map[string]string, error) {
// fetch and configure the rados ioctx // fetch and configure the rados ioctx
ioctx, err := conn.conn.GetIoctx(poolName) ioctx, err := conn.conn.GetIoctx(poolName)
if err != nil { if err != nil {
@ -93,7 +94,8 @@ func getOMapValues(
func removeMapKeys( func removeMapKeys(
ctx context.Context, ctx context.Context,
conn *Connection, conn *Connection,
poolName, namespace, oid string, keys []string) error { poolName, namespace, oid string, keys []string,
) error {
// fetch and configure the rados ioctx // fetch and configure the rados ioctx
ioctx, err := conn.conn.GetIoctx(poolName) ioctx, err := conn.conn.GetIoctx(poolName)
if err != nil { if err != nil {
@ -129,7 +131,8 @@ func removeMapKeys(
func setOMapKeys( func setOMapKeys(
ctx context.Context, ctx context.Context,
conn *Connection, conn *Connection,
poolName, namespace, oid string, pairs map[string]string) error { poolName, namespace, oid string, pairs map[string]string,
) error {
// fetch and configure the rados ioctx // fetch and configure the rados ioctx
ioctx, err := conn.conn.GetIoctx(poolName) ioctx, err := conn.conn.GetIoctx(poolName)
if err != nil { if err != nil {

View File

@ -275,7 +275,8 @@ Return values:
- error: non-nil in case of any errors - error: non-nil in case of any errors
*/ */
func (conn *Connection) CheckReservation(ctx context.Context, func (conn *Connection) CheckReservation(ctx context.Context,
journalPool, reqName, namePrefix, snapParentName, kmsConfig string) (*ImageData, error) { journalPool, reqName, namePrefix, snapParentName, kmsConfig string,
) (*ImageData, error) {
var ( var (
snapSource bool snapSource bool
objUUID string objUUID string
@ -415,7 +416,8 @@ Input arguments:
different if image is created in a topology constrained pool) different if image is created in a topology constrained pool)
*/ */
func (conn *Connection) UndoReservation(ctx context.Context, func (conn *Connection) UndoReservation(ctx context.Context,
csiJournalPool, volJournalPool, volName, reqName string) error { csiJournalPool, volJournalPool, volName, reqName string,
) error {
// delete volume UUID omap (first, inverse of create order) // delete volume UUID omap (first, inverse of create order)
cj := conn.config cj := conn.config
@ -467,7 +469,8 @@ func reserveOMapName(
ctx context.Context, ctx context.Context,
monitors string, monitors string,
cr *util.Credentials, cr *util.Credentials,
pool, namespace, oMapNamePrefix, volUUID string) (string, error) { pool, namespace, oMapNamePrefix, volUUID string,
) (string, error) {
var iterUUID string var iterUUID string
maxAttempts := 5 maxAttempts := 5
@ -534,7 +537,8 @@ Return values:
func (conn *Connection) ReserveName(ctx context.Context, func (conn *Connection) ReserveName(ctx context.Context,
journalPool string, journalPoolID int64, journalPool string, journalPoolID int64,
imagePool string, imagePoolID int64, imagePool string, imagePoolID int64,
reqName, namePrefix, parentName, kmsConf, volUUID, owner string) (string, string, error) { reqName, namePrefix, parentName, kmsConf, volUUID, owner string,
) (string, string, error) {
// TODO: Take in-arg as ImageAttributes? // TODO: Take in-arg as ImageAttributes?
var ( var (
snapSource bool snapSource bool
@ -658,7 +662,8 @@ type ImageAttributes struct {
func (conn *Connection) GetImageAttributes( func (conn *Connection) GetImageAttributes(
ctx context.Context, ctx context.Context,
pool, objectUUID string, pool, objectUUID string,
snapSource bool) (*ImageAttributes, error) { snapSource bool,
) (*ImageAttributes, error) {
var ( var (
err error err error
imageAttributes = &ImageAttributes{} imageAttributes = &ImageAttributes{}
@ -782,7 +787,8 @@ func (conn *Connection) Destroy() {
// CheckNewUUIDMapping checks is there any UUID mapping between old // CheckNewUUIDMapping checks is there any UUID mapping between old
// volumeHandle and the newly generated volumeHandle. // volumeHandle and the newly generated volumeHandle.
func (conn *Connection) CheckNewUUIDMapping(ctx context.Context, func (conn *Connection) CheckNewUUIDMapping(ctx context.Context,
journalPool, volumeHandle string) (string, error) { journalPool, volumeHandle string,
) (string, error) {
cj := conn.config cj := conn.config
// check if request name is already part of the directory omap // check if request name is already part of the directory omap
@ -812,7 +818,8 @@ func (conn *Connection) CheckNewUUIDMapping(ctx context.Context,
// secondary cluster cephcsi will generate the new mapping and keep it for // secondary cluster cephcsi will generate the new mapping and keep it for
// internal reference. // internal reference.
func (conn *Connection) ReserveNewUUIDMapping(ctx context.Context, func (conn *Connection) ReserveNewUUIDMapping(ctx context.Context,
journalPool, oldVolumeHandle, newVolumeHandle string) error { journalPool, oldVolumeHandle, newVolumeHandle string,
) error {
cj := conn.config cj := conn.config
setKeys := map[string]string{ setKeys := map[string]string{

View File

@ -199,8 +199,7 @@ func (kms *awsMetadataKMS) EncryptDEK(volumeID, plainDEK string) (string, error)
// base64 encode the encrypted DEK, so that storing it should not have // base64 encode the encrypted DEK, so that storing it should not have
// issues // issues
encryptedDEK := encryptedDEK := base64.StdEncoding.EncodeToString(result.CiphertextBlob)
base64.StdEncoding.EncodeToString(result.CiphertextBlob)
return encryptedDEK, nil return encryptedDEK, nil
} }

View File

@ -269,7 +269,8 @@ func RegisterProvider(provider Provider) bool {
func (kf *kmsProviderList) buildKMS( func (kf *kmsProviderList) buildKMS(
tenant string, tenant string,
config map[string]interface{}, config map[string]interface{},
secrets map[string]string) (EncryptionKMS, error) { secrets map[string]string,
) (EncryptionKMS, error) {
providerName, err := getProvider(config) providerName, err := getProvider(config)
if err != nil { if err != nil {
return nil, err return nil, err

View File

@ -138,7 +138,8 @@ func initSecretsMetadataKMS(args ProviderInitArgs) (EncryptionKMS, error) {
// fetchEncryptionPassphrase fetches encryptionPassphrase from user provided secret. // fetchEncryptionPassphrase fetches encryptionPassphrase from user provided secret.
func (kms secretsMetadataKMS) fetchEncryptionPassphrase( func (kms secretsMetadataKMS) fetchEncryptionPassphrase(
config map[string]interface{}, config map[string]interface{},
defaultNamespace string) (string, error) { defaultNamespace string,
) (string, error) {
var ( var (
secretName string secretName string
secretNamespace string secretNamespace string

View File

@ -302,6 +302,7 @@ func (vc *vaultConnection) Destroy() {
tmpFile, ok := vc.vaultConfig[api.EnvVaultCACert] tmpFile, ok := vc.vaultConfig[api.EnvVaultCACert]
if ok { if ok {
// ignore error on failure to remove tmpfile (gosec complains) // ignore error on failure to remove tmpfile (gosec complains)
//nolint:forcetypeassert // ignore error on failure to remove tmpfile
_ = os.Remove(tmpFile.(string)) _ = os.Remove(tmpFile.(string))
} }
} }

View File

@ -120,6 +120,7 @@ func TestInitVaultTokensKMS(t *testing.T) {
// add tenant "bob" // add tenant "bob"
bob := make(map[string]interface{}) bob := make(map[string]interface{})
bob["vaultAddress"] = "https://vault.bob.example.org" bob["vaultAddress"] = "https://vault.bob.example.org"
//nolint:forcetypeassert // as its a test we dont need to check assertion here.
args.Config["tenants"].(map[string]interface{})["bob"] = bob args.Config["tenants"].(map[string]interface{})["bob"] = bob
_, err = initVaultTokensKMS(args) _, err = initVaultTokensKMS(args)

View File

@ -57,7 +57,8 @@ func NewControllerServer(d *csicommon.CSIDriver) *Server {
// capabilities that were set in the Driver.Run() function. // capabilities that were set in the Driver.Run() function.
func (cs *Server) ControllerGetCapabilities( func (cs *Server) ControllerGetCapabilities(
ctx context.Context, ctx context.Context,
req *csi.ControllerGetCapabilitiesRequest) (*csi.ControllerGetCapabilitiesResponse, error) { req *csi.ControllerGetCapabilitiesRequest,
) (*csi.ControllerGetCapabilitiesResponse, error) {
return cs.backendServer.ControllerGetCapabilities(ctx, req) return cs.backendServer.ControllerGetCapabilities(ctx, req)
} }
@ -65,7 +66,8 @@ func (cs *Server) ControllerGetCapabilities(
// are supported. // are supported.
func (cs *Server) ValidateVolumeCapabilities( func (cs *Server) ValidateVolumeCapabilities(
ctx context.Context, ctx context.Context,
req *csi.ValidateVolumeCapabilitiesRequest) (*csi.ValidateVolumeCapabilitiesResponse, error) { req *csi.ValidateVolumeCapabilitiesRequest,
) (*csi.ValidateVolumeCapabilitiesResponse, error) {
return cs.backendServer.ValidateVolumeCapabilities(ctx, req) return cs.backendServer.ValidateVolumeCapabilities(ctx, req)
} }
@ -73,7 +75,8 @@ func (cs *Server) ValidateVolumeCapabilities(
// created entities. // created entities.
func (cs *Server) CreateVolume( func (cs *Server) CreateVolume(
ctx context.Context, ctx context.Context,
req *csi.CreateVolumeRequest) (*csi.CreateVolumeResponse, error) { req *csi.CreateVolumeRequest,
) (*csi.CreateVolumeResponse, error) {
res, err := cs.backendServer.CreateVolume(ctx, req) res, err := cs.backendServer.CreateVolume(ctx, req)
if err != nil { if err != nil {
return nil, err return nil, err
@ -120,7 +123,8 @@ func (cs *Server) CreateVolume(
// DeleteVolume deletes the volume in backend and its reservation. // DeleteVolume deletes the volume in backend and its reservation.
func (cs *Server) DeleteVolume( func (cs *Server) DeleteVolume(
ctx context.Context, ctx context.Context,
req *csi.DeleteVolumeRequest) (*csi.DeleteVolumeResponse, error) { req *csi.DeleteVolumeRequest,
) (*csi.DeleteVolumeResponse, error) {
secret := req.GetSecrets() secret := req.GetSecrets()
cr, err := util.NewAdminCredentials(secret) cr, err := util.NewAdminCredentials(secret)
if err != nil { if err != nil {
@ -157,7 +161,8 @@ func (cs *Server) DeleteVolume(
// new size. // new size.
func (cs *Server) ControllerExpandVolume( func (cs *Server) ControllerExpandVolume(
ctx context.Context, ctx context.Context,
req *csi.ControllerExpandVolumeRequest) (*csi.ControllerExpandVolumeResponse, error) { req *csi.ControllerExpandVolumeRequest,
) (*csi.ControllerExpandVolumeResponse, error) {
return cs.backendServer.ControllerExpandVolume(ctx, req) return cs.backendServer.ControllerExpandVolume(ctx, req)
} }
@ -165,7 +170,8 @@ func (cs *Server) ControllerExpandVolume(
// There is no interaction with the NFS-server needed for snapshot creation. // There is no interaction with the NFS-server needed for snapshot creation.
func (cs *Server) CreateSnapshot( func (cs *Server) CreateSnapshot(
ctx context.Context, ctx context.Context,
req *csi.CreateSnapshotRequest) (*csi.CreateSnapshotResponse, error) { req *csi.CreateSnapshotRequest,
) (*csi.CreateSnapshotResponse, error) {
return cs.backendServer.CreateSnapshot(ctx, req) return cs.backendServer.CreateSnapshot(ctx, req)
} }
@ -173,6 +179,7 @@ func (cs *Server) CreateSnapshot(
// There is no interaction with the NFS-server needed for snapshot creation. // There is no interaction with the NFS-server needed for snapshot creation.
func (cs *Server) DeleteSnapshot( func (cs *Server) DeleteSnapshot(
ctx context.Context, ctx context.Context,
req *csi.DeleteSnapshotRequest) (*csi.DeleteSnapshotResponse, error) { req *csi.DeleteSnapshotRequest,
) (*csi.DeleteSnapshotResponse, error) {
return cs.backendServer.DeleteSnapshot(ctx, req) return cs.backendServer.DeleteSnapshot(ctx, req)
} }

View File

@ -40,7 +40,8 @@ func NewIdentityServer(d *csicommon.CSIDriver) *Server {
// GetPluginCapabilities returns available capabilities of the ceph driver. // GetPluginCapabilities returns available capabilities of the ceph driver.
func (is *Server) GetPluginCapabilities( func (is *Server) GetPluginCapabilities(
ctx context.Context, ctx context.Context,
req *csi.GetPluginCapabilitiesRequest) (*csi.GetPluginCapabilitiesResponse, error) { req *csi.GetPluginCapabilitiesRequest,
) (*csi.GetPluginCapabilitiesResponse, error) {
return &csi.GetPluginCapabilitiesResponse{ return &csi.GetPluginCapabilitiesResponse{
Capabilities: []*csi.PluginCapability{ Capabilities: []*csi.PluginCapability{
{ {

View File

@ -98,7 +98,8 @@ func (cs *ControllerServer) validateVolumeReq(ctx context.Context, req *csi.Crea
// request arguments for subsequent calls. // request arguments for subsequent calls.
func (cs *ControllerServer) parseVolCreateRequest( func (cs *ControllerServer) parseVolCreateRequest(
ctx context.Context, ctx context.Context,
req *csi.CreateVolumeRequest) (*rbdVolume, error) { req *csi.CreateVolumeRequest,
) (*rbdVolume, error) {
// TODO (sbezverk) Last check for not exceeding total storage capacity // TODO (sbezverk) Last check for not exceeding total storage capacity
// below capability check indicates that we support both {SINGLE_NODE or MULTI_NODE} WRITERs and the `isMultiWriter` // below capability check indicates that we support both {SINGLE_NODE or MULTI_NODE} WRITERs and the `isMultiWriter`
@ -195,12 +196,11 @@ func buildCreateVolumeResponse(req *csi.CreateVolumeRequest, rbdVol *rbdVolume)
ContentSource: req.GetVolumeContentSource(), ContentSource: req.GetVolumeContentSource(),
} }
if rbdVol.Topology != nil { if rbdVol.Topology != nil {
volume.AccessibleTopology = volume.AccessibleTopology = []*csi.Topology{
[]*csi.Topology{ {
{ Segments: rbdVol.Topology,
Segments: rbdVol.Topology, },
}, }
}
} }
return &csi.CreateVolumeResponse{Volume: volume} return &csi.CreateVolumeResponse{Volume: volume}
@ -252,7 +252,8 @@ func checkValidCreateVolumeRequest(rbdVol, parentVol *rbdVolume, rbdSnap *rbdSna
// CreateVolume creates the volume in backend. // CreateVolume creates the volume in backend.
func (cs *ControllerServer) CreateVolume( func (cs *ControllerServer) CreateVolume(
ctx context.Context, ctx context.Context,
req *csi.CreateVolumeRequest) (*csi.CreateVolumeResponse, error) { req *csi.CreateVolumeRequest,
) (*csi.CreateVolumeResponse, error) {
err := cs.validateVolumeReq(ctx, req) err := cs.validateVolumeReq(ctx, req)
if err != nil { if err != nil {
return nil, err return nil, err
@ -349,7 +350,8 @@ func flattenParentImage(
ctx context.Context, ctx context.Context,
rbdVol *rbdVolume, rbdVol *rbdVolume,
rbdSnap *rbdSnapshot, rbdSnap *rbdSnapshot,
cr *util.Credentials) error { cr *util.Credentials,
) error {
// flatten the image's parent before the reservation to avoid // flatten the image's parent before the reservation to avoid
// stale entries in post creation if we return ABORT error and the // stale entries in post creation if we return ABORT error and the
// DeleteVolume RPC is not called. // DeleteVolume RPC is not called.
@ -417,7 +419,8 @@ func flattenParentImage(
// that the state is corrected to what was requested. It is needed to call this // that the state is corrected to what was requested. It is needed to call this
// when the process of creating a volume was interrupted. // when the process of creating a volume was interrupted.
func (cs *ControllerServer) repairExistingVolume(ctx context.Context, req *csi.CreateVolumeRequest, func (cs *ControllerServer) repairExistingVolume(ctx context.Context, req *csi.CreateVolumeRequest,
cr *util.Credentials, rbdVol *rbdVolume, rbdSnap *rbdSnapshot) (*csi.CreateVolumeResponse, error) { cr *util.Credentials, rbdVol *rbdVolume, rbdSnap *rbdSnapshot,
) (*csi.CreateVolumeResponse, error) {
vcs := req.GetVolumeContentSource() vcs := req.GetVolumeContentSource()
switch { switch {
@ -558,7 +561,8 @@ func (cs *ControllerServer) createVolumeFromSnapshot(
cr *util.Credentials, cr *util.Credentials,
secrets map[string]string, secrets map[string]string,
rbdVol *rbdVolume, rbdVol *rbdVolume,
snapshotID string) error { snapshotID string,
) error {
rbdSnap := &rbdSnapshot{} rbdSnap := &rbdSnapshot{}
if acquired := cs.SnapshotLocks.TryAcquire(snapshotID); !acquired { if acquired := cs.SnapshotLocks.TryAcquire(snapshotID); !acquired {
log.ErrorLog(ctx, util.SnapshotOperationAlreadyExistsFmt, snapshotID) log.ErrorLog(ctx, util.SnapshotOperationAlreadyExistsFmt, snapshotID)
@ -622,7 +626,8 @@ func (cs *ControllerServer) createBackingImage(
cr *util.Credentials, cr *util.Credentials,
secrets map[string]string, secrets map[string]string,
rbdVol, parentVol *rbdVolume, rbdVol, parentVol *rbdVolume,
rbdSnap *rbdSnapshot) error { rbdSnap *rbdSnapshot,
) error {
var err error var err error
j, err := volJournal.Connect(rbdVol.Monitors, rbdVol.RadosNamespace, cr) j, err := volJournal.Connect(rbdVol.Monitors, rbdVol.RadosNamespace, cr)
@ -682,7 +687,8 @@ func (cs *ControllerServer) createBackingImage(
func checkContentSource( func checkContentSource(
ctx context.Context, ctx context.Context,
req *csi.CreateVolumeRequest, req *csi.CreateVolumeRequest,
cr *util.Credentials) (*rbdVolume, *rbdSnapshot, error) { cr *util.Credentials,
) (*rbdVolume, *rbdSnapshot, error) {
if req.VolumeContentSource == nil { if req.VolumeContentSource == nil {
return nil, nil, nil return nil, nil, nil
} }
@ -743,7 +749,8 @@ func (cs *ControllerServer) checkErrAndUndoReserve(
ctx context.Context, ctx context.Context,
err error, err error,
volumeID string, volumeID string,
rbdVol *rbdVolume, cr *util.Credentials) (*csi.DeleteVolumeResponse, error) { rbdVol *rbdVolume, cr *util.Credentials,
) (*csi.DeleteVolumeResponse, error) {
if errors.Is(err, util.ErrPoolNotFound) { if errors.Is(err, util.ErrPoolNotFound) {
log.WarningLog(ctx, "failed to get backend volume for %s: %v", volumeID, err) log.WarningLog(ctx, "failed to get backend volume for %s: %v", volumeID, err)
@ -790,7 +797,8 @@ func (cs *ControllerServer) checkErrAndUndoReserve(
// from store. // from store.
func (cs *ControllerServer) DeleteVolume( func (cs *ControllerServer) DeleteVolume(
ctx context.Context, ctx context.Context,
req *csi.DeleteVolumeRequest) (*csi.DeleteVolumeResponse, error) { req *csi.DeleteVolumeRequest,
) (*csi.DeleteVolumeResponse, error) {
var err error var err error
if err = cs.Driver.ValidateControllerServiceRequest( if err = cs.Driver.ValidateControllerServiceRequest(
csi.ControllerServiceCapability_RPC_CREATE_DELETE_VOLUME); err != nil { csi.ControllerServiceCapability_RPC_CREATE_DELETE_VOLUME); err != nil {
@ -860,7 +868,8 @@ func (cs *ControllerServer) DeleteVolume(
// cleanupRBDImage removes the rbd image and OMAP metadata associated with it. // cleanupRBDImage removes the rbd image and OMAP metadata associated with it.
func cleanupRBDImage(ctx context.Context, func cleanupRBDImage(ctx context.Context,
rbdVol *rbdVolume, cr *util.Credentials) (*csi.DeleteVolumeResponse, error) { rbdVol *rbdVolume, cr *util.Credentials,
) (*csi.DeleteVolumeResponse, error) {
mirroringInfo, err := rbdVol.getImageMirroringInfo() mirroringInfo, err := rbdVol.getImageMirroringInfo()
if err != nil { if err != nil {
log.ErrorLog(ctx, err.Error()) log.ErrorLog(ctx, err.Error())
@ -954,7 +963,8 @@ func cleanupRBDImage(ctx context.Context,
// are supported. // are supported.
func (cs *ControllerServer) ValidateVolumeCapabilities( func (cs *ControllerServer) ValidateVolumeCapabilities(
ctx context.Context, ctx context.Context,
req *csi.ValidateVolumeCapabilitiesRequest) (*csi.ValidateVolumeCapabilitiesResponse, error) { req *csi.ValidateVolumeCapabilitiesRequest,
) (*csi.ValidateVolumeCapabilitiesResponse, error) {
if req.GetVolumeId() == "" { if req.GetVolumeId() == "" {
return nil, status.Error(codes.InvalidArgument, "empty volume ID in request") return nil, status.Error(codes.InvalidArgument, "empty volume ID in request")
} }
@ -980,7 +990,8 @@ func (cs *ControllerServer) ValidateVolumeCapabilities(
// nolint:gocyclo,cyclop // TODO: reduce complexity. // nolint:gocyclo,cyclop // TODO: reduce complexity.
func (cs *ControllerServer) CreateSnapshot( func (cs *ControllerServer) CreateSnapshot(
ctx context.Context, ctx context.Context,
req *csi.CreateSnapshotRequest) (*csi.CreateSnapshotResponse, error) { req *csi.CreateSnapshotRequest,
) (*csi.CreateSnapshotResponse, error) {
if err := cs.validateSnapshotReq(ctx, req); err != nil { if err := cs.validateSnapshotReq(ctx, req); err != nil {
return nil, err return nil, err
} }
@ -1110,7 +1121,8 @@ func cloneFromSnapshot(
rbdVol *rbdVolume, rbdVol *rbdVolume,
rbdSnap *rbdSnapshot, rbdSnap *rbdSnapshot,
cr *util.Credentials, cr *util.Credentials,
parameters map[string]string) (*csi.CreateSnapshotResponse, error) { parameters map[string]string,
) (*csi.CreateSnapshotResponse, error) {
vol := generateVolFromSnap(rbdSnap) vol := generateVolFromSnap(rbdSnap)
err := vol.Connect(cr) err := vol.Connect(cr)
if err != nil { if err != nil {
@ -1193,7 +1205,8 @@ func (cs *ControllerServer) doSnapshotClone(
ctx context.Context, ctx context.Context,
parentVol *rbdVolume, parentVol *rbdVolume,
rbdSnap *rbdSnapshot, rbdSnap *rbdSnapshot,
cr *util.Credentials) (*rbdVolume, error) { cr *util.Credentials,
) (*rbdVolume, error) {
// generate cloned volume details from snapshot // generate cloned volume details from snapshot
cloneRbd := generateVolFromSnap(rbdSnap) cloneRbd := generateVolFromSnap(rbdSnap)
defer cloneRbd.Destroy() defer cloneRbd.Destroy()
@ -1276,7 +1289,8 @@ func (cs *ControllerServer) doSnapshotClone(
// snapshot metadata from store. // snapshot metadata from store.
func (cs *ControllerServer) DeleteSnapshot( func (cs *ControllerServer) DeleteSnapshot(
ctx context.Context, ctx context.Context,
req *csi.DeleteSnapshotRequest) (*csi.DeleteSnapshotResponse, error) { req *csi.DeleteSnapshotRequest,
) (*csi.DeleteSnapshotResponse, error) {
if err := cs.Driver.ValidateControllerServiceRequest( if err := cs.Driver.ValidateControllerServiceRequest(
csi.ControllerServiceCapability_RPC_CREATE_DELETE_SNAPSHOT); err != nil { csi.ControllerServiceCapability_RPC_CREATE_DELETE_SNAPSHOT); err != nil {
log.ErrorLog(ctx, "invalid delete snapshot req: %v", protosanitizer.StripSecrets(req)) log.ErrorLog(ctx, "invalid delete snapshot req: %v", protosanitizer.StripSecrets(req))
@ -1417,7 +1431,8 @@ func cleanUpImageAndSnapReservation(ctx context.Context, rbdSnap *rbdSnapshot, c
// ControllerExpandVolume expand RBD Volumes on demand based on resizer request. // ControllerExpandVolume expand RBD Volumes on demand based on resizer request.
func (cs *ControllerServer) ControllerExpandVolume( func (cs *ControllerServer) ControllerExpandVolume(
ctx context.Context, ctx context.Context,
req *csi.ControllerExpandVolumeRequest) (*csi.ControllerExpandVolumeResponse, error) { req *csi.ControllerExpandVolumeRequest,
) (*csi.ControllerExpandVolumeResponse, error) {
err := cs.Driver.ValidateControllerServiceRequest(csi.ControllerServiceCapability_RPC_EXPAND_VOLUME) err := cs.Driver.ValidateControllerServiceRequest(csi.ControllerServiceCapability_RPC_EXPAND_VOLUME)
if err != nil { if err != nil {
log.ErrorLog(ctx, "invalid expand volume req: %v", protosanitizer.StripSecrets(req)) log.ErrorLog(ctx, "invalid expand volume req: %v", protosanitizer.StripSecrets(req))

View File

@ -273,7 +273,8 @@ func (ri *rbdImage) initKMS(ctx context.Context, volOptions, credentials map[str
// ParseEncryptionOpts returns kmsID and sets Owner attribute. // ParseEncryptionOpts returns kmsID and sets Owner attribute.
func (ri *rbdImage) ParseEncryptionOpts( func (ri *rbdImage) ParseEncryptionOpts(
ctx context.Context, ctx context.Context,
volOptions map[string]string) (string, error) { volOptions map[string]string,
) (string, error) {
var ( var (
err error err error
ok bool ok bool

View File

@ -33,7 +33,8 @@ type IdentityServer struct {
// GetPluginCapabilities returns available capabilities of the rbd driver. // GetPluginCapabilities returns available capabilities of the rbd driver.
func (is *IdentityServer) GetPluginCapabilities( func (is *IdentityServer) GetPluginCapabilities(
ctx context.Context, ctx context.Context,
req *csi.GetPluginCapabilitiesRequest) (*csi.GetPluginCapabilitiesResponse, error) { req *csi.GetPluginCapabilitiesRequest,
) (*csi.GetPluginCapabilitiesResponse, error) {
return &csi.GetPluginCapabilitiesResponse{ return &csi.GetPluginCapabilitiesResponse{
Capabilities: []*csi.PluginCapability{ Capabilities: []*csi.PluginCapability{
{ {

View File

@ -148,7 +148,8 @@ func healerStageTransaction(ctx context.Context, cr *util.Credentials, volOps *r
func populateRbdVol( func populateRbdVol(
ctx context.Context, ctx context.Context,
req *csi.NodeStageVolumeRequest, req *csi.NodeStageVolumeRequest,
cr *util.Credentials) (*rbdVolume, error) { cr *util.Credentials,
) (*rbdVolume, error) {
var err error var err error
var j *journal.Connection var j *journal.Connection
volID := req.GetVolumeId() volID := req.GetVolumeId()
@ -295,7 +296,8 @@ func populateRbdVol(
// - Stage the device (mount the device mapped for image) // - Stage the device (mount the device mapped for image)
func (ns *NodeServer) NodeStageVolume( func (ns *NodeServer) NodeStageVolume(
ctx context.Context, ctx context.Context,
req *csi.NodeStageVolumeRequest) (*csi.NodeStageVolumeResponse, error) { req *csi.NodeStageVolumeRequest,
) (*csi.NodeStageVolumeResponse, error) {
var err error var err error
if err = util.ValidateNodeStageVolumeRequest(req); err != nil { if err = util.ValidateNodeStageVolumeRequest(req); err != nil {
return nil, err return nil, err
@ -384,7 +386,8 @@ func (ns *NodeServer) stageTransaction(
req *csi.NodeStageVolumeRequest, req *csi.NodeStageVolumeRequest,
cr *util.Credentials, cr *util.Credentials,
volOptions *rbdVolume, volOptions *rbdVolume,
staticVol bool) (*stageTransaction, error) { staticVol bool,
) (*stageTransaction, error) {
transaction := &stageTransaction{} transaction := &stageTransaction{}
var err error var err error
@ -466,7 +469,8 @@ func resizeNodeStagePath(ctx context.Context,
isBlock bool, isBlock bool,
transaction *stageTransaction, transaction *stageTransaction,
volID, volID,
stagingTargetPath string) error { stagingTargetPath string,
) error {
var err error var err error
devicePath := transaction.devicePath devicePath := transaction.devicePath
var ok bool var ok bool
@ -543,7 +547,8 @@ func resizeEncryptedDevice(ctx context.Context, volID, stagingTargetPath, device
func flattenImageBeforeMapping( func flattenImageBeforeMapping(
ctx context.Context, ctx context.Context,
volOptions *rbdVolume) error { volOptions *rbdVolume,
) error {
var err error var err error
var feature bool var feature bool
var depth uint var depth uint
@ -579,7 +584,8 @@ func (ns *NodeServer) undoStagingTransaction(
ctx context.Context, ctx context.Context,
req *csi.NodeStageVolumeRequest, req *csi.NodeStageVolumeRequest,
transaction *stageTransaction, transaction *stageTransaction,
volOptions *rbdVolume) { volOptions *rbdVolume,
) {
var err error var err error
stagingTargetPath := getStagingTargetPath(req) stagingTargetPath := getStagingTargetPath(req)
@ -661,7 +667,8 @@ func (ns *NodeServer) createStageMountPoint(ctx context.Context, mountPath strin
// path. // path.
func (ns *NodeServer) NodePublishVolume( func (ns *NodeServer) NodePublishVolume(
ctx context.Context, ctx context.Context,
req *csi.NodePublishVolumeRequest) (*csi.NodePublishVolumeResponse, error) { req *csi.NodePublishVolumeRequest,
) (*csi.NodePublishVolumeResponse, error) {
err := util.ValidateNodePublishVolumeRequest(req) err := util.ValidateNodePublishVolumeRequest(req)
if err != nil { if err != nil {
return nil, err return nil, err
@ -700,7 +707,8 @@ func (ns *NodeServer) mountVolumeToStagePath(
ctx context.Context, ctx context.Context,
req *csi.NodeStageVolumeRequest, req *csi.NodeStageVolumeRequest,
staticVol bool, staticVol bool,
stagingPath, devicePath string) error { stagingPath, devicePath string,
) error {
readOnly := false readOnly := false
fsType := req.GetVolumeCapability().GetMount().GetFsType() fsType := req.GetVolumeCapability().GetMount().GetFsType()
diskMounter := &mount.SafeFormatAndMount{Interface: ns.Mounter, Exec: utilexec.New()} diskMounter := &mount.SafeFormatAndMount{Interface: ns.Mounter, Exec: utilexec.New()}
@ -841,7 +849,8 @@ func (ns *NodeServer) createTargetMountPath(ctx context.Context, mountPath strin
// NodeUnpublishVolume unmounts the volume from the target path. // NodeUnpublishVolume unmounts the volume from the target path.
func (ns *NodeServer) NodeUnpublishVolume( func (ns *NodeServer) NodeUnpublishVolume(
ctx context.Context, ctx context.Context,
req *csi.NodeUnpublishVolumeRequest) (*csi.NodeUnpublishVolumeResponse, error) { req *csi.NodeUnpublishVolumeRequest,
) (*csi.NodeUnpublishVolumeResponse, error) {
err := util.ValidateNodeUnpublishVolumeRequest(req) err := util.ValidateNodeUnpublishVolumeRequest(req)
if err != nil { if err != nil {
return nil, err return nil, err
@ -898,7 +907,8 @@ func getStagingTargetPath(req interface{}) string {
// NodeUnstageVolume unstages the volume from the staging path. // NodeUnstageVolume unstages the volume from the staging path.
func (ns *NodeServer) NodeUnstageVolume( func (ns *NodeServer) NodeUnstageVolume(
ctx context.Context, ctx context.Context,
req *csi.NodeUnstageVolumeRequest) (*csi.NodeUnstageVolumeResponse, error) { req *csi.NodeUnstageVolumeRequest,
) (*csi.NodeUnstageVolumeResponse, error) {
var err error var err error
if err = util.ValidateNodeUnstageVolumeRequest(req); err != nil { if err = util.ValidateNodeUnstageVolumeRequest(req); err != nil {
return nil, err return nil, err
@ -1004,7 +1014,8 @@ func (ns *NodeServer) NodeUnstageVolume(
// NodeExpandVolume resizes rbd volumes. // NodeExpandVolume resizes rbd volumes.
func (ns *NodeServer) NodeExpandVolume( func (ns *NodeServer) NodeExpandVolume(
ctx context.Context, ctx context.Context,
req *csi.NodeExpandVolumeRequest) (*csi.NodeExpandVolumeResponse, error) { req *csi.NodeExpandVolumeRequest,
) (*csi.NodeExpandVolumeResponse, error) {
volumeID := req.GetVolumeId() volumeID := req.GetVolumeId()
if volumeID == "" { if volumeID == "" {
return nil, status.Error(codes.InvalidArgument, "volume ID must be provided") return nil, status.Error(codes.InvalidArgument, "volume ID must be provided")
@ -1078,7 +1089,8 @@ func (ns *NodeServer) NodeExpandVolume(
// NodeGetCapabilities returns the supported capabilities of the node server. // NodeGetCapabilities returns the supported capabilities of the node server.
func (ns *NodeServer) NodeGetCapabilities( func (ns *NodeServer) NodeGetCapabilities(
ctx context.Context, ctx context.Context,
req *csi.NodeGetCapabilitiesRequest) (*csi.NodeGetCapabilitiesResponse, error) { req *csi.NodeGetCapabilitiesRequest,
) (*csi.NodeGetCapabilitiesResponse, error) {
return &csi.NodeGetCapabilitiesResponse{ return &csi.NodeGetCapabilitiesResponse{
Capabilities: []*csi.NodeServiceCapability{ Capabilities: []*csi.NodeServiceCapability{
{ {
@ -1116,7 +1128,8 @@ func (ns *NodeServer) NodeGetCapabilities(
func (ns *NodeServer) processEncryptedDevice( func (ns *NodeServer) processEncryptedDevice(
ctx context.Context, ctx context.Context,
volOptions *rbdVolume, volOptions *rbdVolume,
devicePath string) (string, error) { devicePath string,
) (string, error) {
imageSpec := volOptions.String() imageSpec := volOptions.String()
encrypted, err := volOptions.checkRbdImageEncrypted(ctx) encrypted, err := volOptions.checkRbdImageEncrypted(ctx)
if err != nil { if err != nil {
@ -1212,7 +1225,8 @@ func (ns *NodeServer) xfsSupportsReflink() bool {
// NodeGetVolumeStats returns volume stats. // NodeGetVolumeStats returns volume stats.
func (ns *NodeServer) NodeGetVolumeStats( func (ns *NodeServer) NodeGetVolumeStats(
ctx context.Context, ctx context.Context,
req *csi.NodeGetVolumeStatsRequest) (*csi.NodeGetVolumeStatsResponse, error) { req *csi.NodeGetVolumeStatsRequest,
) (*csi.NodeGetVolumeStatsResponse, error) {
var err error var err error
targetPath := req.GetVolumePath() targetPath := req.GetVolumePath()
if targetPath == "" { if targetPath == "" {

View File

@ -538,7 +538,8 @@ func detachRBDDevice(ctx context.Context, devicePath, volumeID, unmapOptions str
// when imageSpec is used to decide if image is already unmapped. // when imageSpec is used to decide if image is already unmapped.
func detachRBDImageOrDeviceSpec( func detachRBDImageOrDeviceSpec(
ctx context.Context, ctx context.Context,
dArgs *detachRBDImageArgs) error { dArgs *detachRBDImageArgs,
) error {
if dArgs.encrypted { if dArgs.encrypted {
mapperFile, mapperPath := util.VolumeMapper(dArgs.volumeID) mapperFile, mapperPath := util.VolumeMapper(dArgs.volumeID)
mappedDevice, mapper, err := util.DeviceEncryptionStatus(ctx, mapperPath) mappedDevice, mapper, err := util.DeviceEncryptionStatus(ctx, mapperPath)

View File

@ -116,7 +116,8 @@ func checkSnapCloneExists(
ctx context.Context, ctx context.Context,
parentVol *rbdVolume, parentVol *rbdVolume,
rbdSnap *rbdSnapshot, rbdSnap *rbdSnapshot,
cr *util.Credentials) (bool, error) { cr *util.Credentials,
) (bool, error) {
err := validateRbdSnap(rbdSnap) err := validateRbdSnap(rbdSnap)
if err != nil { if err != nil {
return false, err return false, err
@ -541,7 +542,8 @@ func RegenerateJournal(
volumeID, volumeID,
requestName, requestName,
owner string, owner string,
cr *util.Credentials) (string, error) { cr *util.Credentials,
) (string, error) {
ctx := context.Background() ctx := context.Background()
var ( var (
vi util.CSIIdentifier vi util.CSIIdentifier

View File

@ -722,7 +722,8 @@ func flattenClonedRbdImages(
ctx context.Context, ctx context.Context,
snaps []librbd.SnapInfo, snaps []librbd.SnapInfo,
pool, monitors, rbdImageName string, pool, monitors, rbdImageName string,
cr *util.Credentials) error { cr *util.Credentials,
) error {
rv := &rbdVolume{} rv := &rbdVolume{}
rv.Monitors = monitors rv.Monitors = monitors
rv.Pool = pool rv.Pool = pool
@ -769,7 +770,8 @@ func flattenClonedRbdImages(
func (ri *rbdImage) flattenRbdImage( func (ri *rbdImage) flattenRbdImage(
ctx context.Context, ctx context.Context,
forceFlatten bool, forceFlatten bool,
hardlimit, softlimit uint) error { hardlimit, softlimit uint,
) error {
var depth uint var depth uint
var err error var err error
@ -926,7 +928,8 @@ func genSnapFromSnapID(
rbdSnap *rbdSnapshot, rbdSnap *rbdSnapshot,
snapshotID string, snapshotID string,
cr *util.Credentials, cr *util.Credentials,
secrets map[string]string) error { secrets map[string]string,
) error {
var vi util.CSIIdentifier var vi util.CSIIdentifier
rbdSnap.VolID = snapshotID rbdSnap.VolID = snapshotID
@ -1036,7 +1039,8 @@ func generateVolumeFromVolumeID(
volumeID string, volumeID string,
vi util.CSIIdentifier, vi util.CSIIdentifier,
cr *util.Credentials, cr *util.Credentials,
secrets map[string]string) (*rbdVolume, error) { secrets map[string]string,
) (*rbdVolume, error) {
var ( var (
rbdVol *rbdVolume rbdVol *rbdVolume
err error err error
@ -1123,7 +1127,8 @@ func GenVolFromVolID(
ctx context.Context, ctx context.Context,
volumeID string, volumeID string,
cr *util.Credentials, cr *util.Credentials,
secrets map[string]string) (*rbdVolume, error) { secrets map[string]string,
) (*rbdVolume, error) {
var ( var (
vi util.CSIIdentifier vi util.CSIIdentifier
vol *rbdVolume vol *rbdVolume
@ -1165,7 +1170,8 @@ func generateVolumeFromMapping(
volumeID string, volumeID string,
vi util.CSIIdentifier, vi util.CSIIdentifier,
cr *util.Credentials, cr *util.Credentials,
secrets map[string]string) (*rbdVolume, error) { secrets map[string]string,
) (*rbdVolume, error) {
nvi := vi nvi := vi
vol := &rbdVolume{} vol := &rbdVolume{}
// extract clusterID mapping // extract clusterID mapping
@ -1215,7 +1221,8 @@ func generateVolumeFromMapping(
func genVolFromVolumeOptions( func genVolFromVolumeOptions(
ctx context.Context, ctx context.Context,
volOptions map[string]string, volOptions map[string]string,
disableInUseChecks, checkClusterIDMapping bool) (*rbdVolume, error) { disableInUseChecks, checkClusterIDMapping bool,
) (*rbdVolume, error) {
var ( var (
ok bool ok bool
err error err error
@ -1368,7 +1375,8 @@ func (ri *rbdImage) deleteSnapshot(ctx context.Context, pOpts *rbdSnapshot) erro
func (rv *rbdVolume) cloneRbdImageFromSnapshot( func (rv *rbdVolume) cloneRbdImageFromSnapshot(
ctx context.Context, ctx context.Context,
pSnapOpts *rbdSnapshot, pSnapOpts *rbdSnapshot,
parentVol *rbdVolume) error { parentVol *rbdVolume,
) error {
var err error var err error
logMsg := "rbd: clone %s %s (features: %s) using mon %s" logMsg := "rbd: clone %s %s (features: %s) using mon %s"
@ -1904,7 +1912,8 @@ func (ri *rbdImage) isCompabitableClone(dst *rbdImage) error {
func (ri *rbdImage) addSnapshotScheduling( func (ri *rbdImage) addSnapshotScheduling(
interval admin.Interval, interval admin.Interval,
startTime admin.StartTime) error { startTime admin.StartTime,
) error {
ls := admin.NewLevelSpec(ri.Pool, ri.RadosNamespace, ri.RbdImageName) ls := admin.NewLevelSpec(ri.Pool, ri.RadosNamespace, ri.RbdImageName)
ra, err := ri.conn.GetRBDAdmin() ra, err := ri.conn.GetRBDAdmin()
if err != nil { if err != nil {
@ -1965,7 +1974,8 @@ func strategicActionOnLogFile(ctx context.Context, logStrategy, logFile string)
// genVolFromVolIDWithMigration populate a rbdVol structure based on the volID format. // genVolFromVolIDWithMigration populate a rbdVol structure based on the volID format.
func genVolFromVolIDWithMigration( func genVolFromVolIDWithMigration(
ctx context.Context, volID string, cr *util.Credentials, secrets map[string]string) (*rbdVolume, error) { ctx context.Context, volID string, cr *util.Credentials, secrets map[string]string,
) (*rbdVolume, error) {
if isMigrationVolID(volID) { if isMigrationVolID(volID) {
pmVolID, pErr := parseMigrationVolID(volID) pmVolID, pErr := parseMigrationVolID(volID)
if pErr != nil { if pErr != nil {

View File

@ -457,7 +457,8 @@ func (rs *ReplicationServer) DisableVolumeReplication(ctx context.Context,
func disableVolumeReplication(rbdVol *rbdVolume, func disableVolumeReplication(rbdVol *rbdVolume,
mirroringInfo *librbd.MirrorImageInfo, mirroringInfo *librbd.MirrorImageInfo,
force bool) (*replication.DisableVolumeReplicationResponse, error) { force bool,
) (*replication.DisableVolumeReplicationResponse, error) {
if !mirroringInfo.Primary { if !mirroringInfo.Primary {
// Return success if the below condition is met // Return success if the below condition is met
// Local image is secondary // Local image is secondary
@ -913,9 +914,8 @@ func resyncRequired(localStatus librbd.SiteMirrorImageStatus) bool {
// In some corner cases like `re-player shutdown` the local image will not // In some corner cases like `re-player shutdown` the local image will not
// be in an error state. It would be also worth considering the `description` // be in an error state. It would be also worth considering the `description`
// field to make sure about split-brain. // field to make sure about split-brain.
splitBrain := "split-brain"
if localStatus.State == librbd.MirrorImageStatusStateError || if localStatus.State == librbd.MirrorImageStatusStateError ||
strings.Contains(localStatus.Description, splitBrain) { strings.Contains(localStatus.Description, "split-brain") {
return true return true
} }

View File

@ -27,7 +27,8 @@ import (
func createRBDClone( func createRBDClone(
ctx context.Context, ctx context.Context,
parentVol, cloneRbdVol *rbdVolume, parentVol, cloneRbdVol *rbdVolume,
snap *rbdSnapshot) error { snap *rbdSnapshot,
) error {
// create snapshot // create snapshot
err := parentVol.createSnapshot(ctx, snap) err := parentVol.createSnapshot(ctx, snap)
if err != nil { if err != nil {
@ -72,7 +73,8 @@ func cleanUpSnapshot(
ctx context.Context, ctx context.Context,
parentVol *rbdVolume, parentVol *rbdVolume,
rbdSnap *rbdSnapshot, rbdSnap *rbdSnapshot,
rbdVol *rbdVolume) error { rbdVol *rbdVolume,
) error {
err := parentVol.deleteSnapshot(ctx, rbdSnap) err := parentVol.deleteSnapshot(ctx, rbdSnap)
if err != nil { if err != nil {
if !errors.Is(err, ErrSnapNotFound) { if !errors.Is(err, ErrSnapNotFound) {
@ -119,7 +121,8 @@ func undoSnapshotCloning(
parentVol *rbdVolume, parentVol *rbdVolume,
rbdSnap *rbdSnapshot, rbdSnap *rbdSnapshot,
cloneVol *rbdVolume, cloneVol *rbdVolume,
cr *util.Credentials) error { cr *util.Credentials,
) error {
err := cleanUpSnapshot(ctx, parentVol, rbdSnap, cloneVol) err := cleanUpSnapshot(ctx, parentVol, rbdSnap, cloneVol)
if err != nil { if err != nil {
log.ErrorLog(ctx, "failed to clean up %s or %s: %v", cloneVol, rbdSnap, err) log.ErrorLog(ctx, "failed to clean up %s or %s: %v", cloneVol, rbdSnap, err)

View File

@ -119,7 +119,8 @@ func ExecCommandWithTimeout(
args ...string) ( args ...string) (
string, string,
string, string,
error) { error,
) {
var ( var (
sanitizedArgs = StripSecretInArgs(args) sanitizedArgs = StripSecretInArgs(args)
stdoutBuf bytes.Buffer stdoutBuf bytes.Buffer

View File

@ -139,7 +139,8 @@ func GetMappedID(key, value, id string) string {
// fetchMappedClusterIDAndMons returns monitors and clusterID info after checking cluster mapping. // fetchMappedClusterIDAndMons returns monitors and clusterID info after checking cluster mapping.
func fetchMappedClusterIDAndMons(ctx context.Context, func fetchMappedClusterIDAndMons(ctx context.Context,
clusterID, clusterMappingConfigFile, csiConfigFile string) (string, string, error) { clusterID, clusterMappingConfigFile, csiConfigFile string,
) (string, string, error) {
var mons string var mons string
clusterMappingInfo, err := getClusterMappingInfo(clusterID, clusterMappingConfigFile) clusterMappingInfo, err := getClusterMappingInfo(clusterID, clusterMappingConfigFile)
if err != nil { if err != nil {

View File

@ -187,9 +187,9 @@ func generateNewEncryptionPassphrase() (string, error) {
} }
// VolumeMapper returns file name and it's path to where encrypted device should be open. // VolumeMapper returns file name and it's path to where encrypted device should be open.
func VolumeMapper(volumeID string) (mapperFile, mapperFilePath string) { func VolumeMapper(volumeID string) (string, string) {
mapperFile = mapperFilePrefix + volumeID mapperFile := mapperFilePrefix + volumeID
mapperFilePath = path.Join(mapperFilePathPrefix, mapperFile) mapperFilePath := path.Join(mapperFilePathPrefix, mapperFile)
return mapperFile, mapperFilePath return mapperFile, mapperFilePath
} }
@ -248,7 +248,7 @@ func IsDeviceOpen(ctx context.Context, device string) (bool, error) {
// DeviceEncryptionStatus looks to identify if the passed device is a LUKS mapping // DeviceEncryptionStatus looks to identify if the passed device is a LUKS mapping
// and if so what the device is and the mapper name as used by LUKS. // and if so what the device is and the mapper name as used by LUKS.
// If not, just returns the original device and an empty string. // If not, just returns the original device and an empty string.
func DeviceEncryptionStatus(ctx context.Context, devicePath string) (mappedDevice, mapper string, err error) { func DeviceEncryptionStatus(ctx context.Context, devicePath string) (string, string, error) {
if !strings.HasPrefix(devicePath, mapperFilePathPrefix) { if !strings.HasPrefix(devicePath, mapperFilePathPrefix) {
return devicePath, "", nil return devicePath, "", nil
} }
@ -274,7 +274,7 @@ func DeviceEncryptionStatus(ctx context.Context, devicePath string) (mappedDevic
return "", "", fmt.Errorf("device encryption status output for %s is badly formatted: %s", return "", "", fmt.Errorf("device encryption status output for %s is badly formatted: %s",
devicePath, lines[i]) devicePath, lines[i])
} }
if strings.Compare(kv[0], "device") == 0 { if kv[0] == "device" {
return strings.TrimSpace(kv[1]), mapPath, nil return strings.TrimSpace(kv[1]), mapPath, nil
} }
} }

View File

@ -141,7 +141,8 @@ type TopologyConstrainedPool struct {
// GetTopologyFromRequest extracts TopologyConstrainedPools and passed in accessibility constraints // GetTopologyFromRequest extracts TopologyConstrainedPools and passed in accessibility constraints
// from a CSI CreateVolume request. // from a CSI CreateVolume request.
func GetTopologyFromRequest( func GetTopologyFromRequest(
req *csi.CreateVolumeRequest) (*[]TopologyConstrainedPool, *csi.TopologyRequirement, error) { req *csi.CreateVolumeRequest,
) (*[]TopologyConstrainedPool, *csi.TopologyRequirement, error) {
var topologyPools []TopologyConstrainedPool var topologyPools []TopologyConstrainedPool
// check if parameters have pool configuration pertaining to topology // check if parameters have pool configuration pertaining to topology
@ -171,7 +172,8 @@ func GetTopologyFromRequest(
// MatchPoolAndTopology returns the topology map, if the passed in pool matches any // MatchPoolAndTopology returns the topology map, if the passed in pool matches any
// passed in accessibility constraints. // passed in accessibility constraints.
func MatchPoolAndTopology(topologyPools *[]TopologyConstrainedPool, func MatchPoolAndTopology(topologyPools *[]TopologyConstrainedPool,
accessibilityRequirements *csi.TopologyRequirement, poolName string) (string, string, map[string]string, error) { accessibilityRequirements *csi.TopologyRequirement, poolName string,
) (string, string, map[string]string, error) {
var topologyPool []TopologyConstrainedPool var topologyPool []TopologyConstrainedPool
if topologyPools == nil || accessibilityRequirements == nil { if topologyPools == nil || accessibilityRequirements == nil {
@ -199,7 +201,8 @@ func MatchPoolAndTopology(topologyPools *[]TopologyConstrainedPool,
// The return variables are, image poolname, data poolname, and topology map of // The return variables are, image poolname, data poolname, and topology map of
// matched requirement. // matched requirement.
func FindPoolAndTopology(topologyPools *[]TopologyConstrainedPool, func FindPoolAndTopology(topologyPools *[]TopologyConstrainedPool,
accessibilityRequirements *csi.TopologyRequirement) (string, string, map[string]string, error) { accessibilityRequirements *csi.TopologyRequirement,
) (string, string, map[string]string, error) {
if topologyPools == nil || accessibilityRequirements == nil { if topologyPools == nil || accessibilityRequirements == nil {
return "", "", nil, nil return "", "", nil, nil
} }

View File

@ -260,7 +260,8 @@ func GenerateVolID(
cr *Credentials, cr *Credentials,
locationID int64, locationID int64,
pool, clusterID, objUUID string, pool, clusterID, objUUID string,
volIDVersion uint16) (string, error) { volIDVersion uint16,
) (string, error) {
var err error var err error
if locationID == InvalidPoolID { if locationID == InvalidPoolID {

View File

@ -99,7 +99,7 @@ func (ci CSIIdentifier) ComposeCSIID() (string, error) {
/* /*
DecomposeCSIID composes a CSIIdentifier from passed in string. DecomposeCSIID composes a CSIIdentifier from passed in string.
*/ */
func (ci *CSIIdentifier) DecomposeCSIID(composedCSIID string) (err error) { func (ci *CSIIdentifier) DecomposeCSIID(composedCSIID string) error {
bytesToProcess := uint16(len(composedCSIID)) bytesToProcess := uint16(len(composedCSIID))
// if length is less that expected constant elements, then bail out! // if length is less that expected constant elements, then bail out!