mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-12-18 02:50:30 +00:00
rbd: parse migration secret and set fields for nodestage operations
this commit make use of the migration request secret parsing and set the required fields for further nodestage operations Signed-off-by: Humble Chirammal <hchiramm@redhat.com>
This commit is contained in:
parent
5621f2cfca
commit
6aec858cba
@ -151,10 +151,14 @@ func healerStageTransaction(ctx context.Context, cr *util.Credentials, volOps *r
|
|||||||
}
|
}
|
||||||
|
|
||||||
// populateRbdVol update the fields in rbdVolume struct based on the request it received.
|
// populateRbdVol update the fields in rbdVolume struct based on the request it received.
|
||||||
|
// this function also receive the credentials and secrets args as it differs in its data.
|
||||||
|
// The credentials are used directly by functions like voljournal.Connect() and other functions
|
||||||
|
// like genVolFromVolumeOptions() make use of secrets.
|
||||||
func populateRbdVol(
|
func populateRbdVol(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
req *csi.NodeStageVolumeRequest,
|
req *csi.NodeStageVolumeRequest,
|
||||||
cr *util.Credentials) (*rbdVolume, error) {
|
cr *util.Credentials,
|
||||||
|
secrets map[string]string) (*rbdVolume, error) {
|
||||||
var err error
|
var err error
|
||||||
var j *journal.Connection
|
var j *journal.Connection
|
||||||
volID := req.GetVolumeId()
|
volID := req.GetVolumeId()
|
||||||
@ -179,7 +183,7 @@ func populateRbdVol(
|
|||||||
disableInUseChecks = true
|
disableInUseChecks = true
|
||||||
}
|
}
|
||||||
|
|
||||||
rv, err := genVolFromVolumeOptions(ctx, req.GetVolumeContext(), req.GetSecrets(), disableInUseChecks, true)
|
rv, err := genVolFromVolumeOptions(ctx, req.GetVolumeContext(), secrets, disableInUseChecks, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, status.Error(codes.Internal, err.Error())
|
return nil, status.Error(codes.Internal, err.Error())
|
||||||
}
|
}
|
||||||
@ -254,13 +258,20 @@ func populateRbdVol(
|
|||||||
func (ns *NodeServer) NodeStageVolume(
|
func (ns *NodeServer) NodeStageVolume(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
req *csi.NodeStageVolumeRequest) (*csi.NodeStageVolumeResponse, error) {
|
req *csi.NodeStageVolumeRequest) (*csi.NodeStageVolumeResponse, error) {
|
||||||
if err := util.ValidateNodeStageVolumeRequest(req); err != nil {
|
var err error
|
||||||
|
if err = util.ValidateNodeStageVolumeRequest(req); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
volID := req.GetVolumeId()
|
volID := req.GetVolumeId()
|
||||||
|
secrets := req.GetSecrets()
|
||||||
cr, err := util.NewUserCredentials(req.GetSecrets())
|
if util.IsMigrationSecret(secrets) {
|
||||||
|
secrets, err = util.ParseAndSetSecretMapFromMigSecret(secrets)
|
||||||
|
if err != nil {
|
||||||
|
return nil, status.Error(codes.InvalidArgument, err.Error())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cr, err := util.NewUserCredentials(secrets)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, status.Error(codes.Internal, err.Error())
|
return nil, status.Error(codes.Internal, err.Error())
|
||||||
}
|
}
|
||||||
@ -298,7 +309,7 @@ func (ns *NodeServer) NodeStageVolume(
|
|||||||
return nil, status.Error(codes.InvalidArgument, "missing required parameter imageFeatures")
|
return nil, status.Error(codes.InvalidArgument, "missing required parameter imageFeatures")
|
||||||
}
|
}
|
||||||
|
|
||||||
rv, err := populateRbdVol(ctx, req, cr)
|
rv, err := populateRbdVol(ctx, req, cr, secrets)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -335,7 +346,7 @@ func (ns *NodeServer) NodeStageVolume(
|
|||||||
|
|
||||||
// perform the actual staging and if this fails, have undoStagingTransaction
|
// perform the actual staging and if this fails, have undoStagingTransaction
|
||||||
// cleans up for us
|
// cleans up for us
|
||||||
transaction, err = ns.stageTransaction(ctx, req, rv, isStaticVol)
|
transaction, err = ns.stageTransaction(ctx, req, cr, rv, isStaticVol)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, status.Error(codes.Internal, err.Error())
|
return nil, status.Error(codes.Internal, err.Error())
|
||||||
}
|
}
|
||||||
@ -352,6 +363,7 @@ func (ns *NodeServer) NodeStageVolume(
|
|||||||
func (ns *NodeServer) stageTransaction(
|
func (ns *NodeServer) stageTransaction(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
req *csi.NodeStageVolumeRequest,
|
req *csi.NodeStageVolumeRequest,
|
||||||
|
cr *util.Credentials,
|
||||||
volOptions *rbdVolume,
|
volOptions *rbdVolume,
|
||||||
staticVol bool) (stageTransaction, error) {
|
staticVol bool) (stageTransaction, error) {
|
||||||
transaction := stageTransaction{}
|
transaction := stageTransaction{}
|
||||||
@ -359,13 +371,6 @@ func (ns *NodeServer) stageTransaction(
|
|||||||
var err error
|
var err error
|
||||||
var readOnly bool
|
var readOnly bool
|
||||||
|
|
||||||
var cr *util.Credentials
|
|
||||||
cr, err = util.NewUserCredentials(req.GetSecrets())
|
|
||||||
if err != nil {
|
|
||||||
return transaction, err
|
|
||||||
}
|
|
||||||
defer cr.DeleteCredentials()
|
|
||||||
|
|
||||||
// Allow image to be mounted on multiple nodes if it is ROX
|
// Allow image to be mounted on multiple nodes if it is ROX
|
||||||
if req.VolumeCapability.AccessMode.Mode == csi.VolumeCapability_AccessMode_MULTI_NODE_READER_ONLY {
|
if req.VolumeCapability.AccessMode.Mode == csi.VolumeCapability_AccessMode_MULTI_NODE_READER_ONLY {
|
||||||
log.ExtendedLog(ctx, "setting disableInUseChecks on rbd volume to: %v", req.GetVolumeId)
|
log.ExtendedLog(ctx, "setting disableInUseChecks on rbd volume to: %v", req.GetVolumeId)
|
||||||
|
Loading…
Reference in New Issue
Block a user