mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-13 02:33:34 +00:00
rbd: fill clusterID if its a migration nodestage request
the migration nodestage request does not carry the 'clusterID' in it and only monitors are available with the volumeContext. The volume context flag 'migration=true' and 'static=true' flags allow us to fill 'clusterID' from the passed in monitors to the volume Context,so that rest of the static operations on nodestage can be proceeded as we do treat static volumes today. Signed-off-by: Humble Chirammal <hchiramm@redhat.com>
This commit is contained in:
committed by
mergify[bot]
parent
1f5963919f
commit
2e8e8f5e64
@ -149,6 +149,25 @@ func healerStageTransaction(ctx context.Context, cr *util.Credentials, volOps *r
|
||||
return nil
|
||||
}
|
||||
|
||||
// getClusterIDFromMigrationVolume fills the clusterID for the passed in monitors.
|
||||
func getClusterIDFromMigrationVolume(parameters map[string]string) (string, error) {
|
||||
var err error
|
||||
var rclusterID string
|
||||
mons := parameters["monitors"]
|
||||
for _, m := range strings.Split(mons, ",") {
|
||||
rclusterID, err = util.GetClusterIDFromMon(m)
|
||||
if err != nil && !errors.Is(err, util.ErrMissingConfigForMonitor) {
|
||||
return "", err
|
||||
}
|
||||
|
||||
if rclusterID != "" {
|
||||
return rclusterID, nil
|
||||
}
|
||||
}
|
||||
|
||||
return "", err
|
||||
}
|
||||
|
||||
// populateRbdVol update the fields in rbdVolume struct based on the request it received.
|
||||
func populateRbdVol(
|
||||
ctx context.Context,
|
||||
@ -188,6 +207,10 @@ func populateRbdVol(
|
||||
// get rbd image name from the volume journal
|
||||
// for static volumes, the image name is actually the volume ID itself
|
||||
if isStaticVol {
|
||||
if req.GetVolumeContext()[intreeMigrationKey] == intreeMigrationLabel {
|
||||
// if migration static volume, use imageName as volID
|
||||
volID = req.GetVolumeContext()["imageName"]
|
||||
}
|
||||
rv.RbdImageName = volID
|
||||
} else {
|
||||
var vi util.CSIIdentifier
|
||||
@ -268,6 +291,16 @@ func (ns *NodeServer) NodeStageVolume(
|
||||
}
|
||||
defer ns.VolumeLocks.Release(volID)
|
||||
|
||||
// Check this is a migration request because in that case, unlike other node stage requests
|
||||
// it will be missing the clusterID, so fill it by fetching it from config file using mon.
|
||||
if req.GetVolumeContext()[intreeMigrationKey] == intreeMigrationLabel && req.VolumeContext[util.ClusterIDKey] == "" {
|
||||
cID, cErr := getClusterIDFromMigrationVolume(req.GetVolumeContext())
|
||||
if cErr != nil {
|
||||
return nil, status.Error(codes.Internal, cErr.Error())
|
||||
}
|
||||
req.VolumeContext[util.ClusterIDKey] = cID
|
||||
}
|
||||
|
||||
stagingParentPath := req.GetStagingTargetPath()
|
||||
stagingTargetPath := stagingParentPath + "/" + volID
|
||||
|
||||
|
@ -73,6 +73,10 @@ const (
|
||||
// thick provisioned or thin provisioned.
|
||||
thickProvisionMetaData = "true"
|
||||
thinProvisionMetaData = "false"
|
||||
|
||||
// these are the migration label key and value for parameters in volume context.
|
||||
intreeMigrationKey = "migration"
|
||||
intreeMigrationLabel = "true"
|
||||
)
|
||||
|
||||
// rbdImage contains common attributes and methods for the rbdVolume and
|
||||
|
Reference in New Issue
Block a user