mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-12-18 02:50:30 +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 {
|
if pv.Spec.CSI == nil || pv.Spec.CSI.Driver != r.config.DriverName {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
pool := pv.Spec.CSI.VolumeAttributes["pool"]
|
|
||||||
journalPool := pv.Spec.CSI.VolumeAttributes["journalPool"]
|
|
||||||
requestName := pv.Name
|
requestName := pv.Name
|
||||||
imageName := pv.Spec.CSI.VolumeAttributes["imageName"]
|
|
||||||
volumeHandler := pv.Spec.CSI.VolumeHandle
|
volumeHandler := pv.Spec.CSI.VolumeHandle
|
||||||
secretName := ""
|
secretName := ""
|
||||||
secretNamespace := ""
|
secretNamespace := ""
|
||||||
@ -210,7 +207,7 @@ func (r ReconcilePersistentVolume) reconcilePV(ctx context.Context, obj runtime.
|
|||||||
}
|
}
|
||||||
defer cr.DeleteCredentials()
|
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 {
|
if err != nil {
|
||||||
util.ErrorLogMsg("failed to regenerate journal %s", err)
|
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.
|
// complete omap mapping between imageName and volumeID.
|
||||||
|
|
||||||
// RegenerateJournal performs below operations
|
// RegenerateJournal performs below operations
|
||||||
|
// Extract parameters journalPool, pool from volumeAttributes
|
||||||
// Extract information from volumeID
|
// Extract information from volumeID
|
||||||
// Get pool ID from pool name
|
// Get pool ID from pool name
|
||||||
// Extract uuid from volumeID
|
// 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
|
// The volume handler won't remain same as its contains poolID,clusterID etc
|
||||||
// which are not same across clusters.
|
// which are not same across clusters.
|
||||||
func RegenerateJournal(
|
func RegenerateJournal(
|
||||||
imageName, volumeID, pool, journalPool, requestName string,
|
volumeAttributes map[string]string,
|
||||||
|
volumeID, requestName string,
|
||||||
cr *util.Credentials) (string, error) {
|
cr *util.Credentials) (string, error) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
var (
|
var (
|
||||||
options map[string]string
|
options map[string]string
|
||||||
vi util.CSIIdentifier
|
vi util.CSIIdentifier
|
||||||
rbdVol *rbdVolume
|
rbdVol *rbdVolume
|
||||||
|
ok bool
|
||||||
)
|
)
|
||||||
|
|
||||||
options = make(map[string]string)
|
options = make(map[string]string)
|
||||||
@ -560,12 +563,14 @@ func RegenerateJournal(
|
|||||||
return "", err
|
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)
|
err = rbdVol.Connect(cr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
rbdVol.JournalPool = journalPool
|
rbdVol.JournalPool = volumeAttributes["journalPool"]
|
||||||
if rbdVol.JournalPool == "" {
|
if rbdVol.JournalPool == "" {
|
||||||
rbdVol.JournalPool = rbdVol.Pool
|
rbdVol.JournalPool = rbdVol.Pool
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user