cleanup: address godot warnings

Top level comments should end in a period

Signed-off-by: Yug <yuggupta27@gmail.com>
This commit is contained in:
Yug 2020-07-19 17:51:03 +05:30 committed by mergify[bot]
parent cb7ab307dd
commit 7f94a57908
48 changed files with 233 additions and 233 deletions

View File

@ -418,7 +418,7 @@ func createRBDSecret(c kubernetes.Interface, f *framework.Framework) {
// updateSecretForEncryption is an hack to update the secrets created by rook to // updateSecretForEncryption is an hack to update the secrets created by rook to
// include the encyption key // include the encyption key
// TODO in cephcsi we need to create own users in ceph cluster and use it for E2E // TODO in cephcsi we need to create own users in ceph cluster and use it for E2E.
func updateSecretForEncryption(c kubernetes.Interface) error { func updateSecretForEncryption(c kubernetes.Interface) error {
secrets, err := c.CoreV1().Secrets(rookNamespace).Get(context.TODO(), rbdProvisionerSecretName, metav1.GetOptions{}) secrets, err := c.CoreV1().Secrets(rookNamespace).Get(context.TODO(), rbdProvisionerSecretName, metav1.GetOptions{})
if err != nil { if err != nil {
@ -633,7 +633,7 @@ func unmarshal(fileName string, obj interface{}) error {
} }
// createPVCAndApp creates pvc and pod // createPVCAndApp creates pvc and pod
// if name is not empty same will be set as pvc and app name // if name is not empty same will be set as pvc and app name.
func createPVCAndApp(name string, f *framework.Framework, pvc *v1.PersistentVolumeClaim, app *v1.Pod, pvcTimeout int) error { func createPVCAndApp(name string, f *framework.Framework, pvc *v1.PersistentVolumeClaim, app *v1.Pod, pvcTimeout int) error {
if name != "" { if name != "" {
pvc.Name = name pvc.Name = name
@ -649,7 +649,7 @@ func createPVCAndApp(name string, f *framework.Framework, pvc *v1.PersistentVolu
} }
// deletePVCAndApp delete pvc and pod // deletePVCAndApp delete pvc and pod
// if name is not empty same will be set as pvc and app name // if name is not empty same will be set as pvc and app name.
func deletePVCAndApp(name string, f *framework.Framework, pvc *v1.PersistentVolumeClaim, app *v1.Pod) error { func deletePVCAndApp(name string, f *framework.Framework, pvc *v1.PersistentVolumeClaim, app *v1.Pod) error {
if name != "" { if name != "" {
pvc.Name = name pvc.Name = name
@ -703,7 +703,7 @@ type imageInfoFromPVC struct {
} }
// getImageInfoFromPVC reads volume handle of the bound PV to the passed in PVC, // getImageInfoFromPVC reads volume handle of the bound PV to the passed in PVC,
// and returns imageInfoFromPVC or error // and returns imageInfoFromPVC or error.
func getImageInfoFromPVC(pvcNamespace, pvcName string, f *framework.Framework) (imageInfoFromPVC, error) { func getImageInfoFromPVC(pvcNamespace, pvcName string, f *framework.Framework) (imageInfoFromPVC, error) {
var imageData imageInfoFromPVC var imageData imageInfoFromPVC
@ -756,7 +756,7 @@ func getMountType(appName, appNamespace, mountPath string, f *framework.Framewor
// * authenticate with vault and ignore any stdout (we do not need output) // * authenticate with vault and ignore any stdout (we do not need output)
// * issue get request for particular key // * issue get request for particular key
// resulting in stdOut (first entry in tuple) - output that contains the key // resulting in stdOut (first entry in tuple) - output that contains the key
// or stdErr (second entry in tuple) - error getting the key // or stdErr (second entry in tuple) - error getting the key.
func readVaultSecret(key string, f *framework.Framework) (string, string) { func readVaultSecret(key string, f *framework.Framework) (string, string) {
loginCmd := fmt.Sprintf("vault login -address=%s sample_root_token_id > /dev/null", vaultAddr) loginCmd := fmt.Sprintf("vault login -address=%s sample_root_token_id > /dev/null", vaultAddr)
readSecret := fmt.Sprintf("vault kv get -address=%s %s%s", vaultAddr, vaultSecretNs, key) readSecret := fmt.Sprintf("vault kv get -address=%s %s%s", vaultAddr, vaultSecretNs, key)

View File

@ -23,12 +23,12 @@ import (
"github.com/ceph/ceph-csi/internal/util" "github.com/ceph/ceph-csi/internal/util"
) )
// MDSMap is a representation of the mds map sub-structure returned by 'ceph fs get' // MDSMap is a representation of the mds map sub-structure returned by 'ceph fs get'.
type MDSMap struct { type MDSMap struct {
FilesystemName string `json:"fs_name"` FilesystemName string `json:"fs_name"`
} }
// CephFilesystemDetails is a representation of the main json structure returned by 'ceph fs get' // CephFilesystemDetails is a representation of the main json structure returned by 'ceph fs get'.
type CephFilesystemDetails struct { type CephFilesystemDetails struct {
ID int64 `json:"id"` ID int64 `json:"id"`
MDSMap MDSMap `json:"mdsmap"` MDSMap MDSMap `json:"mdsmap"`
@ -53,7 +53,7 @@ func getFscID(ctx context.Context, monitors string, cr *util.Credentials, fsName
return fsDetails.ID, nil return fsDetails.ID, nil
} }
// CephFilesystem is a representation of the json structure returned by 'ceph fs ls' // CephFilesystem is a representation of the json structure returned by 'ceph fs ls'.
type CephFilesystem struct { type CephFilesystem struct {
Name string `json:"name"` Name string `json:"name"`
MetadataPool string `json:"metadata_pool"` MetadataPool string `json:"metadata_pool"`
@ -87,7 +87,7 @@ func getMetadataPool(ctx context.Context, monitors string, cr *util.Credentials,
return "", util.ErrPoolNotFound{Pool: fsName, Err: fmt.Errorf("fsName (%s) not found in Ceph cluster", fsName)} return "", util.ErrPoolNotFound{Pool: fsName, Err: fmt.Errorf("fsName (%s) not found in Ceph cluster", fsName)}
} }
// CephFilesystemDump is a representation of the main json structure returned by 'ceph fs dump' // CephFilesystemDump is a representation of the main json structure returned by 'ceph fs dump'.
type CephFilesystemDump struct { type CephFilesystemDump struct {
Filesystems []CephFilesystemDetails `json:"filesystems"` Filesystems []CephFilesystemDetails `json:"filesystems"`
} }

View File

@ -38,7 +38,7 @@ type ControllerServer struct {
VolumeLocks *util.VolumeLocks VolumeLocks *util.VolumeLocks
} }
// createBackingVolume creates the backing subvolume and on any error cleans up any created entities // createBackingVolume creates the backing subvolume and on any error cleans up any created entities.
func (cs *ControllerServer) createBackingVolume(ctx context.Context, volOptions *volumeOptions, vID *volumeIdentifier, secret map[string]string) error { func (cs *ControllerServer) createBackingVolume(ctx context.Context, volOptions *volumeOptions, vID *volumeIdentifier, secret map[string]string) error {
cr, err := util.NewAdminCredentials(secret) cr, err := util.NewAdminCredentials(secret)
if err != nil { if err != nil {
@ -54,7 +54,7 @@ func (cs *ControllerServer) createBackingVolume(ctx context.Context, volOptions
return nil return nil
} }
// CreateVolume creates a reservation and the volume in backend, if it is not already present // CreateVolume creates a reservation and the volume in backend, if it is not already present.
func (cs *ControllerServer) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest) (*csi.CreateVolumeResponse, error) { func (cs *ControllerServer) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest) (*csi.CreateVolumeResponse, error) {
if err := cs.validateCreateVolumeRequest(req); err != nil { if err := cs.validateCreateVolumeRequest(req); err != nil {
klog.Errorf(util.Log(ctx, "CreateVolumeRequest validation failed: %v"), err) klog.Errorf(util.Log(ctx, "CreateVolumeRequest validation failed: %v"), err)
@ -150,7 +150,7 @@ func (cs *ControllerServer) CreateVolume(ctx context.Context, req *csi.CreateVol
return &csi.CreateVolumeResponse{Volume: volume}, nil return &csi.CreateVolumeResponse{Volume: volume}, nil
} }
// DeleteVolume deletes the volume in backend and its reservation // DeleteVolume deletes the volume in backend and its reservation.
func (cs *ControllerServer) DeleteVolume(ctx context.Context, req *csi.DeleteVolumeRequest) (*csi.DeleteVolumeResponse, error) { func (cs *ControllerServer) DeleteVolume(ctx context.Context, req *csi.DeleteVolumeRequest) (*csi.DeleteVolumeResponse, error) {
if err := cs.validateDeleteVolumeRequest(); err != nil { if err := cs.validateDeleteVolumeRequest(); err != nil {
klog.Errorf(util.Log(ctx, "DeleteVolumeRequest validation failed: %v"), err) klog.Errorf(util.Log(ctx, "DeleteVolumeRequest validation failed: %v"), err)
@ -256,7 +256,7 @@ func (cs *ControllerServer) ValidateVolumeCapabilities(
}, nil }, nil
} }
// ControllerExpandVolume expands CephFS Volumes on demand based on resizer request // ControllerExpandVolume expands CephFS Volumes on demand based on resizer request.
func (cs *ControllerServer) ControllerExpandVolume(ctx context.Context, req *csi.ControllerExpandVolumeRequest) (*csi.ControllerExpandVolumeResponse, error) { func (cs *ControllerServer) ControllerExpandVolume(ctx context.Context, req *csi.ControllerExpandVolumeRequest) (*csi.ControllerExpandVolumeResponse, error) {
if err := cs.validateExpandVolumeRequest(req); err != nil { if err := cs.validateExpandVolumeRequest(req); err != nil {
klog.Errorf(util.Log(ctx, "ControllerExpandVolumeRequest validation failed: %v"), err) klog.Errorf(util.Log(ctx, "ControllerExpandVolumeRequest validation failed: %v"), err)

View File

@ -37,7 +37,7 @@ const (
radosNamespace = "csi" radosNamespace = "csi"
) )
// Driver contains the default identity,node and controller struct // Driver contains the default identity,node and controller struct.
type Driver struct { type Driver struct {
cd *csicommon.CSIDriver cd *csicommon.CSIDriver
@ -56,19 +56,19 @@ var (
volJournal *journal.Config volJournal *journal.Config
) )
// NewDriver returns new ceph driver // NewDriver returns new ceph driver.
func NewDriver() *Driver { func NewDriver() *Driver {
return &Driver{} return &Driver{}
} }
// NewIdentityServer initialize a identity server for ceph CSI driver // NewIdentityServer initialize a identity server for ceph CSI driver.
func NewIdentityServer(d *csicommon.CSIDriver) *IdentityServer { func NewIdentityServer(d *csicommon.CSIDriver) *IdentityServer {
return &IdentityServer{ return &IdentityServer{
DefaultIdentityServer: csicommon.NewDefaultIdentityServer(d), DefaultIdentityServer: csicommon.NewDefaultIdentityServer(d),
} }
} }
// NewControllerServer initialize a controller server for ceph CSI driver // NewControllerServer initialize a controller server for ceph CSI driver.
func NewControllerServer(d *csicommon.CSIDriver) *ControllerServer { func NewControllerServer(d *csicommon.CSIDriver) *ControllerServer {
return &ControllerServer{ return &ControllerServer{
DefaultControllerServer: csicommon.NewDefaultControllerServer(d), DefaultControllerServer: csicommon.NewDefaultControllerServer(d),
@ -85,7 +85,7 @@ func NewNodeServer(d *csicommon.CSIDriver, t string, topology map[string]string)
} }
// Run start a non-blocking grpc controller,node and identityserver for // Run start a non-blocking grpc controller,node and identityserver for
// ceph CSI driver which can serve multiple parallel requests // ceph CSI driver which can serve multiple parallel requests.
func (fs *Driver) Run(conf *util.Config) { func (fs *Driver) Run(conf *util.Config) {
var err error var err error
var topology map[string]string var topology map[string]string

View File

@ -17,7 +17,7 @@ limitations under the License.
package cephfs package cephfs
// ErrInvalidVolID is returned when a CSI passed VolumeID is not conformant to any known volume ID // ErrInvalidVolID is returned when a CSI passed VolumeID is not conformant to any known volume ID
// formats // formats.
type ErrInvalidVolID struct { type ErrInvalidVolID struct {
err error err error
} }
@ -33,7 +33,7 @@ func (e ErrInvalidVolID) Unwrap() error {
} }
// ErrNonStaticVolume is returned when a volume is detected as not being // ErrNonStaticVolume is returned when a volume is detected as not being
// statically provisioned // statically provisioned.
type ErrNonStaticVolume struct { type ErrNonStaticVolume struct {
err error err error
} }
@ -48,7 +48,7 @@ func (e ErrNonStaticVolume) Unwrap() error {
return e.err return e.err
} }
// ErrVolumeNotFound is returned when a subvolume is not found in CephFS // ErrVolumeNotFound is returned when a subvolume is not found in CephFS.
type ErrVolumeNotFound struct { type ErrVolumeNotFound struct {
err error err error
} }

View File

@ -24,7 +24,7 @@ import (
) )
// volumeIdentifier structure contains an association between the CSI VolumeID to its subvolume // volumeIdentifier structure contains an association between the CSI VolumeID to its subvolume
// name on the backing CephFS instance // name on the backing CephFS instance.
type volumeIdentifier struct { type volumeIdentifier struct {
FsSubvolName string FsSubvolName string
VolumeID string VolumeID string
@ -100,7 +100,7 @@ func checkVolExists(ctx context.Context, volOptions *volumeOptions, secret map[s
return &vid, nil return &vid, nil
} }
// undoVolReservation is a helper routine to undo a name reservation for a CSI VolumeName // undoVolReservation is a helper routine to undo a name reservation for a CSI VolumeName.
func undoVolReservation(ctx context.Context, volOptions *volumeOptions, vid volumeIdentifier, secret map[string]string) error { func undoVolReservation(ctx context.Context, volOptions *volumeOptions, vid volumeIdentifier, secret map[string]string) error {
cr, err := util.NewAdminCredentials(secret) cr, err := util.NewAdminCredentials(secret)
if err != nil { if err != nil {
@ -135,7 +135,7 @@ func updateTopologyConstraints(volOpts *volumeOptions) error {
} }
// reserveVol is a helper routine to request a UUID reservation for the CSI VolumeName and, // reserveVol is a helper routine to request a UUID reservation for the CSI VolumeName and,
// to generate the volume identifier for the reserved UUID // to generate the volume identifier for the reserved UUID.
func reserveVol(ctx context.Context, volOptions *volumeOptions, secret map[string]string) (*volumeIdentifier, error) { func reserveVol(ctx context.Context, volOptions *volumeOptions, secret map[string]string) (*volumeIdentifier, error) {
var ( var (
vid volumeIdentifier vid volumeIdentifier

View File

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

View File

@ -197,7 +197,7 @@ func (*NodeServer) mount(ctx context.Context, volOptions *volumeOptions, req *cs
} }
// NodePublishVolume mounts the volume mounted to the staging path to the target // NodePublishVolume mounts the volume mounted to the staging path to the target
// path // path.
func (ns *NodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublishVolumeRequest) (*csi.NodePublishVolumeResponse, error) { func (ns *NodeServer) NodePublishVolume(ctx context.Context, 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 {
@ -250,7 +250,7 @@ func (ns *NodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublis
return &csi.NodePublishVolumeResponse{}, nil return &csi.NodePublishVolumeResponse{}, nil
} }
// NodeUnpublishVolume unmounts the volume from the target path // NodeUnpublishVolume unmounts the volume from the target path.
func (ns *NodeServer) NodeUnpublishVolume(ctx context.Context, req *csi.NodeUnpublishVolumeRequest) (*csi.NodeUnpublishVolumeResponse, error) { func (ns *NodeServer) NodeUnpublishVolume(ctx context.Context, 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 {
@ -281,7 +281,7 @@ func (ns *NodeServer) NodeUnpublishVolume(ctx context.Context, req *csi.NodeUnpu
return &csi.NodeUnpublishVolumeResponse{}, nil return &csi.NodeUnpublishVolumeResponse{}, nil
} }
// NodeUnstageVolume unstages the volume from the staging path // NodeUnstageVolume unstages the volume from the staging path.
func (ns *NodeServer) NodeUnstageVolume(ctx context.Context, req *csi.NodeUnstageVolumeRequest) (*csi.NodeUnstageVolumeResponse, error) { func (ns *NodeServer) NodeUnstageVolume(ctx context.Context, 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 {
@ -306,7 +306,7 @@ func (ns *NodeServer) NodeUnstageVolume(ctx context.Context, req *csi.NodeUnstag
return &csi.NodeUnstageVolumeResponse{}, nil return &csi.NodeUnstageVolumeResponse{}, nil
} }
// NodeGetCapabilities returns the supported capabilities of the node server // NodeGetCapabilities returns the supported capabilities of the node server.
func (ns *NodeServer) NodeGetCapabilities(ctx context.Context, req *csi.NodeGetCapabilitiesRequest) (*csi.NodeGetCapabilitiesResponse, error) { func (ns *NodeServer) NodeGetCapabilities(ctx context.Context, req *csi.NodeGetCapabilitiesRequest) (*csi.NodeGetCapabilitiesResponse, error) {
return &csi.NodeGetCapabilitiesResponse{ return &csi.NodeGetCapabilitiesResponse{
Capabilities: []*csi.NodeServiceCapability{ Capabilities: []*csi.NodeServiceCapability{

View File

@ -76,7 +76,7 @@ func execCommandJSON(ctx context.Context, v interface{}, program string, args ..
return nil return nil
} }
// Controller service request validation // Controller service request validation.
func (cs *ControllerServer) validateCreateVolumeRequest(req *csi.CreateVolumeRequest) error { func (cs *ControllerServer) validateCreateVolumeRequest(req *csi.CreateVolumeRequest) error {
if err := cs.Driver.ValidateControllerServiceRequest(csi.ControllerServiceCapability_RPC_CREATE_DELETE_VOLUME); err != nil { if err := cs.Driver.ValidateControllerServiceRequest(csi.ControllerServiceCapability_RPC_CREATE_DELETE_VOLUME); err != nil {
return fmt.Errorf("invalid CreateVolumeRequest: %v", err) return fmt.Errorf("invalid CreateVolumeRequest: %v", err)
@ -108,7 +108,7 @@ func (cs *ControllerServer) validateDeleteVolumeRequest() error {
return nil return nil
} }
// Controller expand volume request validation // Controller expand volume request validation.
func (cs *ControllerServer) validateExpandVolumeRequest(req *csi.ControllerExpandVolumeRequest) error { func (cs *ControllerServer) validateExpandVolumeRequest(req *csi.ControllerExpandVolumeRequest) error {
if err := cs.Driver.ValidateControllerServiceRequest(csi.ControllerServiceCapability_RPC_EXPAND_VOLUME); err != nil { if err := cs.Driver.ValidateControllerServiceRequest(csi.ControllerServiceCapability_RPC_EXPAND_VOLUME); err != nil {
return fmt.Errorf("invalid ExpandVolumeRequest: %v", err) return fmt.Errorf("invalid ExpandVolumeRequest: %v", err)

View File

@ -67,7 +67,7 @@ var (
) )
// Load available ceph mounters installed on system into availableMounters // Load available ceph mounters installed on system into availableMounters
// Called from driver.go's Run() // Called from driver.go's Run().
func loadAvailableMounters(conf *util.Config) error { func loadAvailableMounters(conf *util.Config) error {
// #nosec // #nosec
fuseMounterProbe := exec.Command("ceph-fuse", "--version") fuseMounterProbe := exec.Command("ceph-fuse", "--version")

View File

@ -142,7 +142,7 @@ func getClusterInformation(options map[string]string) (*util.ClusterInfo, error)
} }
// 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,
secret map[string]string) (*volumeOptions, error) { secret map[string]string) (*volumeOptions, error) {
var ( var (
@ -218,7 +218,7 @@ func newVolumeOptions(ctx context.Context, requestName string, req *csi.CreateVo
} }
// newVolumeOptionsFromVolID generates a new instance of volumeOptions and volumeIdentifier // newVolumeOptionsFromVolID generates a new instance of volumeOptions and volumeIdentifier
// from the provided CSI VolumeID // from the provided CSI VolumeID.
func newVolumeOptionsFromVolID(ctx context.Context, volID string, volOpt, secrets map[string]string) (*volumeOptions, *volumeIdentifier, error) { func newVolumeOptionsFromVolID(ctx context.Context, volID string, volOpt, secrets map[string]string) (*volumeOptions, *volumeIdentifier, error) {
var ( var (
vi util.CSIIdentifier vi util.CSIIdentifier
@ -308,7 +308,7 @@ func newVolumeOptionsFromVolID(ctx context.Context, volID string, volOpt, secret
} }
// newVolumeOptionsFromMonitorList generates a new instance of volumeOptions and // newVolumeOptionsFromMonitorList generates a new instance of volumeOptions and
// volumeIdentifier from the provided CSI volume context // volumeIdentifier from the provided CSI volume context.
func newVolumeOptionsFromMonitorList(volID string, options, secrets map[string]string) (*volumeOptions, *volumeIdentifier, error) { func newVolumeOptionsFromMonitorList(volID string, options, secrets map[string]string) (*volumeOptions, *volumeIdentifier, error) {
var ( var (
opts volumeOptions opts volumeOptions
@ -361,7 +361,7 @@ func newVolumeOptionsFromMonitorList(volID string, options, secrets map[string]s
// newVolumeOptionsFromStaticVolume generates a new instance of volumeOptions and // newVolumeOptionsFromStaticVolume generates a new instance of volumeOptions and
// volumeIdentifier from the provided CSI volume context, if the provided context is // volumeIdentifier from the provided CSI volume context, if the provided context is
// detected to be a statically provisioned volume // detected to be a statically provisioned volume.
func newVolumeOptionsFromStaticVolume(volID string, options map[string]string) (*volumeOptions, *volumeIdentifier, error) { func newVolumeOptionsFromStaticVolume(volID string, options map[string]string) (*volumeOptions, *volumeIdentifier, error) {
var ( var (
opts volumeOptions opts volumeOptions

View File

@ -26,38 +26,38 @@ import (
"google.golang.org/grpc/status" "google.golang.org/grpc/status"
) )
// DefaultControllerServer points to default driver // DefaultControllerServer points to default driver.
type DefaultControllerServer struct { type DefaultControllerServer struct {
Driver *CSIDriver Driver *CSIDriver
} }
// ControllerPublishVolume publish volume on node // ControllerPublishVolume publish volume on node.
func (cs *DefaultControllerServer) ControllerPublishVolume(ctx context.Context, req *csi.ControllerPublishVolumeRequest) (*csi.ControllerPublishVolumeResponse, error) { func (cs *DefaultControllerServer) ControllerPublishVolume(ctx context.Context, 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(ctx context.Context, req *csi.ControllerUnpublishVolumeRequest) (*csi.ControllerUnpublishVolumeResponse, error) { func (cs *DefaultControllerServer) ControllerUnpublishVolume(ctx context.Context, req *csi.ControllerUnpublishVolumeRequest) (*csi.ControllerUnpublishVolumeResponse, error) {
return nil, status.Error(codes.Unimplemented, "") return nil, status.Error(codes.Unimplemented, "")
} }
// ControllerExpandVolume expand volume // ControllerExpandVolume expand volume.
func (cs *DefaultControllerServer) ControllerExpandVolume(ctx context.Context, req *csi.ControllerExpandVolumeRequest) (*csi.ControllerExpandVolumeResponse, error) { func (cs *DefaultControllerServer) ControllerExpandVolume(ctx context.Context, req *csi.ControllerExpandVolumeRequest) (*csi.ControllerExpandVolumeResponse, error) {
return nil, status.Error(codes.Unimplemented, "") return nil, status.Error(codes.Unimplemented, "")
} }
// ListVolumes lists volumes // ListVolumes lists volumes.
func (cs *DefaultControllerServer) ListVolumes(ctx context.Context, req *csi.ListVolumesRequest) (*csi.ListVolumesResponse, error) { func (cs *DefaultControllerServer) ListVolumes(ctx context.Context, 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(ctx context.Context, req *csi.GetCapacityRequest) (*csi.GetCapacityResponse, error) { func (cs *DefaultControllerServer) GetCapacity(ctx context.Context, req *csi.GetCapacityRequest) (*csi.GetCapacityResponse, error) {
return nil, status.Error(codes.Unimplemented, "") return nil, status.Error(codes.Unimplemented, "")
} }
// ControllerGetCapabilities implements the default GRPC callout. // ControllerGetCapabilities implements the default GRPC callout.
// Default supports all capabilities // Default supports all capabilities.
func (cs *DefaultControllerServer) ControllerGetCapabilities(ctx context.Context, req *csi.ControllerGetCapabilitiesRequest) (*csi.ControllerGetCapabilitiesResponse, error) { func (cs *DefaultControllerServer) ControllerGetCapabilities(ctx context.Context, req *csi.ControllerGetCapabilitiesRequest) (*csi.ControllerGetCapabilitiesResponse, error) {
util.TraceLog(ctx, "Using default ControllerGetCapabilities") util.TraceLog(ctx, "Using default ControllerGetCapabilities")
@ -66,17 +66,17 @@ func (cs *DefaultControllerServer) ControllerGetCapabilities(ctx context.Context
}, nil }, nil
} }
// CreateSnapshot creates snapshot // CreateSnapshot creates snapshot.
func (cs *DefaultControllerServer) CreateSnapshot(ctx context.Context, req *csi.CreateSnapshotRequest) (*csi.CreateSnapshotResponse, error) { func (cs *DefaultControllerServer) CreateSnapshot(ctx context.Context, req *csi.CreateSnapshotRequest) (*csi.CreateSnapshotResponse, error) {
return nil, status.Error(codes.Unimplemented, "") return nil, status.Error(codes.Unimplemented, "")
} }
// DeleteSnapshot deletes snapshot // DeleteSnapshot deletes snapshot.
func (cs *DefaultControllerServer) DeleteSnapshot(ctx context.Context, req *csi.DeleteSnapshotRequest) (*csi.DeleteSnapshotResponse, error) { func (cs *DefaultControllerServer) DeleteSnapshot(ctx context.Context, req *csi.DeleteSnapshotRequest) (*csi.DeleteSnapshotResponse, error) {
return nil, status.Error(codes.Unimplemented, "") return nil, status.Error(codes.Unimplemented, "")
} }
// ListSnapshots lists snapshots // ListSnapshots lists snapshots.
func (cs *DefaultControllerServer) ListSnapshots(ctx context.Context, req *csi.ListSnapshotsRequest) (*csi.ListSnapshotsResponse, error) { func (cs *DefaultControllerServer) ListSnapshots(ctx context.Context, req *csi.ListSnapshotsRequest) (*csi.ListSnapshotsResponse, error) {
return nil, status.Error(codes.Unimplemented, "") return nil, status.Error(codes.Unimplemented, "")
} }

View File

@ -27,7 +27,7 @@ import (
"github.com/ceph/ceph-csi/internal/util" "github.com/ceph/ceph-csi/internal/util"
) )
// CSIDriver stores driver information // CSIDriver stores driver information.
type CSIDriver struct { type CSIDriver struct {
name string name string
nodeID string nodeID string
@ -67,7 +67,7 @@ func NewCSIDriver(name, v, nodeID string) *CSIDriver {
} }
// ValidateControllerServiceRequest validates the controller // ValidateControllerServiceRequest validates the controller
// plugin capabilities // plugin capabilities.
func (d *CSIDriver) ValidateControllerServiceRequest(c csi.ControllerServiceCapability_RPC_Type) error { func (d *CSIDriver) ValidateControllerServiceRequest(c csi.ControllerServiceCapability_RPC_Type) error {
if c == csi.ControllerServiceCapability_RPC_UNKNOWN { if c == csi.ControllerServiceCapability_RPC_UNKNOWN {
return nil return nil
@ -82,7 +82,7 @@ func (d *CSIDriver) ValidateControllerServiceRequest(c csi.ControllerServiceCapa
} }
// AddControllerServiceCapabilities stores the controller capabilities // AddControllerServiceCapabilities stores the controller capabilities
// in driver object // in driver object.
func (d *CSIDriver) AddControllerServiceCapabilities(cl []csi.ControllerServiceCapability_RPC_Type) { func (d *CSIDriver) AddControllerServiceCapabilities(cl []csi.ControllerServiceCapability_RPC_Type) {
var csc []*csi.ControllerServiceCapability var csc []*csi.ControllerServiceCapability
@ -94,7 +94,7 @@ func (d *CSIDriver) AddControllerServiceCapabilities(cl []csi.ControllerServiceC
d.cap = csc d.cap = csc
} }
// AddVolumeCapabilityAccessModes stores volume access modes // AddVolumeCapabilityAccessModes stores volume access modes.
func (d *CSIDriver) AddVolumeCapabilityAccessModes(vc []csi.VolumeCapability_AccessMode_Mode) []*csi.VolumeCapability_AccessMode { func (d *CSIDriver) AddVolumeCapabilityAccessModes(vc []csi.VolumeCapability_AccessMode_Mode) []*csi.VolumeCapability_AccessMode {
var vca []*csi.VolumeCapability_AccessMode var vca []*csi.VolumeCapability_AccessMode
for _, c := range vc { for _, c := range vc {
@ -105,7 +105,7 @@ func (d *CSIDriver) AddVolumeCapabilityAccessModes(vc []csi.VolumeCapability_Acc
return vca return vca
} }
// GetVolumeCapabilityAccessModes returns access modes // GetVolumeCapabilityAccessModes returns access modes.
func (d *CSIDriver) GetVolumeCapabilityAccessModes() []*csi.VolumeCapability_AccessMode { func (d *CSIDriver) GetVolumeCapabilityAccessModes() []*csi.VolumeCapability_AccessMode {
return d.vc return d.vc
} }

View File

@ -26,12 +26,12 @@ import (
"google.golang.org/grpc/status" "google.golang.org/grpc/status"
) )
// DefaultIdentityServer stores driver object // DefaultIdentityServer stores driver object.
type DefaultIdentityServer struct { type DefaultIdentityServer struct {
Driver *CSIDriver Driver *CSIDriver
} }
// GetPluginInfo returns plugin information // GetPluginInfo returns plugin information.
func (ids *DefaultIdentityServer) GetPluginInfo(ctx context.Context, req *csi.GetPluginInfoRequest) (*csi.GetPluginInfoResponse, error) { func (ids *DefaultIdentityServer) GetPluginInfo(ctx context.Context, req *csi.GetPluginInfoRequest) (*csi.GetPluginInfoResponse, error) {
util.TraceLog(ctx, "Using default GetPluginInfo") util.TraceLog(ctx, "Using default GetPluginInfo")
@ -49,12 +49,12 @@ func (ids *DefaultIdentityServer) GetPluginInfo(ctx context.Context, req *csi.Ge
}, nil }, nil
} }
// Probe returns empty response // Probe returns empty response.
func (ids *DefaultIdentityServer) Probe(ctx context.Context, req *csi.ProbeRequest) (*csi.ProbeResponse, error) { func (ids *DefaultIdentityServer) Probe(ctx context.Context, req *csi.ProbeRequest) (*csi.ProbeResponse, error) {
return &csi.ProbeResponse{}, nil return &csi.ProbeResponse{}, nil
} }
// GetPluginCapabilities returns plugin capabilities // GetPluginCapabilities returns plugin capabilities.
func (ids *DefaultIdentityServer) GetPluginCapabilities(ctx context.Context, req *csi.GetPluginCapabilitiesRequest) (*csi.GetPluginCapabilitiesResponse, error) { func (ids *DefaultIdentityServer) GetPluginCapabilities(ctx context.Context, req *csi.GetPluginCapabilitiesRequest) (*csi.GetPluginCapabilitiesResponse, error) {
util.TraceLog(ctx, "Using default capabilities") util.TraceLog(ctx, "Using default capabilities")
return &csi.GetPluginCapabilitiesResponse{ return &csi.GetPluginCapabilitiesResponse{

View File

@ -31,28 +31,28 @@ import (
"k8s.io/kubernetes/pkg/volume" "k8s.io/kubernetes/pkg/volume"
) )
// DefaultNodeServer stores driver object // DefaultNodeServer stores driver object.
type DefaultNodeServer struct { type DefaultNodeServer struct {
Driver *CSIDriver Driver *CSIDriver
Type string Type string
} }
// NodeStageVolume returns unimplemented response // NodeStageVolume returns unimplemented response.
func (ns *DefaultNodeServer) NodeStageVolume(ctx context.Context, req *csi.NodeStageVolumeRequest) (*csi.NodeStageVolumeResponse, error) { func (ns *DefaultNodeServer) NodeStageVolume(ctx context.Context, req *csi.NodeStageVolumeRequest) (*csi.NodeStageVolumeResponse, error) {
return nil, status.Error(codes.Unimplemented, "") return nil, status.Error(codes.Unimplemented, "")
} }
// NodeUnstageVolume returns unimplemented response // NodeUnstageVolume returns unimplemented response.
func (ns *DefaultNodeServer) NodeUnstageVolume(ctx context.Context, req *csi.NodeUnstageVolumeRequest) (*csi.NodeUnstageVolumeResponse, error) { func (ns *DefaultNodeServer) NodeUnstageVolume(ctx context.Context, req *csi.NodeUnstageVolumeRequest) (*csi.NodeUnstageVolumeResponse, error) {
return nil, status.Error(codes.Unimplemented, "") return nil, status.Error(codes.Unimplemented, "")
} }
// NodeExpandVolume returns unimplemented response // NodeExpandVolume returns unimplemented response.
func (ns *DefaultNodeServer) NodeExpandVolume(ctx context.Context, req *csi.NodeExpandVolumeRequest) (*csi.NodeExpandVolumeResponse, error) { func (ns *DefaultNodeServer) NodeExpandVolume(ctx context.Context, 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(ctx context.Context, req *csi.NodeGetInfoRequest) (*csi.NodeGetInfoResponse, error) { func (ns *DefaultNodeServer) NodeGetInfo(ctx context.Context, req *csi.NodeGetInfoRequest) (*csi.NodeGetInfoResponse, error) {
util.TraceLog(ctx, "Using default NodeGetInfo") util.TraceLog(ctx, "Using default NodeGetInfo")
@ -66,7 +66,7 @@ func (ns *DefaultNodeServer) NodeGetInfo(ctx context.Context, req *csi.NodeGetIn
}, nil }, nil
} }
// NodeGetCapabilities returns RPC unknow capability // NodeGetCapabilities returns RPC unknow capability.
func (ns *DefaultNodeServer) NodeGetCapabilities(ctx context.Context, req *csi.NodeGetCapabilitiesRequest) (*csi.NodeGetCapabilitiesResponse, error) { func (ns *DefaultNodeServer) NodeGetCapabilities(ctx context.Context, req *csi.NodeGetCapabilitiesRequest) (*csi.NodeGetCapabilitiesResponse, error) {
util.TraceLog(ctx, "Using default NodeGetCapabilities") util.TraceLog(ctx, "Using default NodeGetCapabilities")
@ -83,7 +83,7 @@ func (ns *DefaultNodeServer) NodeGetCapabilities(ctx context.Context, req *csi.N
}, nil }, nil
} }
// NodeGetVolumeStats returns volume stats // NodeGetVolumeStats returns volume stats.
func (ns *DefaultNodeServer) NodeGetVolumeStats(ctx context.Context, req *csi.NodeGetVolumeStatsRequest) (*csi.NodeGetVolumeStatsResponse, error) { func (ns *DefaultNodeServer) NodeGetVolumeStats(ctx context.Context, req *csi.NodeGetVolumeStatsRequest) (*csi.NodeGetVolumeStatsResponse, error) {
var err error var err error
targetPath := req.GetVolumePath() targetPath := req.GetVolumePath()
@ -175,7 +175,7 @@ func (ns *DefaultNodeServer) NodeGetVolumeStats(ctx context.Context, req *csi.No
}, nil }, nil
} }
// ConstructMountOptions returns only unique mount options in slice // ConstructMountOptions returns only unique mount options in slice.
func ConstructMountOptions(mountOptions []string, volCap *csi.VolumeCapability) []string { func ConstructMountOptions(mountOptions []string, volCap *csi.VolumeCapability) []string {
if m := volCap.GetMount(); m != nil { if m := volCap.GetMount(); m != nil {
hasOption := func(options []string, opt string) bool { hasOption := func(options []string, opt string) bool {
@ -195,7 +195,7 @@ func ConstructMountOptions(mountOptions []string, volCap *csi.VolumeCapability)
return mountOptions return mountOptions
} }
// MountOptionContains checks the opt is present in mountOptions // MountOptionContains checks the opt is present in mountOptions.
func MountOptionContains(mountOptions []string, opt string) bool { func MountOptionContains(mountOptions []string, opt string) bool {
for _, mnt := range mountOptions { for _, mnt := range mountOptions {
if mnt == opt { if mnt == opt {

View File

@ -33,7 +33,7 @@ import (
"github.com/ceph/ceph-csi/internal/util" "github.com/ceph/ceph-csi/internal/util"
) )
// NonBlockingGRPCServer defines Non blocking GRPC server interfaces // NonBlockingGRPCServer defines Non blocking GRPC server interfaces.
type NonBlockingGRPCServer interface { type NonBlockingGRPCServer interface {
// Start services at the endpoint // Start services at the endpoint
Start(endpoint, hstOptions string, ids csi.IdentityServer, cs csi.ControllerServer, ns csi.NodeServer, metrics bool) Start(endpoint, hstOptions string, ids csi.IdentityServer, cs csi.ControllerServer, ns csi.NodeServer, metrics bool)
@ -45,24 +45,24 @@ type NonBlockingGRPCServer interface {
ForceStop() ForceStop()
} }
// NewNonBlockingGRPCServer return non-blocking GRPC // NewNonBlockingGRPCServer return non-blocking GRPC.
func NewNonBlockingGRPCServer() NonBlockingGRPCServer { func NewNonBlockingGRPCServer() NonBlockingGRPCServer {
return &nonBlockingGRPCServer{} return &nonBlockingGRPCServer{}
} }
// NonBlocking server // NonBlocking server.
type nonBlockingGRPCServer struct { type nonBlockingGRPCServer struct {
wg sync.WaitGroup wg sync.WaitGroup
server *grpc.Server server *grpc.Server
} }
// Start start service on endpoint // Start start service on endpoint.
func (s *nonBlockingGRPCServer) Start(endpoint, hstOptions string, ids csi.IdentityServer, cs csi.ControllerServer, ns csi.NodeServer, metrics bool) { func (s *nonBlockingGRPCServer) Start(endpoint, hstOptions string, ids csi.IdentityServer, cs csi.ControllerServer, ns csi.NodeServer, metrics bool) {
s.wg.Add(1) s.wg.Add(1)
go s.serve(endpoint, hstOptions, ids, cs, ns, metrics) go s.serve(endpoint, hstOptions, ids, cs, ns, metrics)
} }
// Wait blocks until the WaitGroup counter // Wait blocks until the WaitGroup counter.
func (s *nonBlockingGRPCServer) Wait() { func (s *nonBlockingGRPCServer) Wait() {
s.wg.Wait() s.wg.Wait()
} }

View File

@ -43,12 +43,12 @@ func parseEndpoint(ep string) (string, string, error) {
return "", "", fmt.Errorf("invalid endpoint: %v", ep) return "", "", fmt.Errorf("invalid endpoint: %v", ep)
} }
// NewVolumeCapabilityAccessMode returns volume access mode // NewVolumeCapabilityAccessMode returns volume access mode.
func NewVolumeCapabilityAccessMode(mode csi.VolumeCapability_AccessMode_Mode) *csi.VolumeCapability_AccessMode { func NewVolumeCapabilityAccessMode(mode csi.VolumeCapability_AccessMode_Mode) *csi.VolumeCapability_AccessMode {
return &csi.VolumeCapability_AccessMode{Mode: mode} return &csi.VolumeCapability_AccessMode{Mode: mode}
} }
// NewDefaultNodeServer initializes default node server // NewDefaultNodeServer initializes default node server.
func NewDefaultNodeServer(d *CSIDriver, t string, topology map[string]string) *DefaultNodeServer { func NewDefaultNodeServer(d *CSIDriver, t string, topology map[string]string) *DefaultNodeServer {
d.topology = topology d.topology = topology
return &DefaultNodeServer{ return &DefaultNodeServer{
@ -57,21 +57,21 @@ func NewDefaultNodeServer(d *CSIDriver, t string, topology map[string]string) *D
} }
} }
// NewDefaultIdentityServer initializes default identity servier // NewDefaultIdentityServer initializes default identity servier.
func NewDefaultIdentityServer(d *CSIDriver) *DefaultIdentityServer { func NewDefaultIdentityServer(d *CSIDriver) *DefaultIdentityServer {
return &DefaultIdentityServer{ return &DefaultIdentityServer{
Driver: d, Driver: d,
} }
} }
// NewDefaultControllerServer initializes default controller server // NewDefaultControllerServer initializes default controller server.
func NewDefaultControllerServer(d *CSIDriver) *DefaultControllerServer { func NewDefaultControllerServer(d *CSIDriver) *DefaultControllerServer {
return &DefaultControllerServer{ return &DefaultControllerServer{
Driver: d, Driver: d,
} }
} }
// NewControllerServiceCapability returns controller capabilities // NewControllerServiceCapability returns controller capabilities.
func NewControllerServiceCapability(ctrlCap csi.ControllerServiceCapability_RPC_Type) *csi.ControllerServiceCapability { func NewControllerServiceCapability(ctrlCap csi.ControllerServiceCapability_RPC_Type) *csi.ControllerServiceCapability {
return &csi.ControllerServiceCapability{ return &csi.ControllerServiceCapability{
Type: &csi.ControllerServiceCapability_Rpc{ Type: &csi.ControllerServiceCapability_Rpc{
@ -82,7 +82,7 @@ func NewControllerServiceCapability(ctrlCap csi.ControllerServiceCapability_RPC_
} }
} }
// RunNodePublishServer starts node server // RunNodePublishServer starts node server.
func RunNodePublishServer(endpoint, hstOption string, d *CSIDriver, ns csi.NodeServer, m bool) { func RunNodePublishServer(endpoint, hstOption string, d *CSIDriver, ns csi.NodeServer, m bool) {
ids := NewDefaultIdentityServer(d) ids := NewDefaultIdentityServer(d)
@ -91,7 +91,7 @@ func RunNodePublishServer(endpoint, hstOption string, d *CSIDriver, ns csi.NodeS
s.Wait() s.Wait()
} }
// RunControllerPublishServer starts controller server // RunControllerPublishServer starts controller server.
func RunControllerPublishServer(endpoint, hstOption string, d *CSIDriver, cs csi.ControllerServer, m bool) { func RunControllerPublishServer(endpoint, hstOption string, d *CSIDriver, cs csi.ControllerServer, m bool) {
ids := NewDefaultIdentityServer(d) ids := NewDefaultIdentityServer(d)
@ -100,7 +100,7 @@ func RunControllerPublishServer(endpoint, hstOption string, d *CSIDriver, cs csi
s.Wait() s.Wait()
} }
// RunControllerandNodePublishServer starts both controller and node server // RunControllerandNodePublishServer starts both controller and node server.
func RunControllerandNodePublishServer(endpoint, hstOption string, d *CSIDriver, cs csi.ControllerServer, ns csi.NodeServer, m bool) { func RunControllerandNodePublishServer(endpoint, hstOption string, d *CSIDriver, cs csi.ControllerServer, ns csi.NodeServer, m bool) {
ids := NewDefaultIdentityServer(d) ids := NewDefaultIdentityServer(d)

View File

@ -30,7 +30,7 @@ import (
klog "k8s.io/klog/v2" klog "k8s.io/klog/v2"
) )
// Length of string representation of uuid, xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx is 36 bytes // Length of string representation of uuid, xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx is 36 bytes.
const uuidEncodedLength = 36 const uuidEncodedLength = 36
/* /*
@ -111,7 +111,7 @@ const (
defaultSnapshotNamingPrefix string = "csi-snap-" defaultSnapshotNamingPrefix string = "csi-snap-"
) )
// CSIJournal defines the interface and the required key names for the above RADOS based OMaps // CSIJournal defines the interface and the required key names for the above RADOS based OMaps.
type Config struct { type Config struct {
// csiDirectory is the name of the CSI volumes object map that contains CSI volume-name (or // csiDirectory is the name of the CSI volumes object map that contains CSI volume-name (or
// snapshot name) based keys // snapshot name) based keys
@ -153,7 +153,7 @@ type Config struct {
commonPrefix string commonPrefix string
} }
// NewCSIVolumeJournal returns an instance of CSIJournal for volumes // NewCSIVolumeJournal returns an instance of CSIJournal for volumes.
func NewCSIVolumeJournal(suffix string) *Config { func NewCSIVolumeJournal(suffix string) *Config {
return &Config{ return &Config{
csiDirectory: "csi.volumes." + suffix, csiDirectory: "csi.volumes." + suffix,
@ -170,7 +170,7 @@ func NewCSIVolumeJournal(suffix string) *Config {
} }
} }
// NewCSISnapshotJournal returns an instance of CSIJournal for snapshots // NewCSISnapshotJournal returns an instance of CSIJournal for snapshots.
func NewCSISnapshotJournal(suffix string) *Config { func NewCSISnapshotJournal(suffix string) *Config {
return &Config{ return &Config{
csiDirectory: "csi.snaps." + suffix, csiDirectory: "csi.snaps." + suffix,
@ -195,7 +195,7 @@ func NewCSIVolumeJournalWithNamespace(suffix, ns string) *Config {
return j return j
} }
// GetNameForUUID returns volume name // GetNameForUUID returns volume name.
func (cj *Config) GetNameForUUID(prefix, uid string, isSnapshot bool) string { func (cj *Config) GetNameForUUID(prefix, uid string, isSnapshot bool) string {
if prefix == "" { if prefix == "" {
if isSnapshot { if isSnapshot {
@ -207,7 +207,7 @@ func (cj *Config) GetNameForUUID(prefix, uid string, isSnapshot bool) string {
return prefix + uid return prefix + uid
} }
// ImageData contains image name and stored CSI properties // ImageData contains image name and stored CSI properties.
type ImageData struct { type ImageData struct {
ImageUUID string ImageUUID string
ImagePool string ImagePool string
@ -433,7 +433,7 @@ func (conn *Connection) UndoReservation(ctx context.Context,
// reserveOMapName creates an omap with passed in oMapNamePrefix and a generated <uuid>. // reserveOMapName creates an omap with passed in oMapNamePrefix and a generated <uuid>.
// It ensures generated omap name does not already exist and if conflicts are detected, a set // It ensures generated omap name does not already exist and if conflicts are detected, a set
// number of retires with newer uuids are attempted before returning an error // number of retires with newer uuids are attempted before returning an error.
func reserveOMapName(ctx context.Context, monitors string, cr *util.Credentials, pool, namespace, oMapNamePrefix string) (string, error) { func reserveOMapName(ctx context.Context, monitors string, cr *util.Credentials, pool, namespace, oMapNamePrefix string) (string, error) {
var iterUUID string var iterUUID string
@ -581,7 +581,7 @@ func (conn *Connection) ReserveName(ctx context.Context,
return volUUID, imageName, nil return volUUID, imageName, nil
} }
// ImageAttributes contains all CSI stored image attributes, typically as OMap keys // ImageAttributes contains all CSI stored image attributes, typically as OMap keys.
type ImageAttributes struct { type ImageAttributes struct {
RequestName string // Contains the request name for the passed in UUID RequestName string // Contains the request name for the passed in UUID
SourceName string // Contains the parent image name for the passed in UUID, if it is a snapshot SourceName string // Contains the parent image name for the passed in UUID, if it is a snapshot
@ -591,7 +591,7 @@ type ImageAttributes struct {
JournalPoolID int64 // Pool ID of the CSI journal pool, stored in big endian format (on-disk data) JournalPoolID int64 // Pool ID of the CSI journal pool, stored in big endian format (on-disk data)
} }
// GetImageAttributes fetches all keys and their values, from a UUID directory, returning ImageAttributes structure // GetImageAttributes fetches all keys and their values, from a UUID directory, returning ImageAttributes structure.
func (conn *Connection) GetImageAttributes(ctx context.Context, pool, objectUUID string, snapSource bool) (*ImageAttributes, error) { func (conn *Connection) GetImageAttributes(ctx context.Context, pool, objectUUID string, snapSource bool) (*ImageAttributes, error) {
var ( var (
err error err error
@ -665,7 +665,7 @@ func (conn *Connection) GetImageAttributes(ctx context.Context, pool, objectUUID
return imageAttributes, nil return imageAttributes, nil
} }
// StoreImageID stores the image ID in omap // StoreImageID stores the image ID in omap.
func (conn *Connection) StoreImageID(ctx context.Context, pool, reservedUUID, imageID string, cr *util.Credentials) error { func (conn *Connection) StoreImageID(ctx context.Context, pool, reservedUUID, imageID string, cr *util.Credentials) error {
err := setOMapKeys(ctx, conn, pool, conn.config.namespace, conn.config.cephUUIDDirectoryPrefix+reservedUUID, err := setOMapKeys(ctx, conn, pool, conn.config.namespace, conn.config.cephUUIDDirectoryPrefix+reservedUUID,
map[string]string{conn.config.csiImageIDKey: imageID}) map[string]string{conn.config.csiImageIDKey: imageID})

View File

@ -82,7 +82,7 @@ func recordLiveness(endpoint, drivername string, pollTime, timeout time.Duration
} }
} }
// Run starts liveness collection and prometheus endpoint // Run starts liveness collection and prometheus endpoint.
func Run(conf *util.Config) { func Run(conf *util.Config) {
util.ExtendedLogMsg("Liveness Running") util.ExtendedLogMsg("Liveness Running")

View File

@ -202,7 +202,7 @@ func validateRequestedVolumeSize(rbdVol, parentVol *rbdVolume, rbdSnap *rbdSnaps
return nil return nil
} }
// CreateVolume creates the volume in backend // CreateVolume creates the volume in backend.
func (cs *ControllerServer) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest) (*csi.CreateVolumeResponse, error) { func (cs *ControllerServer) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest) (*csi.CreateVolumeResponse, error) {
if err := cs.validateVolumeReq(ctx, req); err != nil { if err := cs.validateVolumeReq(ctx, req); err != nil {
return nil, err return nil, err
@ -357,7 +357,7 @@ func flattenTemporaryClonedImages(ctx context.Context, rbdVol *rbdVolume, cr *ut
// checkFlatten ensures that that the image chain depth is not reached // checkFlatten ensures that that the image chain depth is not reached
// hardlimit or softlimit. if the softlimit is reached it adds a task and // hardlimit or softlimit. if the softlimit is reached it adds a task and
// return success,the hardlimit is reached it starts a task to flatten the // return success,the hardlimit is reached it starts a task to flatten the
// image and return Aborted // image and return Aborted.
func checkFlatten(ctx context.Context, rbdVol *rbdVolume, cr *util.Credentials) error { func checkFlatten(ctx context.Context, rbdVol *rbdVolume, cr *util.Credentials) error {
err := rbdVol.flattenRbdImage(ctx, cr, false, rbdHardMaxCloneDepth, rbdSoftMaxCloneDepth) err := rbdVol.flattenRbdImage(ctx, cr, false, rbdHardMaxCloneDepth, rbdSoftMaxCloneDepth)
if err != nil { if err != nil {
@ -931,7 +931,7 @@ func (cs *ControllerServer) doSnapshotClone(ctx context.Context, parentVol *rbdV
} }
// DeleteSnapshot deletes the snapshot in backend and removes the // DeleteSnapshot deletes the snapshot in backend and removes the
// snapshot metadata from store // snapshot metadata from store.
func (cs *ControllerServer) DeleteSnapshot(ctx context.Context, req *csi.DeleteSnapshotRequest) (*csi.DeleteSnapshotResponse, error) { func (cs *ControllerServer) DeleteSnapshot(ctx context.Context, req *csi.DeleteSnapshotRequest) (*csi.DeleteSnapshotResponse, error) {
if err := cs.Driver.ValidateControllerServiceRequest(csi.ControllerServiceCapability_RPC_CREATE_DELETE_SNAPSHOT); err != nil { if err := cs.Driver.ValidateControllerServiceRequest(csi.ControllerServiceCapability_RPC_CREATE_DELETE_SNAPSHOT); err != nil {
klog.Errorf(util.Log(ctx, "invalid delete snapshot req: %v"), protosanitizer.StripSecrets(req)) klog.Errorf(util.Log(ctx, "invalid delete snapshot req: %v"), protosanitizer.StripSecrets(req))
@ -1022,7 +1022,7 @@ func (cs *ControllerServer) DeleteSnapshot(ctx context.Context, req *csi.DeleteS
return &csi.DeleteSnapshotResponse{}, nil return &csi.DeleteSnapshotResponse{}, nil
} }
// ControllerExpandVolume expand RBD Volumes on demand based on resizer request // ControllerExpandVolume expand RBD Volumes on demand based on resizer request.
func (cs *ControllerServer) ControllerExpandVolume(ctx context.Context, req *csi.ControllerExpandVolumeRequest) (*csi.ControllerExpandVolumeResponse, error) { func (cs *ControllerServer) ControllerExpandVolume(ctx context.Context, req *csi.ControllerExpandVolumeRequest) (*csi.ControllerExpandVolumeResponse, error) {
if err := cs.Driver.ValidateControllerServiceRequest(csi.ControllerServiceCapability_RPC_EXPAND_VOLUME); err != nil { if err := cs.Driver.ValidateControllerServiceRequest(csi.ControllerServiceCapability_RPC_EXPAND_VOLUME); err != nil {
klog.Errorf(util.Log(ctx, "invalid expand volume req: %v"), protosanitizer.StripSecrets(req)) klog.Errorf(util.Log(ctx, "invalid expand volume req: %v"), protosanitizer.StripSecrets(req))

View File

@ -34,7 +34,7 @@ const (
csiConfigFile = "/etc/ceph-csi-config/config.json" csiConfigFile = "/etc/ceph-csi-config/config.json"
) )
// Driver contains the default identity,node and controller struct // Driver contains the default identity,node and controller struct.
type Driver struct { type Driver struct {
cd *csicommon.CSIDriver cd *csicommon.CSIDriver
@ -62,19 +62,19 @@ var (
skipForceFlatten bool skipForceFlatten bool
) )
// NewDriver returns new rbd driver // NewDriver returns new rbd driver.
func NewDriver() *Driver { func NewDriver() *Driver {
return &Driver{} return &Driver{}
} }
// NewIdentityServer initialize a identity server for rbd CSI driver // NewIdentityServer initialize a identity server for rbd CSI driver.
func NewIdentityServer(d *csicommon.CSIDriver) *IdentityServer { func NewIdentityServer(d *csicommon.CSIDriver) *IdentityServer {
return &IdentityServer{ return &IdentityServer{
DefaultIdentityServer: csicommon.NewDefaultIdentityServer(d), DefaultIdentityServer: csicommon.NewDefaultIdentityServer(d),
} }
} }
// NewControllerServer initialize a controller server for rbd CSI driver // NewControllerServer initialize a controller server for rbd CSI driver.
func NewControllerServer(d *csicommon.CSIDriver) *ControllerServer { func NewControllerServer(d *csicommon.CSIDriver) *ControllerServer {
return &ControllerServer{ return &ControllerServer{
DefaultControllerServer: csicommon.NewDefaultControllerServer(d), DefaultControllerServer: csicommon.NewDefaultControllerServer(d),
@ -94,7 +94,7 @@ func NewNodeServer(d *csicommon.CSIDriver, t string, topology map[string]string)
} }
// Run start a non-blocking grpc controller,node and identityserver for // Run start a non-blocking grpc controller,node and identityserver for
// rbd CSI driver which can serve multiple parallel requests // rbd CSI driver which can serve multiple parallel requests.
func (r *Driver) Run(conf *util.Config) { func (r *Driver) Run(conf *util.Config) {
var err error var err error
var topology map[string]string var topology map[string]string

View File

@ -16,7 +16,7 @@ limitations under the License.
package rbd package rbd
// ErrImageNotFound is returned when image name is not found in the cluster on the given pool // ErrImageNotFound is returned when image name is not found in the cluster on the given pool.
type ErrImageNotFound struct { type ErrImageNotFound struct {
imageName string imageName string
err error err error
@ -33,7 +33,7 @@ func (e ErrImageNotFound) Unwrap() error {
} }
// ErrSnapNotFound is returned when snap name passed is not found in the list of snapshots for the // ErrSnapNotFound is returned when snap name passed is not found in the list of snapshots for the
// given image // given image.
type ErrSnapNotFound struct { type ErrSnapNotFound struct {
snapName string snapName string
err error err error
@ -50,7 +50,7 @@ func (e ErrSnapNotFound) Unwrap() error {
} }
// ErrVolNameConflict is generated when a requested CSI volume name already exists on RBD but with // ErrVolNameConflict is generated when a requested CSI volume name already exists on RBD but with
// different properties, and hence is in conflict with the passed in CSI volume name // different properties, and hence is in conflict with the passed in CSI volume name.
type ErrVolNameConflict struct { type ErrVolNameConflict struct {
requestName string requestName string
err error err error
@ -67,7 +67,7 @@ func (e ErrVolNameConflict) Unwrap() error {
} }
// ErrInvalidVolID is returned when a CSI passed VolumeID does not conform to any known volume ID // ErrInvalidVolID is returned when a CSI passed VolumeID does not conform to any known volume ID
// formats // formats.
type ErrInvalidVolID struct { type ErrInvalidVolID struct {
err error err error
} }
@ -82,7 +82,7 @@ func (e ErrInvalidVolID) Unwrap() error {
return e.err return e.err
} }
// ErrMissingStash is returned when the image metadata stash file is not found // ErrMissingStash is returned when the image metadata stash file is not found.
type ErrMissingStash struct { type ErrMissingStash struct {
err error err error
} }
@ -97,7 +97,7 @@ func (e ErrMissingStash) Unwrap() error {
return e.err return e.err
} }
// ErrFlattenInProgress is returned when flatten is inprogess for an image // ErrFlattenInProgress is returned when flatten is inprogess for an image.
type ErrFlattenInProgress struct { type ErrFlattenInProgress struct {
err error err error
} }

View File

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

View File

@ -38,7 +38,7 @@ import (
) )
// NodeServer struct of ceph rbd driver with supported methods of CSI // NodeServer struct of ceph rbd driver with supported methods of CSI
// node server spec // node server spec.
type NodeServer struct { type NodeServer struct {
*csicommon.DefaultNodeServer *csicommon.DefaultNodeServer
mounter mount.Interface mounter mount.Interface
@ -49,7 +49,7 @@ type NodeServer struct {
// stageTransaction struct represents the state a transaction was when it either completed // stageTransaction struct represents the state a transaction was when it either completed
// or failed // or failed
// this transaction state can be used to rollback the transaction // this transaction state can be used to rollback the transaction.
type stageTransaction struct { type stageTransaction struct {
// isStagePathCreated represents whether the mount path to stage the volume on was created or not // isStagePathCreated represents whether the mount path to stage the volume on was created or not
isStagePathCreated bool isStagePathCreated bool
@ -375,7 +375,7 @@ func (ns *NodeServer) createStageMountPoint(ctx context.Context, mountPath strin
} }
// NodePublishVolume mounts the volume mounted to the device path to the target // NodePublishVolume mounts the volume mounted to the device path to the target
// path // path.
func (ns *NodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublishVolumeRequest) (*csi.NodePublishVolumeResponse, error) { func (ns *NodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublishVolumeRequest) (*csi.NodePublishVolumeResponse, error) {
err := util.ValidateNodePublishVolumeRequest(req) err := util.ValidateNodePublishVolumeRequest(req)
if err != nil { if err != nil {
@ -539,7 +539,7 @@ func (ns *NodeServer) createTargetMountPath(ctx context.Context, mountPath strin
return notMnt, err return notMnt, err
} }
// NodeUnpublishVolume unmounts the volume from the target path // NodeUnpublishVolume unmounts the volume from the target path.
func (ns *NodeServer) NodeUnpublishVolume(ctx context.Context, req *csi.NodeUnpublishVolumeRequest) (*csi.NodeUnpublishVolumeResponse, error) { func (ns *NodeServer) NodeUnpublishVolume(ctx context.Context, req *csi.NodeUnpublishVolumeRequest) (*csi.NodeUnpublishVolumeResponse, error) {
err := util.ValidateNodeUnpublishVolumeRequest(req) err := util.ValidateNodeUnpublishVolumeRequest(req)
if err != nil { if err != nil {
@ -585,7 +585,7 @@ func (ns *NodeServer) NodeUnpublishVolume(ctx context.Context, req *csi.NodeUnpu
} }
// getStagingTargetPath concats either NodeStageVolumeRequest's or // getStagingTargetPath concats either NodeStageVolumeRequest's or
// NodeUnstageVolumeRequest's target path with the volumeID // NodeUnstageVolumeRequest's target path with the volumeID.
func getStagingTargetPath(req interface{}) string { func getStagingTargetPath(req interface{}) string {
switch vr := req.(type) { switch vr := req.(type) {
case *csi.NodeStageVolumeRequest: case *csi.NodeStageVolumeRequest:
@ -597,7 +597,7 @@ func getStagingTargetPath(req interface{}) string {
return "" return ""
} }
// NodeUnstageVolume unstages the volume from the staging path // NodeUnstageVolume unstages the volume from the staging path.
func (ns *NodeServer) NodeUnstageVolume(ctx context.Context, req *csi.NodeUnstageVolumeRequest) (*csi.NodeUnstageVolumeResponse, error) { func (ns *NodeServer) NodeUnstageVolume(ctx context.Context, 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 {
@ -680,7 +680,7 @@ func (ns *NodeServer) NodeUnstageVolume(ctx context.Context, req *csi.NodeUnstag
return &csi.NodeUnstageVolumeResponse{}, nil return &csi.NodeUnstageVolumeResponse{}, nil
} }
// NodeExpandVolume resizes rbd volumes // NodeExpandVolume resizes rbd volumes.
func (ns *NodeServer) NodeExpandVolume(ctx context.Context, req *csi.NodeExpandVolumeRequest) (*csi.NodeExpandVolumeResponse, error) { func (ns *NodeServer) NodeExpandVolume(ctx context.Context, req *csi.NodeExpandVolumeRequest) (*csi.NodeExpandVolumeResponse, error) {
volumeID := req.GetVolumeId() volumeID := req.GetVolumeId()
if volumeID == "" { if volumeID == "" {
@ -740,7 +740,7 @@ func getDevicePath(ctx context.Context, volumePath string) (string, error) {
return "", fmt.Errorf("failed to get device for stagingtarget path %v", volumePath) return "", fmt.Errorf("failed to get device for stagingtarget path %v", volumePath)
} }
// NodeGetCapabilities returns the supported capabilities of the node server // NodeGetCapabilities returns the supported capabilities of the node server.
func (ns *NodeServer) NodeGetCapabilities(ctx context.Context, req *csi.NodeGetCapabilitiesRequest) (*csi.NodeGetCapabilitiesResponse, error) { func (ns *NodeServer) NodeGetCapabilities(ctx context.Context, req *csi.NodeGetCapabilitiesRequest) (*csi.NodeGetCapabilitiesResponse, error) {
return &csi.NodeGetCapabilitiesResponse{ return &csi.NodeGetCapabilitiesResponse{
Capabilities: []*csi.NodeServiceCapability{ Capabilities: []*csi.NodeServiceCapability{

View File

@ -56,7 +56,7 @@ func init() {
hasNBD = checkRbdNbdTools() hasNBD = checkRbdNbdTools()
} }
// rbdDeviceInfo strongly typed JSON spec for rbd device list output (of type krbd) // rbdDeviceInfo strongly typed JSON spec for rbd device list output (of type krbd).
type rbdDeviceInfo struct { type rbdDeviceInfo struct {
ID string `json:"id"` ID string `json:"id"`
Pool string `json:"pool"` Pool string `json:"pool"`
@ -67,7 +67,7 @@ type rbdDeviceInfo struct {
// nbdDeviceInfo strongly typed JSON spec for rbd-nbd device list output (of type nbd) // nbdDeviceInfo strongly typed JSON spec for rbd-nbd device list output (of type nbd)
// NOTE: There is a bug in rbd output that returns id as number for nbd, and string for krbd, thus // NOTE: There is a bug in rbd output that returns id as number for nbd, and string for krbd, thus
// requiring 2 different JSON structures to unmarshal the output. // requiring 2 different JSON structures to unmarshal the output.
// NOTE: image key is "name" in krbd output and "image" in nbd output, which is another difference // NOTE: image key is "name" in krbd output and "image" in nbd output, which is another difference.
type nbdDeviceInfo struct { type nbdDeviceInfo struct {
ID int64 `json:"id"` ID int64 `json:"id"`
Pool string `json:"pool"` Pool string `json:"pool"`
@ -76,7 +76,7 @@ type nbdDeviceInfo struct {
} }
// rbdGetDeviceList queries rbd about mapped devices and returns a list of rbdDeviceInfo // rbdGetDeviceList queries rbd about mapped devices and returns a list of rbdDeviceInfo
// It will selectively list devices mapped using krbd or nbd as specified by accessType // It will selectively list devices mapped using krbd or nbd as specified by accessType.
func rbdGetDeviceList(accessType string) ([]rbdDeviceInfo, error) { func rbdGetDeviceList(accessType string) ([]rbdDeviceInfo, error) {
// rbd device list --format json --device-type [krbd|nbd] // rbd device list --format json --device-type [krbd|nbd]
var ( var (
@ -278,7 +278,7 @@ func detachRBDDevice(ctx context.Context, devicePath, volumeID string, encrypted
} }
// detachRBDImageOrDeviceSpec detaches an rbd imageSpec or devicePath, with additional checking // detachRBDImageOrDeviceSpec detaches an rbd imageSpec or devicePath, with additional checking
// when imageSpec is used to decide if image is already unmapped // when imageSpec is used to decide if image is already unmapped.
func detachRBDImageOrDeviceSpec(ctx context.Context, imageOrDeviceSpec string, isImageSpec, ndbType, encrypted bool, volumeID string) error { func detachRBDImageOrDeviceSpec(ctx context.Context, imageOrDeviceSpec string, isImageSpec, ndbType, encrypted bool, volumeID string) error {
var output []byte var output []byte

View File

@ -339,7 +339,7 @@ func (rv *rbdVolume) Exists(ctx context.Context, parentVol *rbdVolume) (bool, er
} }
// reserveSnap is a helper routine to request a rbdSnapshot name reservation and generate the // reserveSnap is a helper routine to request a rbdSnapshot name reservation and generate the
// volume ID for the generated name // volume ID for the generated name.
func reserveSnap(ctx context.Context, rbdSnap *rbdSnapshot, rbdVol *rbdVolume, cr *util.Credentials) error { func reserveSnap(ctx context.Context, rbdSnap *rbdSnapshot, rbdVol *rbdVolume, cr *util.Credentials) error {
var ( var (
err error err error
@ -407,7 +407,7 @@ func updateTopologyConstraints(rbdVol *rbdVolume, rbdSnap *rbdSnapshot) error {
} }
// reserveVol is a helper routine to request a rbdVolume name reservation and generate the // reserveVol is a helper routine to request a rbdVolume name reservation and generate the
// volume ID for the generated name // volume ID for the generated name.
func reserveVol(ctx context.Context, rbdVol *rbdVolume, rbdSnap *rbdSnapshot, cr *util.Credentials) error { func reserveVol(ctx context.Context, rbdVol *rbdVolume, rbdSnap *rbdSnapshot, cr *util.Credentials) error {
var ( var (
err error err error
@ -453,7 +453,7 @@ func reserveVol(ctx context.Context, rbdVol *rbdVolume, rbdSnap *rbdSnapshot, cr
return nil return nil
} }
// undoSnapReservation is a helper routine to undo a name reservation for rbdSnapshot // undoSnapReservation is a helper routine to undo a name reservation for rbdSnapshot.
func undoSnapReservation(ctx context.Context, rbdSnap *rbdSnapshot, cr *util.Credentials) error { func undoSnapReservation(ctx context.Context, rbdSnap *rbdSnapshot, cr *util.Credentials) error {
j, err := snapJournal.Connect(rbdSnap.Monitors, cr) j, err := snapJournal.Connect(rbdSnap.Monitors, cr)
if err != nil { if err != nil {
@ -468,7 +468,7 @@ func undoSnapReservation(ctx context.Context, rbdSnap *rbdSnapshot, cr *util.Cre
return err return err
} }
// undoVolReservation is a helper routine to undo a name reservation for rbdVolume // undoVolReservation is a helper routine to undo a name reservation for rbdVolume.
func undoVolReservation(ctx context.Context, rbdVol *rbdVolume, cr *util.Credentials) error { func undoVolReservation(ctx context.Context, rbdVol *rbdVolume, cr *util.Credentials) error {
j, err := volJournal.Connect(rbdVol.Monitors, cr) j, err := volJournal.Connect(rbdVol.Monitors, cr)
if err != nil { if err != nil {

View File

@ -67,7 +67,7 @@ const (
imageOptionCloneFormat = librbd.RbdImageOption(12) imageOptionCloneFormat = librbd.RbdImageOption(12)
) )
// rbdVolume represents a CSI volume and its RBD image specifics // rbdVolume represents a CSI volume and its RBD image specifics.
type rbdVolume struct { type rbdVolume struct {
// RbdImageName is the name of the RBD image backing this rbdVolume. This does not have a // RbdImageName is the name of the RBD image backing this rbdVolume. This does not have a
// JSON tag as it is not stashed in JSON encoded config maps in v1.0.0 // JSON tag as it is not stashed in JSON encoded config maps in v1.0.0
@ -114,7 +114,7 @@ type rbdVolume struct {
ioctx *rados.IOContext ioctx *rados.IOContext
} }
// rbdSnapshot represents a CSI snapshot and its RBD snapshot specifics // rbdSnapshot represents a CSI snapshot and its RBD snapshot specifics.
type rbdSnapshot struct { type rbdSnapshot struct {
// SourceVolumeID is the volume ID of RbdImageName, that is exchanged with CSI drivers // SourceVolumeID is the volume ID of RbdImageName, that is exchanged with CSI drivers
// RbdImageName is the name of the RBD image, that is this rbdSnapshot's source image // RbdImageName is the name of the RBD image, that is this rbdSnapshot's source image
@ -144,7 +144,7 @@ var (
supportedFeatures = sets.NewString(librbd.FeatureNameLayering) supportedFeatures = sets.NewString(librbd.FeatureNameLayering)
) )
// Connect an rbdVolume to the Ceph cluster // Connect an rbdVolume to the Ceph cluster.
func (rv *rbdVolume) Connect(cr *util.Credentials) error { func (rv *rbdVolume) Connect(cr *util.Credentials) error {
if rv.conn != nil { if rv.conn != nil {
return nil return nil
@ -170,12 +170,12 @@ func (rv *rbdVolume) Destroy() {
} }
} }
// String returns the image-spec (pool/image) format of the image // String returns the image-spec (pool/image) format of the image.
func (rv *rbdVolume) String() string { func (rv *rbdVolume) String() string {
return fmt.Sprintf("%s/%s", rv.Pool, rv.RbdImageName) return fmt.Sprintf("%s/%s", rv.Pool, rv.RbdImageName)
} }
// String returns the snap-spec (pool/image@snap) format of the snapshot // String returns the snap-spec (pool/image@snap) format of the snapshot.
func (rs *rbdSnapshot) String() string { func (rs *rbdSnapshot) String() string {
return fmt.Sprintf("%s/%s@%s", rs.Pool, rs.RbdImageName, rs.RbdSnapName) return fmt.Sprintf("%s/%s@%s", rs.Pool, rs.RbdImageName, rs.RbdSnapName)
} }
@ -239,7 +239,7 @@ func (rv *rbdVolume) openIoctx() error {
} }
// getImageID queries rbd about the given image and stores its id, returns // getImageID queries rbd about the given image and stores its id, returns
// ErrImageNotFound if provided image is not found // ErrImageNotFound if provided image is not found.
func (rv *rbdVolume) getImageID() error { func (rv *rbdVolume) getImageID() error {
if rv.ImageID != "" { if rv.ImageID != "" {
return nil return nil
@ -313,7 +313,7 @@ func rbdStatus(ctx context.Context, pOpts *rbdVolume, cr *util.Credentials) (boo
// addRbdManagerTask adds a ceph manager task to execute command // addRbdManagerTask adds a ceph manager task to execute command
// asynchronously. If command is not found returns a bool set to false // asynchronously. If command is not found returns a bool set to false
// example arg ["trash", "remove","pool/image"] // example arg ["trash", "remove","pool/image"].
func addRbdManagerTask(ctx context.Context, pOpts *rbdVolume, arg []string) (bool, error) { func addRbdManagerTask(ctx context.Context, pOpts *rbdVolume, arg []string) (bool, error) {
var output []byte var output []byte
args := []string{"rbd", "task", "add"} args := []string{"rbd", "task", "add"}
@ -530,7 +530,7 @@ func (rv *rbdVolume) checkImageChainHasFeature(ctx context.Context, feature uint
} }
// genSnapFromSnapID generates a rbdSnapshot structure from the provided identifier, updating // genSnapFromSnapID generates a rbdSnapshot structure from the provided identifier, updating
// the structure with elements from on-disk snapshot metadata as well // the structure with elements from on-disk snapshot metadata as well.
func genSnapFromSnapID(ctx context.Context, rbdSnap *rbdSnapshot, snapshotID string, cr *util.Credentials) error { func genSnapFromSnapID(ctx context.Context, rbdSnap *rbdSnapshot, snapshotID string, cr *util.Credentials) error {
var ( var (
options map[string]string options map[string]string
@ -589,7 +589,7 @@ func genSnapFromSnapID(ctx context.Context, rbdSnap *rbdSnapshot, snapshotID str
} }
// genVolFromVolID generates a rbdVolume structure from the provided identifier, updating // genVolFromVolID generates a rbdVolume structure from the provided identifier, updating
// the structure with elements from on-disk image metadata as well // the structure with elements from on-disk image metadata as well.
func genVolFromVolID(ctx context.Context, volumeID string, cr *util.Credentials, secrets map[string]string) (*rbdVolume, error) { func genVolFromVolID(ctx context.Context, volumeID string, cr *util.Credentials, secrets map[string]string) (*rbdVolume, error) {
var ( var (
options map[string]string options map[string]string
@ -794,7 +794,7 @@ func genSnapFromOptions(ctx context.Context, rbdVol *rbdVolume, snapOptions map[
return rbdSnap return rbdSnap
} }
// hasSnapshotFeature checks if Layering is enabled for this image // hasSnapshotFeature checks if Layering is enabled for this image.
func (rv *rbdVolume) hasSnapshotFeature() bool { func (rv *rbdVolume) hasSnapshotFeature() bool {
return (uint64(rv.imageFeatureSet) & librbd.FeatureLayering) == librbd.FeatureLayering return (uint64(rv.imageFeatureSet) & librbd.FeatureLayering) == librbd.FeatureLayering
} }
@ -874,7 +874,7 @@ func (rv *rbdVolume) cloneRbdImageFromSnapshot(ctx context.Context, pSnapOpts *r
return nil return nil
} }
// imageInfo strongly typed JSON spec for image info // imageInfo strongly typed JSON spec for image info.
type imageInfo struct { type imageInfo struct {
ObjectUUID string `json:"name"` ObjectUUID string `json:"name"`
Size int64 `json:"size"` Size int64 `json:"size"`
@ -883,7 +883,7 @@ type imageInfo struct {
Parent parentInfo `json:"parent"` Parent parentInfo `json:"parent"`
} }
// parentInfo spec for parent volume info // parentInfo spec for parent volume info.
type parentInfo struct { type parentInfo struct {
Image string `json:"image"` Image string `json:"image"`
Pool string `json:"pool"` Pool string `json:"pool"`
@ -891,7 +891,7 @@ type parentInfo struct {
} }
// updateVolWithImageInfo updates provided rbdVolume with information from on-disk data // updateVolWithImageInfo updates provided rbdVolume with information from on-disk data
// regarding the same // regarding the same.
func (rv *rbdVolume) updateVolWithImageInfo(cr *util.Credentials) error { func (rv *rbdVolume) updateVolWithImageInfo(cr *util.Credentials) error {
// rbd --format=json info [image-spec | snap-spec] // rbd --format=json info [image-spec | snap-spec]
var imgInfo imageInfo var imgInfo imageInfo
@ -931,7 +931,7 @@ func (rv *rbdVolume) updateVolWithImageInfo(cr *util.Credentials) error {
} }
// getImageInfo queries rbd about the given image and returns its metadata, and returns // getImageInfo queries rbd about the given image and returns its metadata, and returns
// ErrImageNotFound if provided image is not found // ErrImageNotFound if provided image is not found.
func (rv *rbdVolume) getImageInfo() error { func (rv *rbdVolume) getImageInfo() error {
image, err := rv.open() image, err := rv.open()
if err != nil { if err != nil {
@ -962,7 +962,7 @@ func (rv *rbdVolume) getImageInfo() error {
/* /*
checkSnapExists queries rbd about the snapshots of the given image and returns checkSnapExists queries rbd about the snapshots of the given image and returns
ErrImageNotFound if provided image is not found, and ErrSnapNotFound if ErrImageNotFound if provided image is not found, and ErrSnapNotFound if
provided snap is not found in the images snapshot list provided snap is not found in the images snapshot list.
*/ */
func (rv *rbdVolume) checkSnapExists(rbdSnap *rbdSnapshot) error { func (rv *rbdVolume) checkSnapExists(rbdSnap *rbdSnapshot) error {
image, err := rv.open() image, err := rv.open()
@ -985,7 +985,7 @@ func (rv *rbdVolume) checkSnapExists(rbdSnap *rbdSnapshot) error {
return ErrSnapNotFound{rbdSnap.RbdSnapName, fmt.Errorf("snap %s not found", rbdSnap.String())} return ErrSnapNotFound{rbdSnap.RbdSnapName, fmt.Errorf("snap %s not found", rbdSnap.String())}
} }
// rbdImageMetadataStash strongly typed JSON spec for stashed RBD image metadata // rbdImageMetadataStash strongly typed JSON spec for stashed RBD image metadata.
type rbdImageMetadataStash struct { type rbdImageMetadataStash struct {
Version int `json:"Version"` Version int `json:"Version"`
Pool string `json:"pool"` Pool string `json:"pool"`
@ -994,16 +994,16 @@ type rbdImageMetadataStash struct {
Encrypted bool `json:"encrypted"` Encrypted bool `json:"encrypted"`
} }
// file name in which image metadata is stashed // file name in which image metadata is stashed.
const stashFileName = "image-meta.json" const stashFileName = "image-meta.json"
// spec returns the image-spec (pool/image) format of the image // spec returns the image-spec (pool/image) format of the image.
func (ri *rbdImageMetadataStash) String() string { func (ri *rbdImageMetadataStash) String() string {
return fmt.Sprintf("%s/%s", ri.Pool, ri.ImageName) return fmt.Sprintf("%s/%s", ri.Pool, ri.ImageName)
} }
// stashRBDImageMetadata stashes required fields into the stashFileName at the passed in path, in // stashRBDImageMetadata stashes required fields into the stashFileName at the passed in path, in
// JSON format // JSON format.
func stashRBDImageMetadata(volOptions *rbdVolume, path string) error { func stashRBDImageMetadata(volOptions *rbdVolume, path string) error {
var imgMeta = rbdImageMetadataStash{ var imgMeta = rbdImageMetadataStash{
Version: 2, // there are no checks for this at present Version: 2, // there are no checks for this at present
@ -1031,7 +1031,7 @@ func stashRBDImageMetadata(volOptions *rbdVolume, path string) error {
return nil return nil
} }
// lookupRBDImageMetadataStash reads and returns stashed image metadata at passed in path // lookupRBDImageMetadataStash reads and returns stashed image metadata at passed in path.
func lookupRBDImageMetadataStash(path string) (rbdImageMetadataStash, error) { func lookupRBDImageMetadataStash(path string) (rbdImageMetadataStash, error) {
var imgMeta rbdImageMetadataStash var imgMeta rbdImageMetadataStash
@ -1053,7 +1053,7 @@ func lookupRBDImageMetadataStash(path string) (rbdImageMetadataStash, error) {
return imgMeta, nil return imgMeta, nil
} }
// cleanupRBDImageMetadataStash cleans up any stashed metadata at passed in path // cleanupRBDImageMetadataStash cleans up any stashed metadata at passed in path.
func cleanupRBDImageMetadataStash(path string) error { func cleanupRBDImageMetadataStash(path string) error {
fPath := filepath.Join(path, stashFileName) fPath := filepath.Join(path, stashFileName)
if err := os.Remove(fPath); err != nil { if err := os.Remove(fPath); err != nil {
@ -1063,7 +1063,7 @@ func cleanupRBDImageMetadataStash(path string) error {
return nil return nil
} }
// resizeRBDImage resizes the given volume to new size // resizeRBDImage resizes the given volume to new size.
func resizeRBDImage(rbdVol *rbdVolume, cr *util.Credentials) error { func resizeRBDImage(rbdVol *rbdVolume, cr *util.Credentials) error {
var output []byte var output []byte
@ -1100,7 +1100,7 @@ func (rv *rbdVolume) SetMetadata(key, value string) error {
return image.SetMetadata(key, value) return image.SetMetadata(key, value)
} }
// checkRbdImageEncrypted verifies if rbd image was encrypted when created // checkRbdImageEncrypted verifies if rbd image was encrypted when created.
func (rv *rbdVolume) checkRbdImageEncrypted(ctx context.Context) (string, error) { func (rv *rbdVolume) checkRbdImageEncrypted(ctx context.Context) (string, error) {
value, err := rv.GetMetadata(encryptionMetaKey) value, err := rv.GetMetadata(encryptionMetaKey)
if err != nil { if err != nil {
@ -1122,7 +1122,7 @@ func (rv *rbdVolume) ensureEncryptionMetadataSet(status string) error {
return nil return nil
} }
// SnapshotInfo holds snapshots details // SnapshotInfo holds snapshots details.
type snapshotInfo struct { type snapshotInfo struct {
ID int `json:"id"` ID int `json:"id"`
Name string `json:"name"` Name string `json:"name"`

View File

@ -27,10 +27,10 @@ import (
klog "k8s.io/klog/v2" klog "k8s.io/klog/v2"
) )
// InvalidPoolID used to denote an invalid pool // InvalidPoolID used to denote an invalid pool.
const InvalidPoolID int64 = -1 const InvalidPoolID int64 = -1
// ExecCommand executes passed in program with args and returns separate stdout and stderr streams // ExecCommand executes passed in program with args and returns separate stdout and stderr streams.
func ExecCommand(program string, args ...string) (stdout, stderr []byte, err error) { func ExecCommand(program string, args ...string) (stdout, stderr []byte, err error) {
var ( var (
cmd = exec.Command(program, args...) // nolint: gosec, #nosec cmd = exec.Command(program, args...) // nolint: gosec, #nosec
@ -51,7 +51,7 @@ func ExecCommand(program string, args ...string) (stdout, stderr []byte, err err
} }
// GetPoolID fetches the ID of the pool that matches the passed in poolName // GetPoolID fetches the ID of the pool that matches the passed in poolName
// parameter // parameter.
func GetPoolID(monitors string, cr *Credentials, poolName string) (int64, error) { func GetPoolID(monitors string, cr *Credentials, poolName string) (int64, error) {
conn, err := connPool.Get(monitors, cr.ID, cr.KeyFile) conn, err := connPool.Get(monitors, cr.ID, cr.KeyFile)
if err != nil { if err != nil {
@ -70,7 +70,7 @@ func GetPoolID(monitors string, cr *Credentials, poolName string) (int64, error)
} }
// GetPoolName fetches the pool whose pool ID is equal to the requested poolID // GetPoolName fetches the pool whose pool ID is equal to the requested poolID
// parameter // parameter.
func GetPoolName(monitors string, cr *Credentials, poolID int64) (string, error) { func GetPoolName(monitors string, cr *Credentials, poolID int64) (string, error) {
conn, err := connPool.Get(monitors, cr.ID, cr.KeyFile) conn, err := connPool.Get(monitors, cr.ID, cr.KeyFile)
if err != nil { if err != nil {
@ -87,7 +87,7 @@ func GetPoolName(monitors string, cr *Credentials, poolID int64) (string, error)
// GetPoolIDs searches a list of pools in a cluster and returns the IDs of the pools that matches // GetPoolIDs searches a list of pools in a cluster and returns the IDs of the pools that matches
// the passed in pools // the passed in pools
// TODO this should take in a list and return a map[string(poolname)]int64(poolID) // TODO this should take in a list and return a map[string(poolname)]int64(poolID).
func GetPoolIDs(ctx context.Context, monitors, journalPool, imagePool string, cr *Credentials) (int64, int64, error) { func GetPoolIDs(ctx context.Context, monitors, journalPool, imagePool string, cr *Credentials) (int64, int64, error) {
journalPoolID, err := GetPoolID(monitors, cr, journalPool) journalPoolID, err := GetPoolID(monitors, cr, journalPool)
if err != nil { if err != nil {
@ -106,7 +106,7 @@ func GetPoolIDs(ctx context.Context, monitors, journalPool, imagePool string, cr
} }
// CreateObject creates the object name passed in and returns ErrObjectExists if the provided object // CreateObject creates the object name passed in and returns ErrObjectExists if the provided object
// is already present in rados // is already present in rados.
func CreateObject(ctx context.Context, monitors string, cr *Credentials, poolName, namespace, objectName string) error { func CreateObject(ctx context.Context, monitors string, cr *Credentials, poolName, namespace, objectName string) error {
conn := ClusterConnection{} conn := ClusterConnection{}
err := conn.Connect(monitors, cr) err := conn.Connect(monitors, cr)
@ -141,7 +141,7 @@ func CreateObject(ctx context.Context, monitors string, cr *Credentials, poolNam
} }
// RemoveObject removes the entire omap name passed in and returns ErrObjectNotFound is provided omap // RemoveObject removes the entire omap name passed in and returns ErrObjectNotFound is provided omap
// is not found in rados // is not found in rados.
func RemoveObject(ctx context.Context, monitors string, cr *Credentials, poolName, namespace, oMapName string) error { func RemoveObject(ctx context.Context, monitors string, cr *Credentials, poolName, namespace, oMapName string) error {
conn := ClusterConnection{} conn := ClusterConnection{}
err := conn.Connect(monitors, cr) err := conn.Connect(monitors, cr)

View File

@ -43,7 +43,7 @@ func createCephConfigRoot() error {
} }
// WriteCephConfig writes out a basic ceph.conf file, making it easy to use // WriteCephConfig writes out a basic ceph.conf file, making it easy to use
// ceph related CLIs // ceph related CLIs.
func WriteCephConfig() error { func WriteCephConfig() error {
if err := createCephConfigRoot(); err != nil { if err := createCephConfigRoot(); err != nil {
return err return err
@ -64,7 +64,7 @@ if any ceph commands fails it will log below error message
/etc/ceph/ceph.client.admin.keyring,/etc/ceph/ceph.keyring,/etc/ceph/keyring, /etc/ceph/ceph.client.admin.keyring,/etc/ceph/ceph.keyring,/etc/ceph/keyring,
/etc/ceph/keyring.bin,: (2) No such file or directory /etc/ceph/keyring.bin,: (2) No such file or directory
*/ */
// createKeyRingFile creates the keyring files to fix above error message logging // createKeyRingFile creates the keyring files to fix above error message logging.
func createKeyRingFile() error { func createKeyRingFile() error {
_, err := os.Create(keyRing) _, err := os.Create(keyRing)
return err return err

View File

@ -106,7 +106,7 @@ func (cp *ConnPool) generateUniqueKey(monitors, user, keyfile string) (string, e
// getExisting returns the existing rados.Conn associated with the unique key. // getExisting returns the existing rados.Conn associated with the unique key.
// //
// Requires: locked cp.lock because of ce.get() // Requires: locked cp.lock because of ce.get().
func (cp *ConnPool) getConn(unique string) *rados.Conn { func (cp *ConnPool) getConn(unique string) *rados.Conn {
ce, exists := cp.conns[unique] ce, exists := cp.conns[unique]
if exists { if exists {

View File

@ -33,7 +33,7 @@ const (
// fakeGet is used as a replacement for ConnPool.Get and does not need a // fakeGet is used as a replacement for ConnPool.Get and does not need a
// working Ceph cluster to connect to. // working Ceph cluster to connect to.
// //
// This is mostly a copy of ConnPool.Get() // This is mostly a copy of ConnPool.Get().
func (cp *ConnPool) fakeGet(monitors, user, keyfile string) (*rados.Conn, string, error) { func (cp *ConnPool) fakeGet(monitors, user, keyfile string) (*rados.Conn, string, error) {
unique, err := cp.generateUniqueKey(monitors, user, keyfile) unique, err := cp.generateUniqueKey(monitors, user, keyfile)
if err != nil { if err != nil {

View File

@ -51,7 +51,7 @@ const (
) )
// EncryptionKMS provides external Key Management System for encryption // EncryptionKMS provides external Key Management System for encryption
// passphrases storage // passphrases storage.
type EncryptionKMS interface { type EncryptionKMS interface {
GetPassphrase(key string) (string, error) GetPassphrase(key string) (string, error)
SavePassphrase(key, value string) error SavePassphrase(key, value string) error
@ -59,12 +59,12 @@ type EncryptionKMS interface {
GetID() string GetID() string
} }
// MissingPassphrase is an error instructing to generate new passphrase // MissingPassphrase is an error instructing to generate new passphrase.
type MissingPassphrase struct { type MissingPassphrase struct {
error error
} }
// SecretsKMS is default KMS implementation that means no KMS is in use // SecretsKMS is default KMS implementation that means no KMS is in use.
type SecretsKMS struct { type SecretsKMS struct {
passphrase string passphrase string
} }
@ -77,28 +77,28 @@ func initSecretsKMS(secrets map[string]string) (EncryptionKMS, error) {
return SecretsKMS{passphrase: passphraseValue}, nil return SecretsKMS{passphrase: passphraseValue}, nil
} }
// GetPassphrase returns passphrase from Kubernetes secrets // GetPassphrase returns passphrase from Kubernetes secrets.
func (kms SecretsKMS) GetPassphrase(key string) (string, error) { func (kms SecretsKMS) GetPassphrase(key string) (string, error) {
return kms.passphrase, nil return kms.passphrase, nil
} }
// SavePassphrase is not implemented // SavePassphrase is not implemented.
func (kms SecretsKMS) SavePassphrase(key, value string) error { func (kms SecretsKMS) SavePassphrase(key, value string) error {
return fmt.Errorf("save new passphrase is not implemented for Kubernetes secrets") return fmt.Errorf("save new passphrase is not implemented for Kubernetes secrets")
} }
// DeletePassphrase is doing nothing as no new passphrases are saved with // DeletePassphrase is doing nothing as no new passphrases are saved with
// SecretsKMS // SecretsKMS.
func (kms SecretsKMS) DeletePassphrase(key string) error { func (kms SecretsKMS) DeletePassphrase(key string) error {
return nil return nil
} }
// GetID is returning ID representing default KMS `default` // GetID is returning ID representing default KMS `default`.
func (kms SecretsKMS) GetID() string { func (kms SecretsKMS) GetID() string {
return defaultKMSType return defaultKMSType
} }
// GetKMS returns an instance of Key Management System // GetKMS returns an instance of Key Management System.
func GetKMS(kmsID string, secrets map[string]string) (EncryptionKMS, error) { func GetKMS(kmsID string, secrets map[string]string) (EncryptionKMS, error) {
if kmsID == "" || kmsID == defaultKMSType { if kmsID == "" || kmsID == defaultKMSType {
return initSecretsKMS(secrets) return initSecretsKMS(secrets)
@ -141,7 +141,7 @@ func GetKMS(kmsID string, secrets map[string]string) (EncryptionKMS, error) {
return nil, fmt.Errorf("unknown encryption KMS type %s", kmsType) return nil, fmt.Errorf("unknown encryption KMS type %s", kmsType)
} }
// GetCryptoPassphrase Retrieves passphrase to encrypt volume // GetCryptoPassphrase Retrieves passphrase to encrypt volume.
func GetCryptoPassphrase(ctx context.Context, volumeID string, kms EncryptionKMS) (string, error) { func GetCryptoPassphrase(ctx context.Context, volumeID string, kms EncryptionKMS) (string, error) {
passphrase, err := kms.GetPassphrase(volumeID) passphrase, err := kms.GetPassphrase(volumeID)
if err == nil { if err == nil {
@ -164,7 +164,7 @@ func GetCryptoPassphrase(ctx context.Context, volumeID string, kms EncryptionKMS
return "", err return "", err
} }
// generateNewEncryptionPassphrase generates a random passphrase for encryption // generateNewEncryptionPassphrase generates a random passphrase for encryption.
func generateNewEncryptionPassphrase() (string, error) { func generateNewEncryptionPassphrase() (string, error) {
bytesPassphrase := make([]byte, encryptionPassphraseSize) bytesPassphrase := make([]byte, encryptionPassphraseSize)
_, err := rand.Read(bytesPassphrase) _, err := rand.Read(bytesPassphrase)
@ -174,14 +174,14 @@ func generateNewEncryptionPassphrase() (string, error) {
return base64.URLEncoding.EncodeToString(bytesPassphrase), nil return base64.URLEncoding.EncodeToString(bytesPassphrase), nil
} }
// 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) (mapperFile, mapperFilePath string) {
mapperFile = mapperFilePrefix + volumeID mapperFile = mapperFilePrefix + volumeID
mapperFilePath = path.Join(mapperFilePathPrefix, mapperFile) mapperFilePath = path.Join(mapperFilePathPrefix, mapperFile)
return mapperFile, mapperFilePath return mapperFile, mapperFilePath
} }
// EncryptVolume encrypts provided device with LUKS // EncryptVolume encrypts provided device with LUKS.
func EncryptVolume(ctx context.Context, devicePath, passphrase string) error { func EncryptVolume(ctx context.Context, devicePath, passphrase string) error {
DebugLog(ctx, "Encrypting device %s with LUKS", devicePath) DebugLog(ctx, "Encrypting device %s with LUKS", devicePath)
if _, _, err := LuksFormat(devicePath, passphrase); err != nil { if _, _, err := LuksFormat(devicePath, passphrase); err != nil {
@ -190,21 +190,21 @@ func EncryptVolume(ctx context.Context, devicePath, passphrase string) error {
return nil return nil
} }
// OpenEncryptedVolume opens volume so that it can be used by the client // OpenEncryptedVolume opens volume so that it can be used by the client.
func OpenEncryptedVolume(ctx context.Context, devicePath, mapperFile, passphrase string) error { func OpenEncryptedVolume(ctx context.Context, devicePath, mapperFile, passphrase string) error {
DebugLog(ctx, "Opening device %s with LUKS on %s", devicePath, mapperFile) DebugLog(ctx, "Opening device %s with LUKS on %s", devicePath, mapperFile)
_, _, err := LuksOpen(devicePath, mapperFile, passphrase) _, _, err := LuksOpen(devicePath, mapperFile, passphrase)
return err return err
} }
// CloseEncryptedVolume closes encrypted volume so it can be detached // CloseEncryptedVolume closes encrypted volume so it can be detached.
func CloseEncryptedVolume(ctx context.Context, mapperFile string) error { func CloseEncryptedVolume(ctx context.Context, mapperFile string) error {
DebugLog(ctx, "Closing LUKS device %s", mapperFile) DebugLog(ctx, "Closing LUKS device %s", mapperFile)
_, _, err := LuksClose(mapperFile) _, _, err := LuksClose(mapperFile)
return err return err
} }
// IsDeviceOpen determines if encrypted device is already open // IsDeviceOpen determines if encrypted device is already open.
func IsDeviceOpen(ctx context.Context, device string) (bool, error) { func IsDeviceOpen(ctx context.Context, device string) (bool, error) {
_, mappedFile, err := DeviceEncryptionStatus(ctx, device) _, mappedFile, err := DeviceEncryptionStatus(ctx, device)
return (mappedFile != ""), err return (mappedFile != ""), err

View File

@ -23,22 +23,22 @@ import (
"strings" "strings"
) )
// LuksFormat sets up volume as an encrypted LUKS partition // LuksFormat sets up volume as an encrypted LUKS partition.
func LuksFormat(devicePath, passphrase string) (stdout, stderr []byte, err error) { func LuksFormat(devicePath, passphrase string) (stdout, stderr []byte, err error) {
return execCryptsetupCommand(&passphrase, "-q", "luksFormat", "--hash", "sha256", devicePath, "-d", "/dev/stdin") return execCryptsetupCommand(&passphrase, "-q", "luksFormat", "--hash", "sha256", devicePath, "-d", "/dev/stdin")
} }
// LuksOpen opens LUKS encrypted partition and sets up a mapping // LuksOpen opens LUKS encrypted partition and sets up a mapping.
func LuksOpen(devicePath, mapperFile, passphrase string) (stdout, stderr []byte, err error) { func LuksOpen(devicePath, mapperFile, passphrase string) (stdout, stderr []byte, err error) {
return execCryptsetupCommand(&passphrase, "luksOpen", devicePath, mapperFile, "-d", "/dev/stdin") return execCryptsetupCommand(&passphrase, "luksOpen", devicePath, mapperFile, "-d", "/dev/stdin")
} }
// LuksClose removes existing mapping // LuksClose removes existing mapping.
func LuksClose(mapperFile string) (stdout, stderr []byte, err error) { func LuksClose(mapperFile string) (stdout, stderr []byte, err error) {
return execCryptsetupCommand(nil, "luksClose", mapperFile) return execCryptsetupCommand(nil, "luksClose", mapperFile)
} }
// LuksStatus returns encryption status of a provided device // LuksStatus returns encryption status of a provided device.
func LuksStatus(mapperFile string) (stdout, stderr []byte, err error) { func LuksStatus(mapperFile string) (stdout, stderr []byte, err error) {
return execCryptsetupCommand(nil, "status", mapperFile) return execCryptsetupCommand(nil, "status", mapperFile)
} }

View File

@ -29,7 +29,7 @@ const (
defaultCsiSubvolumeGroup = "csi" defaultCsiSubvolumeGroup = "csi"
) )
// ClusterInfo strongly typed JSON spec for the below JSON structure // ClusterInfo strongly typed JSON spec for the below JSON structure.
type ClusterInfo struct { type ClusterInfo struct {
// ClusterID is used for unique identification // ClusterID is used for unique identification
ClusterID string `json:"clusterID"` ClusterID string `json:"clusterID"`
@ -57,7 +57,7 @@ type ClusterInfo struct {
// } // }
// }, // },
// ... // ...
// ] // ].
func readClusterInfo(pathToConfig, clusterID string) (*ClusterInfo, error) { func readClusterInfo(pathToConfig, clusterID string) (*ClusterInfo, error) {
var config []ClusterInfo var config []ClusterInfo
@ -83,7 +83,7 @@ func readClusterInfo(pathToConfig, clusterID string) (*ClusterInfo, error) {
return nil, fmt.Errorf("missing configuration for cluster ID (%s)", clusterID) return nil, fmt.Errorf("missing configuration for cluster ID (%s)", clusterID)
} }
// Mons returns a comma separated MON list from the csi config for the given clusterID // Mons returns a comma separated MON list from the csi config for the given clusterID.
func Mons(pathToConfig, clusterID string) (string, error) { func Mons(pathToConfig, clusterID string) (string, error) {
cluster, err := readClusterInfo(pathToConfig, clusterID) cluster, err := readClusterInfo(pathToConfig, clusterID)
if err != nil { if err != nil {
@ -96,7 +96,7 @@ func Mons(pathToConfig, clusterID string) (string, error) {
return strings.Join(cluster.Monitors, ","), nil return strings.Join(cluster.Monitors, ","), nil
} }
// CephFSSubvolumeGroup returns the subvolumeGroup for CephFS volumes. If not set, it returns the default value "csi" // CephFSSubvolumeGroup returns the subvolumeGroup for CephFS volumes. If not set, it returns the default value "csi".
func CephFSSubvolumeGroup(pathToConfig, clusterID string) (string, error) { func CephFSSubvolumeGroup(pathToConfig, clusterID string) (string, error) {
cluster, err := readClusterInfo(pathToConfig, clusterID) cluster, err := readClusterInfo(pathToConfig, clusterID)
if err != nil { if err != nil {

View File

@ -16,7 +16,7 @@ limitations under the License.
package util package util
// ErrKeyNotFound is returned when requested key in omap is not found // ErrKeyNotFound is returned when requested key in omap is not found.
type ErrKeyNotFound struct { type ErrKeyNotFound struct {
keyName string keyName string
err error err error
@ -37,7 +37,7 @@ func (e ErrKeyNotFound) Unwrap() error {
return e.err return e.err
} }
// ErrObjectExists is returned when named omap is already present in rados // ErrObjectExists is returned when named omap is already present in rados.
type ErrObjectExists struct { type ErrObjectExists struct {
objectName string objectName string
err error err error
@ -53,7 +53,7 @@ func (e ErrObjectExists) Unwrap() error {
return e.err return e.err
} }
// ErrObjectNotFound is returned when named omap is not found in rados // ErrObjectNotFound is returned when named omap is not found in rados.
type ErrObjectNotFound struct { type ErrObjectNotFound struct {
oMapName string oMapName string
err error err error
@ -70,7 +70,7 @@ func (e ErrObjectNotFound) Unwrap() error {
} }
// ErrSnapNameConflict is generated when a requested CSI snap name already exists on RBD but with // ErrSnapNameConflict is generated when a requested CSI snap name already exists on RBD but with
// different properties, and hence is in conflict with the passed in CSI volume name // different properties, and hence is in conflict with the passed in CSI volume name.
type ErrSnapNameConflict struct { type ErrSnapNameConflict struct {
requestName string requestName string
err error err error
@ -91,7 +91,7 @@ func NewErrSnapNameConflict(name string, err error) ErrSnapNameConflict {
return ErrSnapNameConflict{name, err} return ErrSnapNameConflict{name, err}
} }
// ErrPoolNotFound is returned when pool is not found // ErrPoolNotFound is returned when pool is not found.
type ErrPoolNotFound struct { type ErrPoolNotFound struct {
Pool string Pool string
Err error Err error

View File

@ -10,13 +10,13 @@ import (
klog "k8s.io/klog/v2" klog "k8s.io/klog/v2"
) )
// ValidateURL validates the url // ValidateURL validates the url.
func ValidateURL(c *Config) error { func ValidateURL(c *Config) error {
_, err := url.Parse(c.MetricsPath) _, err := url.Parse(c.MetricsPath)
return err return err
} }
// StartMetricsServer starts http server // StartMetricsServer starts http server.
func StartMetricsServer(c *Config) { func StartMetricsServer(c *Config) {
addr := net.JoinHostPort(c.MetricsIP, strconv.Itoa(c.MetricsPort)) addr := net.JoinHostPort(c.MetricsIP, strconv.Itoa(c.MetricsPort))
http.Handle(c.MetricsPath, promhttp.Handler()) http.Handle(c.MetricsPath, promhttp.Handler())

View File

@ -20,7 +20,7 @@ import (
"testing" "testing"
) )
// very basic tests for the moment // very basic tests for the moment.
func TestIDLocker(t *testing.T) { func TestIDLocker(t *testing.T) {
fakeID := "fake-id" fakeID := "fake-id"
locks := NewVolumeLocks() locks := NewVolumeLocks()

View File

@ -25,7 +25,7 @@ import (
klog "k8s.io/klog/v2" klog "k8s.io/klog/v2"
) )
// NewK8sClient create kubernetes client // NewK8sClient create kubernetes client.
func NewK8sClient() *k8s.Clientset { func NewK8sClient() *k8s.Clientset {
var cfg *rest.Config var cfg *rest.Config
var err error var err error

View File

@ -20,13 +20,13 @@ import (
type contextKey string type contextKey string
// CtxKey for context based logging // CtxKey for context based logging.
var CtxKey = contextKey("ID") var CtxKey = contextKey("ID")
// ReqID for logging request ID // ReqID for logging request ID.
var ReqID = contextKey("Req-ID") var ReqID = contextKey("Req-ID")
// Log helps in context based logging // Log helps in context based logging.
func Log(ctx context.Context, format string) string { func Log(ctx context.Context, format string) string {
id := ctx.Value(CtxKey) id := ctx.Value(CtxKey)
if id == nil { if id == nil {

View File

@ -35,7 +35,7 @@ const (
// find the line containing the pids group from the /proc/self/cgroup file // find the line containing the pids group from the /proc/self/cgroup file
// $ grep 'pids' /proc/self/cgroup // $ grep 'pids' /proc/self/cgroup
// 7:pids:/kubepods.slice/kubepods-besteffort.slice/....scope // 7:pids:/kubepods.slice/kubepods-besteffort.slice/....scope
// $ cat /sys/fs/cgroup/pids + *.scope + /pids.max // $ cat /sys/fs/cgroup/pids + *.scope + /pids.max.
func getCgroupPidsFile() (string, error) { func getCgroupPidsFile() (string, error) {
cgroup, err := os.Open(procCgroup) cgroup, err := os.Open(procCgroup)
if err != nil { if err != nil {

View File

@ -22,7 +22,7 @@ import (
) )
// minimal test to check if GetPIDLimit() returns an int // minimal test to check if GetPIDLimit() returns an int
// changing the limit require root permissions, not tested // changing the limit require root permissions, not tested.
func TestGetPIDLimit(t *testing.T) { func TestGetPIDLimit(t *testing.T) {
runTest := os.Getenv("CEPH_CSI_RUN_ALL_TESTS") runTest := os.Getenv("CEPH_CSI_RUN_ALL_TESTS")
if runTest == "" { if runTest == "" {

View File

@ -44,7 +44,7 @@ func k8sGetNodeLabels(nodeName string) (map[string]string, error) {
// GetTopologyFromDomainLabels returns the CSI topology map, determined from // GetTopologyFromDomainLabels returns the CSI topology map, determined from
// the domain labels and their values from the CO system // the domain labels and their values from the CO system
// Expects domainLabels in arg to be in the format "[prefix/]<name>,[prefix/]<name>,...", // Expects domainLabels in arg to be in the format "[prefix/]<name>,[prefix/]<name>,...",.
func GetTopologyFromDomainLabels(domainLabels, nodeName, driverName string) (map[string]string, error) { func GetTopologyFromDomainLabels(domainLabels, nodeName, driverName string) (map[string]string, error) {
if domainLabels == "" { if domainLabels == "" {
return nil, nil return nil, nil
@ -122,7 +122,7 @@ type topologySegment struct {
DomainValue string `json:"value"` DomainValue string `json:"value"`
} }
// TopologyConstrainedPool stores the pool name and a list of its associated topology domain values // TopologyConstrainedPool stores the pool name and a list of its associated topology domain values.
type TopologyConstrainedPool struct { type TopologyConstrainedPool struct {
PoolName string `json:"poolName"` PoolName string `json:"poolName"`
DataPoolName string `json:"dataPool"` DataPoolName string `json:"dataPool"`
@ -130,7 +130,7 @@ 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(req *csi.CreateVolumeRequest) (*[]TopologyConstrainedPool, *csi.TopologyRequirement, error) { func GetTopologyFromRequest(req *csi.CreateVolumeRequest) (*[]TopologyConstrainedPool, *csi.TopologyRequirement, error) {
var ( var (
topologyPools []TopologyConstrainedPool topologyPools []TopologyConstrainedPool
@ -158,7 +158,7 @@ func GetTopologyFromRequest(req *csi.CreateVolumeRequest) (*[]TopologyConstraine
} }
// MatchTopologyForPool returns the topology map, if the passed in pool matches any // MatchTopologyForPool returns the topology map, if the passed in pool matches any
// passed in accessibility constraints // passed in accessibility constraints.
func MatchTopologyForPool(topologyPools *[]TopologyConstrainedPool, func MatchTopologyForPool(topologyPools *[]TopologyConstrainedPool,
accessibilityRequirements *csi.TopologyRequirement, poolName string) (map[string]string, error) { accessibilityRequirements *csi.TopologyRequirement, poolName string) (map[string]string, error) {
var topologyPool []TopologyConstrainedPool var topologyPool []TopologyConstrainedPool
@ -187,7 +187,7 @@ func MatchTopologyForPool(topologyPools *[]TopologyConstrainedPool,
// FindPoolAndTopology loops through passed in "topologyPools" and also related // FindPoolAndTopology loops through passed in "topologyPools" and also related
// accessibility requirements, to determine which pool matches the requirement. // accessibility requirements, to determine which pool matches the requirement.
// 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 {
@ -217,7 +217,7 @@ func FindPoolAndTopology(topologyPools *[]TopologyConstrainedPool,
// matchPoolToTopology loops through passed in pools, and for each pool checks if all // matchPoolToTopology loops through passed in pools, and for each pool checks if all
// requested topology segments are present and match the request, returning the first pool // requested topology segments are present and match the request, returning the first pool
// that hence matches (or an empty string if none match) // that hence matches (or an empty string if none match).
func matchPoolToTopology(topologyPools *[]TopologyConstrainedPool, topology *csi.Topology) TopologyConstrainedPool { func matchPoolToTopology(topologyPools *[]TopologyConstrainedPool, topology *csi.Topology) TopologyConstrainedPool {
domainMap := extractDomainsFromlabels(topology) domainMap := extractDomainsFromlabels(topology)
@ -243,7 +243,7 @@ func matchPoolToTopology(topologyPools *[]TopologyConstrainedPool, topology *csi
} }
// extractDomainsFromlabels returns the domain name map, from passed in domain segments, // extractDomainsFromlabels returns the domain name map, from passed in domain segments,
// which is of the form [prefix/]<name> // which is of the form [prefix/]<name>.
func extractDomainsFromlabels(topology *csi.Topology) map[string]string { func extractDomainsFromlabels(topology *csi.Topology) map[string]string {
domainMap := make(map[string]string) domainMap := make(map[string]string)
for domainKey, value := range topology.GetSegments() { for domainKey, value := range topology.GetSegments() {

View File

@ -35,7 +35,7 @@ func checkAndReportError(t *testing.T, msg string, err error) {
} }
} }
// TestFindPoolAndTopology also tests MatchTopologyForPool // TestFindPoolAndTopology also tests MatchTopologyForPool.
func TestFindPoolAndTopology(t *testing.T) { func TestFindPoolAndTopology(t *testing.T) {
var err error var err error
var label1 = "region" var label1 = "region"

View File

@ -44,7 +44,7 @@ const (
Trace Trace
) )
// RoundOffVolSize rounds up given quantity upto chunks of MiB/GiB // RoundOffVolSize rounds up given quantity upto chunks of MiB/GiB.
func RoundOffVolSize(size int64) int64 { func RoundOffVolSize(size int64) int64 {
size = RoundOffBytes(size) size = RoundOffBytes(size)
// convert size back to MiB for rbd CLI // convert size back to MiB for rbd CLI
@ -53,7 +53,7 @@ func RoundOffVolSize(size int64) int64 {
// RoundOffBytes converts roundoff the size // RoundOffBytes converts roundoff the size
// 1.1Mib will be round off to 2Mib same for GiB // 1.1Mib will be round off to 2Mib same for GiB
// size less than 1MiB will be round off to 1MiB // size less than 1MiB will be round off to 1MiB.
func RoundOffBytes(bytes int64) int64 { func RoundOffBytes(bytes int64) int64 {
var num int64 var num int64
floatBytes := float64(bytes) floatBytes := float64(bytes)
@ -68,7 +68,7 @@ func RoundOffBytes(bytes int64) int64 {
return num return num
} }
// variables which will be set during the build time // variables which will be set during the build time.
var ( var (
// GitCommit tell the latest git commit image is built from // GitCommit tell the latest git commit image is built from
GitCommit string GitCommit string
@ -76,7 +76,7 @@ var (
DriverVersion string DriverVersion string
) )
// Config holds the parameters list which can be configured // Config holds the parameters list which can be configured.
type Config struct { type Config struct {
Vtype string // driver type [rbd|cephfs|liveness] Vtype string // driver type [rbd|cephfs|liveness]
Endpoint string // CSI endpoint Endpoint string // CSI endpoint
@ -119,7 +119,7 @@ type Config struct {
MaxSnapshotsOnImage uint MaxSnapshotsOnImage uint
} }
// ValidateDriverName validates the driver name // ValidateDriverName validates the driver name.
func ValidateDriverName(driverName string) error { func ValidateDriverName(driverName string) error {
if driverName == "" { if driverName == "" {
return errors.New("driver name is empty") return errors.New("driver name is empty")
@ -150,7 +150,7 @@ func GetKernelVersion() (string, error) {
return strings.TrimRight(string(utsname.Release[:]), "\x00"), nil return strings.TrimRight(string(utsname.Release[:]), "\x00"), nil
} }
// KernelVersion holds kernel related informations // KernelVersion holds kernel related informations.
type KernelVersion struct { type KernelVersion struct {
Version int Version int
PatchLevel int PatchLevel int
@ -235,7 +235,7 @@ func CheckKernelSupport(release string, supportedVersions []KernelVersion) bool
} }
// GenerateVolID generates a volume ID based on passed in parameters and version, to be returned // GenerateVolID generates a volume ID based on passed in parameters and version, to be returned
// to the CO system // to the CO system.
func GenerateVolID(ctx context.Context, monitors string, cr *Credentials, locationID int64, pool, clusterID, objUUID string, volIDVersion uint16) (string, error) { func GenerateVolID(ctx context.Context, monitors string, cr *Credentials, locationID int64, pool, clusterID, objUUID string, volIDVersion uint16) (string, error) {
var err error var err error
@ -259,12 +259,12 @@ func GenerateVolID(ctx context.Context, monitors string, cr *Credentials, locati
return volID, err return volID, err
} }
// CreateMountPoint creates the directory with given path // CreateMountPoint creates the directory with given path.
func CreateMountPoint(mountPath string) error { func CreateMountPoint(mountPath string) error {
return os.MkdirAll(mountPath, 0750) return os.MkdirAll(mountPath, 0750)
} }
// checkDirExists checks directory exists or not // checkDirExists checks directory exists or not.
func checkDirExists(p string) bool { func checkDirExists(p string) bool {
if _, err := os.Stat(p); os.IsNotExist(err) { if _, err := os.Stat(p); os.IsNotExist(err) {
return false return false
@ -272,7 +272,7 @@ func checkDirExists(p string) bool {
return true return true
} }
// IsMountPoint checks if the given path is mountpoint or not // IsMountPoint checks if the given path is mountpoint or not.
func IsMountPoint(p string) (bool, error) { func IsMountPoint(p string) (bool, error) {
dummyMount := mount.New("") dummyMount := mount.New("")
notMnt, err := dummyMount.IsLikelyNotMountPoint(p) notMnt, err := dummyMount.IsLikelyNotMountPoint(p)
@ -283,7 +283,7 @@ func IsMountPoint(p string) (bool, error) {
return !notMnt, nil return !notMnt, nil
} }
// Mount mounts the source to target path // Mount mounts the source to target path.
func Mount(source, target, fstype string, options []string) error { func Mount(source, target, fstype string, options []string) error {
dummyMount := mount.New("") dummyMount := mount.New("")
return dummyMount.Mount(source, target, fstype, options) return dummyMount.Mount(source, target, fstype, options)
@ -321,7 +321,7 @@ func contains(s []string, key string) bool {
return false return false
} }
// DefaultLog helps in logging with klog.level 1 // DefaultLog helps in logging with klog.level 1.
func DefaultLog(message string, args ...interface{}) { func DefaultLog(message string, args ...interface{}) {
logMessage := fmt.Sprintf(message, args...) logMessage := fmt.Sprintf(message, args...)
// If logging is disabled, don't evaluate the arguments // If logging is disabled, don't evaluate the arguments
@ -330,7 +330,7 @@ func DefaultLog(message string, args ...interface{}) {
} }
} }
// UsefulLog helps in logging with klog.level 2 // UsefulLog helps in logging with klog.level 2.
func UsefulLog(ctx context.Context, message string, args ...interface{}) { func UsefulLog(ctx context.Context, message string, args ...interface{}) {
logMessage := fmt.Sprintf(Log(ctx, message), args...) logMessage := fmt.Sprintf(Log(ctx, message), args...)
// If logging is disabled, don't evaluate the arguments // If logging is disabled, don't evaluate the arguments
@ -339,7 +339,7 @@ func UsefulLog(ctx context.Context, message string, args ...interface{}) {
} }
} }
// ExtendedLogMsg helps in logging a message with klog.level 3 // ExtendedLogMsg helps in logging a message with klog.level 3.
func ExtendedLogMsg(message string, args ...interface{}) { func ExtendedLogMsg(message string, args ...interface{}) {
logMessage := fmt.Sprintf(message, args...) logMessage := fmt.Sprintf(message, args...)
// If logging is disabled, don't evaluate the arguments // If logging is disabled, don't evaluate the arguments
@ -348,7 +348,7 @@ func ExtendedLogMsg(message string, args ...interface{}) {
} }
} }
// ExtendedLog helps in logging with klog.level 3 // ExtendedLog helps in logging with klog.level 3.
func ExtendedLog(ctx context.Context, message string, args ...interface{}) { func ExtendedLog(ctx context.Context, message string, args ...interface{}) {
logMessage := fmt.Sprintf(Log(ctx, message), args...) logMessage := fmt.Sprintf(Log(ctx, message), args...)
// If logging is disabled, don't evaluate the arguments // If logging is disabled, don't evaluate the arguments
@ -357,7 +357,7 @@ func ExtendedLog(ctx context.Context, message string, args ...interface{}) {
} }
} }
// DebugLogMsg helps in logging a message with klog.level 4 // DebugLogMsg helps in logging a message with klog.level 4.
func DebugLogMsg(message string, args ...interface{}) { func DebugLogMsg(message string, args ...interface{}) {
logMessage := fmt.Sprintf(message, args...) logMessage := fmt.Sprintf(message, args...)
// If logging is disabled, don't evaluate the arguments // If logging is disabled, don't evaluate the arguments
@ -366,7 +366,7 @@ func DebugLogMsg(message string, args ...interface{}) {
} }
} }
// DebugLog helps in logging with klog.level 4 // DebugLog helps in logging with klog.level 4.
func DebugLog(ctx context.Context, message string, args ...interface{}) { func DebugLog(ctx context.Context, message string, args ...interface{}) {
logMessage := fmt.Sprintf(Log(ctx, message), args...) logMessage := fmt.Sprintf(Log(ctx, message), args...)
// If logging is disabled, don't evaluate the arguments // If logging is disabled, don't evaluate the arguments
@ -375,7 +375,7 @@ func DebugLog(ctx context.Context, message string, args ...interface{}) {
} }
} }
// TraceLogMsg helps in logging a message with klog.level 5 // TraceLogMsg helps in logging a message with klog.level 5.
func TraceLogMsg(message string, args ...interface{}) { func TraceLogMsg(message string, args ...interface{}) {
logMessage := fmt.Sprintf(message, args...) logMessage := fmt.Sprintf(message, args...)
// If logging is disabled, don't evaluate the arguments // If logging is disabled, don't evaluate the arguments
@ -384,7 +384,7 @@ func TraceLogMsg(message string, args ...interface{}) {
} }
} }
// TraceLog helps in logging with klog.level 5 // TraceLog helps in logging with klog.level 5.
func TraceLog(ctx context.Context, message string, args ...interface{}) { func TraceLog(ctx context.Context, message string, args ...interface{}) {
logMessage := fmt.Sprintf(Log(ctx, message), args...) logMessage := fmt.Sprintf(Log(ctx, message), args...)
// If logging is disabled, don't evaluate the arguments // If logging is disabled, don't evaluate the arguments

View File

@ -6,7 +6,7 @@ import (
"google.golang.org/grpc/status" "google.golang.org/grpc/status"
) )
// ValidateNodeStageVolumeRequest validates the node stage request // ValidateNodeStageVolumeRequest validates the node stage request.
func ValidateNodeStageVolumeRequest(req *csi.NodeStageVolumeRequest) error { func ValidateNodeStageVolumeRequest(req *csi.NodeStageVolumeRequest) error {
if req.GetVolumeCapability() == nil { if req.GetVolumeCapability() == nil {
return status.Error(codes.InvalidArgument, "volume capability missing in request") return status.Error(codes.InvalidArgument, "volume capability missing in request")
@ -32,7 +32,7 @@ func ValidateNodeStageVolumeRequest(req *csi.NodeStageVolumeRequest) error {
return nil return nil
} }
// ValidateNodeUnstageVolumeRequest validates the node unstage request // ValidateNodeUnstageVolumeRequest validates the node unstage request.
func ValidateNodeUnstageVolumeRequest(req *csi.NodeUnstageVolumeRequest) error { func ValidateNodeUnstageVolumeRequest(req *csi.NodeUnstageVolumeRequest) error {
if req.GetVolumeId() == "" { if req.GetVolumeId() == "" {
return status.Error(codes.InvalidArgument, "volume ID missing in request") return status.Error(codes.InvalidArgument, "volume ID missing in request")
@ -45,7 +45,7 @@ func ValidateNodeUnstageVolumeRequest(req *csi.NodeUnstageVolumeRequest) error {
return nil return nil
} }
// ValidateNodePublishVolumeRequest validates the node publish request // ValidateNodePublishVolumeRequest validates the node publish request.
func ValidateNodePublishVolumeRequest(req *csi.NodePublishVolumeRequest) error { func ValidateNodePublishVolumeRequest(req *csi.NodePublishVolumeRequest) error {
if req.GetVolumeCapability() == nil { if req.GetVolumeCapability() == nil {
return status.Error(codes.InvalidArgument, "volume capability missing in request") return status.Error(codes.InvalidArgument, "volume capability missing in request")
@ -66,7 +66,7 @@ func ValidateNodePublishVolumeRequest(req *csi.NodePublishVolumeRequest) error {
return nil return nil
} }
// ValidateNodeUnpublishVolumeRequest validates the node unpublish request // ValidateNodeUnpublishVolumeRequest validates the node unpublish request.
func ValidateNodeUnpublishVolumeRequest(req *csi.NodeUnpublishVolumeRequest) error { func ValidateNodeUnpublishVolumeRequest(req *csi.NodeUnpublishVolumeRequest) error {
if req.GetVolumeId() == "" { if req.GetVolumeId() == "" {
return status.Error(codes.InvalidArgument, "volume ID missing in request") return status.Error(codes.InvalidArgument, "volume ID missing in request")

View File

@ -62,7 +62,7 @@ Example JSON structure in the KMS config is,
"vaultCAFromSecret": "vault-ca" "vaultCAFromSecret": "vault-ca"
}, },
... ...
} }.
*/ */
type VaultKMS struct { type VaultKMS struct {
EncryptionKMSID string EncryptionKMSID string
@ -76,7 +76,7 @@ type VaultKMS struct {
vaultCA *x509.CertPool vaultCA *x509.CertPool
} }
// InitVaultKMS returns an interface to HashiCorp Vault KMS // InitVaultKMS returns an interface to HashiCorp Vault KMS.
func InitVaultKMS(kmsID string, config, secrets map[string]string) (EncryptionKMS, error) { func InitVaultKMS(kmsID string, config, secrets map[string]string) (EncryptionKMS, error) {
var ( var (
ok bool ok bool
@ -136,12 +136,12 @@ func InitVaultKMS(kmsID string, config, secrets map[string]string) (EncryptionKM
return kms, nil return kms, nil
} }
// GetID is returning correlation ID to KMS configuration // GetID is returning correlation ID to KMS configuration.
func (kms *VaultKMS) GetID() string { func (kms *VaultKMS) GetID() string {
return kms.EncryptionKMSID return kms.EncryptionKMSID
} }
// GetPassphrase returns passphrase from Vault // GetPassphrase returns passphrase from Vault.
func (kms *VaultKMS) GetPassphrase(key string) (string, error) { func (kms *VaultKMS) GetPassphrase(key string) (string, error) {
var passphrase string var passphrase string
resp, err := kms.request("GET", kms.getKeyDataURI(key), nil) resp, err := kms.request("GET", kms.getKeyDataURI(key), nil)
@ -182,7 +182,7 @@ func (kms *VaultKMS) GetPassphrase(key string) (string, error) {
return passphrase, nil return passphrase, nil
} }
// SavePassphrase saves new passphrase in Vault // SavePassphrase saves new passphrase in Vault.
func (kms *VaultKMS) SavePassphrase(key, value string) error { func (kms *VaultKMS) SavePassphrase(key, value string) error {
data, err := json.Marshal(map[string]map[string]string{ data, err := json.Marshal(map[string]map[string]string{
"data": { "data": {
@ -206,7 +206,7 @@ func (kms *VaultKMS) SavePassphrase(key, value string) error {
return nil return nil
} }
// DeletePassphrase deletes passphrase from Vault // DeletePassphrase deletes passphrase from Vault.
func (kms *VaultKMS) DeletePassphrase(key string) error { func (kms *VaultKMS) DeletePassphrase(key string) error {
vaultToken, err := kms.getAccessToken() vaultToken, err := kms.getAccessToken()
if err != nil { if err != nil {
@ -241,7 +241,7 @@ getVaultAccessToken retrieves vault token using kubernetes authentication:
1. read jwt service account token from well known location 1. read jwt service account token from well known location
2. request token from vault using service account jwt token 2. request token from vault using service account jwt token
Vault will verify service account jwt token with Kubernetes and return token Vault will verify service account jwt token with Kubernetes and return token
if the requester is allowed if the requester is allowed.
*/ */
func (kms *VaultKMS) getAccessToken() (string, error) { func (kms *VaultKMS) getAccessToken() (string, error) {
saToken, err := ioutil.ReadFile(serviceAccountTokenPath) saToken, err := ioutil.ReadFile(serviceAccountTokenPath)

View File

@ -49,7 +49,7 @@ type CSIIdentifier struct {
ObjectUUID string ObjectUUID string
} }
// This maximum comes from the CSI spec on max bytes allowed in the various CSI ID fields // This maximum comes from the CSI spec on max bytes allowed in the various CSI ID fields.
const maxVolIDLen = 128 const maxVolIDLen = 128
const ( const (
@ -95,7 +95,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) (err error) {
bytesToProcess := uint16(len(composedCSIID)) bytesToProcess := uint16(len(composedCSIID))

View File

@ -29,7 +29,7 @@ type testTuple struct {
wantDecError bool wantDecError bool
} }
// TODO: Add more test tuples to test out other edge conditions // TODO: Add more test tuples to test out other edge conditions.
var testData = []testTuple{ var testData = []testTuple{
{ {
vID: CSIIdentifier{ vID: CSIIdentifier{