mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-09 16:00:22 +00:00
rbd: refractor RegenerateJournal() to take in volumeAttributes
This commit refractors RegenerateJournal() to take in volumeAttributes map[string]string as argument so it can extract required attributes internally. Signed-off-by: Rakshith R <rar@redhat.com>
This commit is contained in:
parent
39d6752fc1
commit
b9b4b1e34e
@ -172,10 +172,7 @@ func (r ReconcilePersistentVolume) reconcilePV(ctx context.Context, obj runtime.
|
||||
if pv.Spec.CSI == nil || pv.Spec.CSI.Driver != r.config.DriverName {
|
||||
return nil
|
||||
}
|
||||
pool := pv.Spec.CSI.VolumeAttributes["pool"]
|
||||
journalPool := pv.Spec.CSI.VolumeAttributes["journalPool"]
|
||||
requestName := pv.Name
|
||||
imageName := pv.Spec.CSI.VolumeAttributes["imageName"]
|
||||
volumeHandler := pv.Spec.CSI.VolumeHandle
|
||||
secretName := ""
|
||||
secretNamespace := ""
|
||||
@ -210,7 +207,7 @@ func (r ReconcilePersistentVolume) reconcilePV(ctx context.Context, obj runtime.
|
||||
}
|
||||
defer cr.DeleteCredentials()
|
||||
|
||||
rbdVolID, err := rbd.RegenerateJournal(imageName, volumeHandler, pool, journalPool, requestName, cr)
|
||||
rbdVolID, err := rbd.RegenerateJournal(pv.Spec.CSI.VolumeAttributes, volumeHandler, requestName, cr)
|
||||
if err != nil {
|
||||
util.ErrorLogMsg("failed to regenerate journal %s", err)
|
||||
|
||||
|
@ -522,6 +522,7 @@ func undoVolReservation(ctx context.Context, rbdVol *rbdVolume, cr *util.Credent
|
||||
// complete omap mapping between imageName and volumeID.
|
||||
|
||||
// RegenerateJournal performs below operations
|
||||
// Extract parameters journalPool, pool from volumeAttributes
|
||||
// Extract information from volumeID
|
||||
// Get pool ID from pool name
|
||||
// Extract uuid from volumeID
|
||||
@ -530,13 +531,15 @@ func undoVolReservation(ctx context.Context, rbdVol *rbdVolume, cr *util.Credent
|
||||
// The volume handler won't remain same as its contains poolID,clusterID etc
|
||||
// which are not same across clusters.
|
||||
func RegenerateJournal(
|
||||
imageName, volumeID, pool, journalPool, requestName string,
|
||||
volumeAttributes map[string]string,
|
||||
volumeID, requestName string,
|
||||
cr *util.Credentials) (string, error) {
|
||||
ctx := context.Background()
|
||||
var (
|
||||
options map[string]string
|
||||
vi util.CSIIdentifier
|
||||
rbdVol *rbdVolume
|
||||
ok bool
|
||||
)
|
||||
|
||||
options = make(map[string]string)
|
||||
@ -560,12 +563,14 @@ func RegenerateJournal(
|
||||
return "", err
|
||||
}
|
||||
|
||||
rbdVol.Pool = pool
|
||||
if rbdVol.Pool, ok = volumeAttributes["pool"]; !ok {
|
||||
return "", errors.New("required 'pool' parameter missing in volume attributes")
|
||||
}
|
||||
err = rbdVol.Connect(cr)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
rbdVol.JournalPool = journalPool
|
||||
rbdVol.JournalPool = volumeAttributes["journalPool"]
|
||||
if rbdVol.JournalPool == "" {
|
||||
rbdVol.JournalPool = rbdVol.Pool
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user