mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-13 02:33:34 +00:00
ci: fix all linter errors found in golangci-lint
Fixing all the linter errors found in golang-ci lint v1.46.2 Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
committed by
mergify[bot]
parent
9e5cad173d
commit
1952a9b4b3
@ -98,7 +98,8 @@ func (cs *ControllerServer) validateVolumeReq(ctx context.Context, req *csi.Crea
|
||||
// request arguments for subsequent calls.
|
||||
func (cs *ControllerServer) parseVolCreateRequest(
|
||||
ctx context.Context,
|
||||
req *csi.CreateVolumeRequest) (*rbdVolume, error) {
|
||||
req *csi.CreateVolumeRequest,
|
||||
) (*rbdVolume, error) {
|
||||
// TODO (sbezverk) Last check for not exceeding total storage capacity
|
||||
|
||||
// below capability check indicates that we support both {SINGLE_NODE or MULTI_NODE} WRITERs and the `isMultiWriter`
|
||||
@ -195,12 +196,11 @@ func buildCreateVolumeResponse(req *csi.CreateVolumeRequest, rbdVol *rbdVolume)
|
||||
ContentSource: req.GetVolumeContentSource(),
|
||||
}
|
||||
if rbdVol.Topology != nil {
|
||||
volume.AccessibleTopology =
|
||||
[]*csi.Topology{
|
||||
{
|
||||
Segments: rbdVol.Topology,
|
||||
},
|
||||
}
|
||||
volume.AccessibleTopology = []*csi.Topology{
|
||||
{
|
||||
Segments: rbdVol.Topology,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
return &csi.CreateVolumeResponse{Volume: volume}
|
||||
@ -252,7 +252,8 @@ func checkValidCreateVolumeRequest(rbdVol, parentVol *rbdVolume, rbdSnap *rbdSna
|
||||
// CreateVolume creates the volume in backend.
|
||||
func (cs *ControllerServer) CreateVolume(
|
||||
ctx context.Context,
|
||||
req *csi.CreateVolumeRequest) (*csi.CreateVolumeResponse, error) {
|
||||
req *csi.CreateVolumeRequest,
|
||||
) (*csi.CreateVolumeResponse, error) {
|
||||
err := cs.validateVolumeReq(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -349,7 +350,8 @@ func flattenParentImage(
|
||||
ctx context.Context,
|
||||
rbdVol *rbdVolume,
|
||||
rbdSnap *rbdSnapshot,
|
||||
cr *util.Credentials) error {
|
||||
cr *util.Credentials,
|
||||
) error {
|
||||
// flatten the image's parent before the reservation to avoid
|
||||
// stale entries in post creation if we return ABORT error and the
|
||||
// DeleteVolume RPC is not called.
|
||||
@ -417,7 +419,8 @@ func flattenParentImage(
|
||||
// that the state is corrected to what was requested. It is needed to call this
|
||||
// when the process of creating a volume was interrupted.
|
||||
func (cs *ControllerServer) repairExistingVolume(ctx context.Context, req *csi.CreateVolumeRequest,
|
||||
cr *util.Credentials, rbdVol *rbdVolume, rbdSnap *rbdSnapshot) (*csi.CreateVolumeResponse, error) {
|
||||
cr *util.Credentials, rbdVol *rbdVolume, rbdSnap *rbdSnapshot,
|
||||
) (*csi.CreateVolumeResponse, error) {
|
||||
vcs := req.GetVolumeContentSource()
|
||||
|
||||
switch {
|
||||
@ -558,7 +561,8 @@ func (cs *ControllerServer) createVolumeFromSnapshot(
|
||||
cr *util.Credentials,
|
||||
secrets map[string]string,
|
||||
rbdVol *rbdVolume,
|
||||
snapshotID string) error {
|
||||
snapshotID string,
|
||||
) error {
|
||||
rbdSnap := &rbdSnapshot{}
|
||||
if acquired := cs.SnapshotLocks.TryAcquire(snapshotID); !acquired {
|
||||
log.ErrorLog(ctx, util.SnapshotOperationAlreadyExistsFmt, snapshotID)
|
||||
@ -622,7 +626,8 @@ func (cs *ControllerServer) createBackingImage(
|
||||
cr *util.Credentials,
|
||||
secrets map[string]string,
|
||||
rbdVol, parentVol *rbdVolume,
|
||||
rbdSnap *rbdSnapshot) error {
|
||||
rbdSnap *rbdSnapshot,
|
||||
) error {
|
||||
var err error
|
||||
|
||||
j, err := volJournal.Connect(rbdVol.Monitors, rbdVol.RadosNamespace, cr)
|
||||
@ -682,7 +687,8 @@ func (cs *ControllerServer) createBackingImage(
|
||||
func checkContentSource(
|
||||
ctx context.Context,
|
||||
req *csi.CreateVolumeRequest,
|
||||
cr *util.Credentials) (*rbdVolume, *rbdSnapshot, error) {
|
||||
cr *util.Credentials,
|
||||
) (*rbdVolume, *rbdSnapshot, error) {
|
||||
if req.VolumeContentSource == nil {
|
||||
return nil, nil, nil
|
||||
}
|
||||
@ -743,7 +749,8 @@ func (cs *ControllerServer) checkErrAndUndoReserve(
|
||||
ctx context.Context,
|
||||
err error,
|
||||
volumeID string,
|
||||
rbdVol *rbdVolume, cr *util.Credentials) (*csi.DeleteVolumeResponse, error) {
|
||||
rbdVol *rbdVolume, cr *util.Credentials,
|
||||
) (*csi.DeleteVolumeResponse, error) {
|
||||
if errors.Is(err, util.ErrPoolNotFound) {
|
||||
log.WarningLog(ctx, "failed to get backend volume for %s: %v", volumeID, err)
|
||||
|
||||
@ -790,7 +797,8 @@ func (cs *ControllerServer) checkErrAndUndoReserve(
|
||||
// from store.
|
||||
func (cs *ControllerServer) DeleteVolume(
|
||||
ctx context.Context,
|
||||
req *csi.DeleteVolumeRequest) (*csi.DeleteVolumeResponse, error) {
|
||||
req *csi.DeleteVolumeRequest,
|
||||
) (*csi.DeleteVolumeResponse, error) {
|
||||
var err error
|
||||
if err = cs.Driver.ValidateControllerServiceRequest(
|
||||
csi.ControllerServiceCapability_RPC_CREATE_DELETE_VOLUME); err != nil {
|
||||
@ -860,7 +868,8 @@ func (cs *ControllerServer) DeleteVolume(
|
||||
|
||||
// cleanupRBDImage removes the rbd image and OMAP metadata associated with it.
|
||||
func cleanupRBDImage(ctx context.Context,
|
||||
rbdVol *rbdVolume, cr *util.Credentials) (*csi.DeleteVolumeResponse, error) {
|
||||
rbdVol *rbdVolume, cr *util.Credentials,
|
||||
) (*csi.DeleteVolumeResponse, error) {
|
||||
mirroringInfo, err := rbdVol.getImageMirroringInfo()
|
||||
if err != nil {
|
||||
log.ErrorLog(ctx, err.Error())
|
||||
@ -954,7 +963,8 @@ func cleanupRBDImage(ctx context.Context,
|
||||
// are supported.
|
||||
func (cs *ControllerServer) ValidateVolumeCapabilities(
|
||||
ctx context.Context,
|
||||
req *csi.ValidateVolumeCapabilitiesRequest) (*csi.ValidateVolumeCapabilitiesResponse, error) {
|
||||
req *csi.ValidateVolumeCapabilitiesRequest,
|
||||
) (*csi.ValidateVolumeCapabilitiesResponse, error) {
|
||||
if req.GetVolumeId() == "" {
|
||||
return nil, status.Error(codes.InvalidArgument, "empty volume ID in request")
|
||||
}
|
||||
@ -980,7 +990,8 @@ func (cs *ControllerServer) ValidateVolumeCapabilities(
|
||||
// nolint:gocyclo,cyclop // TODO: reduce complexity.
|
||||
func (cs *ControllerServer) CreateSnapshot(
|
||||
ctx context.Context,
|
||||
req *csi.CreateSnapshotRequest) (*csi.CreateSnapshotResponse, error) {
|
||||
req *csi.CreateSnapshotRequest,
|
||||
) (*csi.CreateSnapshotResponse, error) {
|
||||
if err := cs.validateSnapshotReq(ctx, req); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -1110,7 +1121,8 @@ func cloneFromSnapshot(
|
||||
rbdVol *rbdVolume,
|
||||
rbdSnap *rbdSnapshot,
|
||||
cr *util.Credentials,
|
||||
parameters map[string]string) (*csi.CreateSnapshotResponse, error) {
|
||||
parameters map[string]string,
|
||||
) (*csi.CreateSnapshotResponse, error) {
|
||||
vol := generateVolFromSnap(rbdSnap)
|
||||
err := vol.Connect(cr)
|
||||
if err != nil {
|
||||
@ -1193,7 +1205,8 @@ func (cs *ControllerServer) doSnapshotClone(
|
||||
ctx context.Context,
|
||||
parentVol *rbdVolume,
|
||||
rbdSnap *rbdSnapshot,
|
||||
cr *util.Credentials) (*rbdVolume, error) {
|
||||
cr *util.Credentials,
|
||||
) (*rbdVolume, error) {
|
||||
// generate cloned volume details from snapshot
|
||||
cloneRbd := generateVolFromSnap(rbdSnap)
|
||||
defer cloneRbd.Destroy()
|
||||
@ -1276,7 +1289,8 @@ func (cs *ControllerServer) doSnapshotClone(
|
||||
// snapshot metadata from store.
|
||||
func (cs *ControllerServer) DeleteSnapshot(
|
||||
ctx context.Context,
|
||||
req *csi.DeleteSnapshotRequest) (*csi.DeleteSnapshotResponse, error) {
|
||||
req *csi.DeleteSnapshotRequest,
|
||||
) (*csi.DeleteSnapshotResponse, error) {
|
||||
if err := cs.Driver.ValidateControllerServiceRequest(
|
||||
csi.ControllerServiceCapability_RPC_CREATE_DELETE_SNAPSHOT); err != nil {
|
||||
log.ErrorLog(ctx, "invalid delete snapshot req: %v", protosanitizer.StripSecrets(req))
|
||||
@ -1417,7 +1431,8 @@ func cleanUpImageAndSnapReservation(ctx context.Context, rbdSnap *rbdSnapshot, c
|
||||
// ControllerExpandVolume expand RBD Volumes on demand based on resizer request.
|
||||
func (cs *ControllerServer) ControllerExpandVolume(
|
||||
ctx context.Context,
|
||||
req *csi.ControllerExpandVolumeRequest) (*csi.ControllerExpandVolumeResponse, error) {
|
||||
req *csi.ControllerExpandVolumeRequest,
|
||||
) (*csi.ControllerExpandVolumeResponse, error) {
|
||||
err := cs.Driver.ValidateControllerServiceRequest(csi.ControllerServiceCapability_RPC_EXPAND_VOLUME)
|
||||
if err != nil {
|
||||
log.ErrorLog(ctx, "invalid expand volume req: %v", protosanitizer.StripSecrets(req))
|
||||
|
@ -273,7 +273,8 @@ func (ri *rbdImage) initKMS(ctx context.Context, volOptions, credentials map[str
|
||||
// ParseEncryptionOpts returns kmsID and sets Owner attribute.
|
||||
func (ri *rbdImage) ParseEncryptionOpts(
|
||||
ctx context.Context,
|
||||
volOptions map[string]string) (string, error) {
|
||||
volOptions map[string]string,
|
||||
) (string, error) {
|
||||
var (
|
||||
err error
|
||||
ok bool
|
||||
|
@ -33,7 +33,8 @@ type IdentityServer struct {
|
||||
// GetPluginCapabilities returns available capabilities of the rbd driver.
|
||||
func (is *IdentityServer) GetPluginCapabilities(
|
||||
ctx context.Context,
|
||||
req *csi.GetPluginCapabilitiesRequest) (*csi.GetPluginCapabilitiesResponse, error) {
|
||||
req *csi.GetPluginCapabilitiesRequest,
|
||||
) (*csi.GetPluginCapabilitiesResponse, error) {
|
||||
return &csi.GetPluginCapabilitiesResponse{
|
||||
Capabilities: []*csi.PluginCapability{
|
||||
{
|
||||
|
@ -148,7 +148,8 @@ func healerStageTransaction(ctx context.Context, cr *util.Credentials, volOps *r
|
||||
func populateRbdVol(
|
||||
ctx context.Context,
|
||||
req *csi.NodeStageVolumeRequest,
|
||||
cr *util.Credentials) (*rbdVolume, error) {
|
||||
cr *util.Credentials,
|
||||
) (*rbdVolume, error) {
|
||||
var err error
|
||||
var j *journal.Connection
|
||||
volID := req.GetVolumeId()
|
||||
@ -295,7 +296,8 @@ func populateRbdVol(
|
||||
// - Stage the device (mount the device mapped for image)
|
||||
func (ns *NodeServer) NodeStageVolume(
|
||||
ctx context.Context,
|
||||
req *csi.NodeStageVolumeRequest) (*csi.NodeStageVolumeResponse, error) {
|
||||
req *csi.NodeStageVolumeRequest,
|
||||
) (*csi.NodeStageVolumeResponse, error) {
|
||||
var err error
|
||||
if err = util.ValidateNodeStageVolumeRequest(req); err != nil {
|
||||
return nil, err
|
||||
@ -384,7 +386,8 @@ func (ns *NodeServer) stageTransaction(
|
||||
req *csi.NodeStageVolumeRequest,
|
||||
cr *util.Credentials,
|
||||
volOptions *rbdVolume,
|
||||
staticVol bool) (*stageTransaction, error) {
|
||||
staticVol bool,
|
||||
) (*stageTransaction, error) {
|
||||
transaction := &stageTransaction{}
|
||||
|
||||
var err error
|
||||
@ -466,7 +469,8 @@ func resizeNodeStagePath(ctx context.Context,
|
||||
isBlock bool,
|
||||
transaction *stageTransaction,
|
||||
volID,
|
||||
stagingTargetPath string) error {
|
||||
stagingTargetPath string,
|
||||
) error {
|
||||
var err error
|
||||
devicePath := transaction.devicePath
|
||||
var ok bool
|
||||
@ -543,7 +547,8 @@ func resizeEncryptedDevice(ctx context.Context, volID, stagingTargetPath, device
|
||||
|
||||
func flattenImageBeforeMapping(
|
||||
ctx context.Context,
|
||||
volOptions *rbdVolume) error {
|
||||
volOptions *rbdVolume,
|
||||
) error {
|
||||
var err error
|
||||
var feature bool
|
||||
var depth uint
|
||||
@ -579,7 +584,8 @@ func (ns *NodeServer) undoStagingTransaction(
|
||||
ctx context.Context,
|
||||
req *csi.NodeStageVolumeRequest,
|
||||
transaction *stageTransaction,
|
||||
volOptions *rbdVolume) {
|
||||
volOptions *rbdVolume,
|
||||
) {
|
||||
var err error
|
||||
|
||||
stagingTargetPath := getStagingTargetPath(req)
|
||||
@ -661,7 +667,8 @@ func (ns *NodeServer) createStageMountPoint(ctx context.Context, mountPath strin
|
||||
// path.
|
||||
func (ns *NodeServer) NodePublishVolume(
|
||||
ctx context.Context,
|
||||
req *csi.NodePublishVolumeRequest) (*csi.NodePublishVolumeResponse, error) {
|
||||
req *csi.NodePublishVolumeRequest,
|
||||
) (*csi.NodePublishVolumeResponse, error) {
|
||||
err := util.ValidateNodePublishVolumeRequest(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -700,7 +707,8 @@ func (ns *NodeServer) mountVolumeToStagePath(
|
||||
ctx context.Context,
|
||||
req *csi.NodeStageVolumeRequest,
|
||||
staticVol bool,
|
||||
stagingPath, devicePath string) error {
|
||||
stagingPath, devicePath string,
|
||||
) error {
|
||||
readOnly := false
|
||||
fsType := req.GetVolumeCapability().GetMount().GetFsType()
|
||||
diskMounter := &mount.SafeFormatAndMount{Interface: ns.Mounter, Exec: utilexec.New()}
|
||||
@ -841,7 +849,8 @@ func (ns *NodeServer) createTargetMountPath(ctx context.Context, mountPath strin
|
||||
// NodeUnpublishVolume unmounts the volume from the target path.
|
||||
func (ns *NodeServer) NodeUnpublishVolume(
|
||||
ctx context.Context,
|
||||
req *csi.NodeUnpublishVolumeRequest) (*csi.NodeUnpublishVolumeResponse, error) {
|
||||
req *csi.NodeUnpublishVolumeRequest,
|
||||
) (*csi.NodeUnpublishVolumeResponse, error) {
|
||||
err := util.ValidateNodeUnpublishVolumeRequest(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -898,7 +907,8 @@ func getStagingTargetPath(req interface{}) string {
|
||||
// NodeUnstageVolume unstages the volume from the staging path.
|
||||
func (ns *NodeServer) NodeUnstageVolume(
|
||||
ctx context.Context,
|
||||
req *csi.NodeUnstageVolumeRequest) (*csi.NodeUnstageVolumeResponse, error) {
|
||||
req *csi.NodeUnstageVolumeRequest,
|
||||
) (*csi.NodeUnstageVolumeResponse, error) {
|
||||
var err error
|
||||
if err = util.ValidateNodeUnstageVolumeRequest(req); err != nil {
|
||||
return nil, err
|
||||
@ -1004,7 +1014,8 @@ func (ns *NodeServer) NodeUnstageVolume(
|
||||
// NodeExpandVolume resizes rbd volumes.
|
||||
func (ns *NodeServer) NodeExpandVolume(
|
||||
ctx context.Context,
|
||||
req *csi.NodeExpandVolumeRequest) (*csi.NodeExpandVolumeResponse, error) {
|
||||
req *csi.NodeExpandVolumeRequest,
|
||||
) (*csi.NodeExpandVolumeResponse, error) {
|
||||
volumeID := req.GetVolumeId()
|
||||
if volumeID == "" {
|
||||
return nil, status.Error(codes.InvalidArgument, "volume ID must be provided")
|
||||
@ -1078,7 +1089,8 @@ func (ns *NodeServer) NodeExpandVolume(
|
||||
// NodeGetCapabilities returns the supported capabilities of the node server.
|
||||
func (ns *NodeServer) NodeGetCapabilities(
|
||||
ctx context.Context,
|
||||
req *csi.NodeGetCapabilitiesRequest) (*csi.NodeGetCapabilitiesResponse, error) {
|
||||
req *csi.NodeGetCapabilitiesRequest,
|
||||
) (*csi.NodeGetCapabilitiesResponse, error) {
|
||||
return &csi.NodeGetCapabilitiesResponse{
|
||||
Capabilities: []*csi.NodeServiceCapability{
|
||||
{
|
||||
@ -1116,7 +1128,8 @@ func (ns *NodeServer) NodeGetCapabilities(
|
||||
func (ns *NodeServer) processEncryptedDevice(
|
||||
ctx context.Context,
|
||||
volOptions *rbdVolume,
|
||||
devicePath string) (string, error) {
|
||||
devicePath string,
|
||||
) (string, error) {
|
||||
imageSpec := volOptions.String()
|
||||
encrypted, err := volOptions.checkRbdImageEncrypted(ctx)
|
||||
if err != nil {
|
||||
@ -1212,7 +1225,8 @@ func (ns *NodeServer) xfsSupportsReflink() bool {
|
||||
// NodeGetVolumeStats returns volume stats.
|
||||
func (ns *NodeServer) NodeGetVolumeStats(
|
||||
ctx context.Context,
|
||||
req *csi.NodeGetVolumeStatsRequest) (*csi.NodeGetVolumeStatsResponse, error) {
|
||||
req *csi.NodeGetVolumeStatsRequest,
|
||||
) (*csi.NodeGetVolumeStatsResponse, error) {
|
||||
var err error
|
||||
targetPath := req.GetVolumePath()
|
||||
if targetPath == "" {
|
||||
|
@ -538,7 +538,8 @@ func detachRBDDevice(ctx context.Context, devicePath, volumeID, unmapOptions str
|
||||
// when imageSpec is used to decide if image is already unmapped.
|
||||
func detachRBDImageOrDeviceSpec(
|
||||
ctx context.Context,
|
||||
dArgs *detachRBDImageArgs) error {
|
||||
dArgs *detachRBDImageArgs,
|
||||
) error {
|
||||
if dArgs.encrypted {
|
||||
mapperFile, mapperPath := util.VolumeMapper(dArgs.volumeID)
|
||||
mappedDevice, mapper, err := util.DeviceEncryptionStatus(ctx, mapperPath)
|
||||
|
@ -116,7 +116,8 @@ func checkSnapCloneExists(
|
||||
ctx context.Context,
|
||||
parentVol *rbdVolume,
|
||||
rbdSnap *rbdSnapshot,
|
||||
cr *util.Credentials) (bool, error) {
|
||||
cr *util.Credentials,
|
||||
) (bool, error) {
|
||||
err := validateRbdSnap(rbdSnap)
|
||||
if err != nil {
|
||||
return false, err
|
||||
@ -541,7 +542,8 @@ func RegenerateJournal(
|
||||
volumeID,
|
||||
requestName,
|
||||
owner string,
|
||||
cr *util.Credentials) (string, error) {
|
||||
cr *util.Credentials,
|
||||
) (string, error) {
|
||||
ctx := context.Background()
|
||||
var (
|
||||
vi util.CSIIdentifier
|
||||
|
@ -722,7 +722,8 @@ func flattenClonedRbdImages(
|
||||
ctx context.Context,
|
||||
snaps []librbd.SnapInfo,
|
||||
pool, monitors, rbdImageName string,
|
||||
cr *util.Credentials) error {
|
||||
cr *util.Credentials,
|
||||
) error {
|
||||
rv := &rbdVolume{}
|
||||
rv.Monitors = monitors
|
||||
rv.Pool = pool
|
||||
@ -769,7 +770,8 @@ func flattenClonedRbdImages(
|
||||
func (ri *rbdImage) flattenRbdImage(
|
||||
ctx context.Context,
|
||||
forceFlatten bool,
|
||||
hardlimit, softlimit uint) error {
|
||||
hardlimit, softlimit uint,
|
||||
) error {
|
||||
var depth uint
|
||||
var err error
|
||||
|
||||
@ -926,7 +928,8 @@ func genSnapFromSnapID(
|
||||
rbdSnap *rbdSnapshot,
|
||||
snapshotID string,
|
||||
cr *util.Credentials,
|
||||
secrets map[string]string) error {
|
||||
secrets map[string]string,
|
||||
) error {
|
||||
var vi util.CSIIdentifier
|
||||
|
||||
rbdSnap.VolID = snapshotID
|
||||
@ -1036,7 +1039,8 @@ func generateVolumeFromVolumeID(
|
||||
volumeID string,
|
||||
vi util.CSIIdentifier,
|
||||
cr *util.Credentials,
|
||||
secrets map[string]string) (*rbdVolume, error) {
|
||||
secrets map[string]string,
|
||||
) (*rbdVolume, error) {
|
||||
var (
|
||||
rbdVol *rbdVolume
|
||||
err error
|
||||
@ -1123,7 +1127,8 @@ func GenVolFromVolID(
|
||||
ctx context.Context,
|
||||
volumeID string,
|
||||
cr *util.Credentials,
|
||||
secrets map[string]string) (*rbdVolume, error) {
|
||||
secrets map[string]string,
|
||||
) (*rbdVolume, error) {
|
||||
var (
|
||||
vi util.CSIIdentifier
|
||||
vol *rbdVolume
|
||||
@ -1165,7 +1170,8 @@ func generateVolumeFromMapping(
|
||||
volumeID string,
|
||||
vi util.CSIIdentifier,
|
||||
cr *util.Credentials,
|
||||
secrets map[string]string) (*rbdVolume, error) {
|
||||
secrets map[string]string,
|
||||
) (*rbdVolume, error) {
|
||||
nvi := vi
|
||||
vol := &rbdVolume{}
|
||||
// extract clusterID mapping
|
||||
@ -1215,7 +1221,8 @@ func generateVolumeFromMapping(
|
||||
func genVolFromVolumeOptions(
|
||||
ctx context.Context,
|
||||
volOptions map[string]string,
|
||||
disableInUseChecks, checkClusterIDMapping bool) (*rbdVolume, error) {
|
||||
disableInUseChecks, checkClusterIDMapping bool,
|
||||
) (*rbdVolume, error) {
|
||||
var (
|
||||
ok bool
|
||||
err error
|
||||
@ -1368,7 +1375,8 @@ func (ri *rbdImage) deleteSnapshot(ctx context.Context, pOpts *rbdSnapshot) erro
|
||||
func (rv *rbdVolume) cloneRbdImageFromSnapshot(
|
||||
ctx context.Context,
|
||||
pSnapOpts *rbdSnapshot,
|
||||
parentVol *rbdVolume) error {
|
||||
parentVol *rbdVolume,
|
||||
) error {
|
||||
var err error
|
||||
logMsg := "rbd: clone %s %s (features: %s) using mon %s"
|
||||
|
||||
@ -1904,7 +1912,8 @@ func (ri *rbdImage) isCompabitableClone(dst *rbdImage) error {
|
||||
|
||||
func (ri *rbdImage) addSnapshotScheduling(
|
||||
interval admin.Interval,
|
||||
startTime admin.StartTime) error {
|
||||
startTime admin.StartTime,
|
||||
) error {
|
||||
ls := admin.NewLevelSpec(ri.Pool, ri.RadosNamespace, ri.RbdImageName)
|
||||
ra, err := ri.conn.GetRBDAdmin()
|
||||
if err != nil {
|
||||
@ -1965,7 +1974,8 @@ func strategicActionOnLogFile(ctx context.Context, logStrategy, logFile string)
|
||||
|
||||
// genVolFromVolIDWithMigration populate a rbdVol structure based on the volID format.
|
||||
func genVolFromVolIDWithMigration(
|
||||
ctx context.Context, volID string, cr *util.Credentials, secrets map[string]string) (*rbdVolume, error) {
|
||||
ctx context.Context, volID string, cr *util.Credentials, secrets map[string]string,
|
||||
) (*rbdVolume, error) {
|
||||
if isMigrationVolID(volID) {
|
||||
pmVolID, pErr := parseMigrationVolID(volID)
|
||||
if pErr != nil {
|
||||
|
@ -457,7 +457,8 @@ func (rs *ReplicationServer) DisableVolumeReplication(ctx context.Context,
|
||||
|
||||
func disableVolumeReplication(rbdVol *rbdVolume,
|
||||
mirroringInfo *librbd.MirrorImageInfo,
|
||||
force bool) (*replication.DisableVolumeReplicationResponse, error) {
|
||||
force bool,
|
||||
) (*replication.DisableVolumeReplicationResponse, error) {
|
||||
if !mirroringInfo.Primary {
|
||||
// Return success if the below condition is met
|
||||
// Local image is secondary
|
||||
@ -913,9 +914,8 @@ func resyncRequired(localStatus librbd.SiteMirrorImageStatus) bool {
|
||||
// In some corner cases like `re-player shutdown` the local image will not
|
||||
// be in an error state. It would be also worth considering the `description`
|
||||
// field to make sure about split-brain.
|
||||
splitBrain := "split-brain"
|
||||
if localStatus.State == librbd.MirrorImageStatusStateError ||
|
||||
strings.Contains(localStatus.Description, splitBrain) {
|
||||
strings.Contains(localStatus.Description, "split-brain") {
|
||||
return true
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,8 @@ import (
|
||||
func createRBDClone(
|
||||
ctx context.Context,
|
||||
parentVol, cloneRbdVol *rbdVolume,
|
||||
snap *rbdSnapshot) error {
|
||||
snap *rbdSnapshot,
|
||||
) error {
|
||||
// create snapshot
|
||||
err := parentVol.createSnapshot(ctx, snap)
|
||||
if err != nil {
|
||||
@ -72,7 +73,8 @@ func cleanUpSnapshot(
|
||||
ctx context.Context,
|
||||
parentVol *rbdVolume,
|
||||
rbdSnap *rbdSnapshot,
|
||||
rbdVol *rbdVolume) error {
|
||||
rbdVol *rbdVolume,
|
||||
) error {
|
||||
err := parentVol.deleteSnapshot(ctx, rbdSnap)
|
||||
if err != nil {
|
||||
if !errors.Is(err, ErrSnapNotFound) {
|
||||
@ -119,7 +121,8 @@ func undoSnapshotCloning(
|
||||
parentVol *rbdVolume,
|
||||
rbdSnap *rbdSnapshot,
|
||||
cloneVol *rbdVolume,
|
||||
cr *util.Credentials) error {
|
||||
cr *util.Credentials,
|
||||
) error {
|
||||
err := cleanUpSnapshot(ctx, parentVol, rbdSnap, cloneVol)
|
||||
if err != nil {
|
||||
log.ErrorLog(ctx, "failed to clean up %s or %s: %v", cloneVol, rbdSnap, err)
|
||||
|
Reference in New Issue
Block a user