mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-09 16:00:22 +00:00
journal: add volumeMap to the group
instead of adding single volumes to the group journal, support adding multiple volumeID's map to the group journal which is required for RBD as well. Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
parent
fc0a7d2542
commit
f8fbf2e95a
@ -461,11 +461,13 @@ func (cs *ControllerServer) createSnapshotAndAddMapping(
|
||||
}
|
||||
defer j.Destroy()
|
||||
// Add the snapshot to the volume group journal
|
||||
err = j.AddVolumeMapping(ctx,
|
||||
err = j.AddVolumesMapping(ctx,
|
||||
vgo.MetadataPool,
|
||||
vgs.ReservedID,
|
||||
req.GetSourceVolumeId(),
|
||||
resp.GetSnapshot().GetSnapshotId())
|
||||
map[string]string{
|
||||
req.GetSourceVolumeId(): resp.GetSnapshot().GetSnapshotId(),
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
log.ErrorLog(ctx, "failed to add volume snapshot mapping: %v", err)
|
||||
// Delete the last created snapshot as its still not added to the
|
||||
@ -640,7 +642,7 @@ func (cs *ControllerServer) deleteSnapshotsAndUndoReservation(ctx context.Contex
|
||||
return err
|
||||
}
|
||||
// remove the entry from the omap
|
||||
err = j.RemoveVolumeMapping(
|
||||
err = j.RemoveVolumesMapping(
|
||||
ctx,
|
||||
vgo.MetadataPool,
|
||||
vgsi.ReservedID,
|
||||
|
@ -55,17 +55,18 @@ type VolumeGroupJournal interface {
|
||||
journalPoolID int64,
|
||||
reqName,
|
||||
namePrefix string) (string, string, error)
|
||||
// AddVolumeMapping adds a volumeID and value mapping to the UUID
|
||||
// AddVolumesMapping adds a volumeMap map which contains volumeID's and its
|
||||
// corresponding values mapping which need to be added to the UUID
|
||||
// directory. value can be anything which needs mapping, in case of
|
||||
// volumegroupsnapshot its a snapshotID and its empty in case of volumegroup.
|
||||
AddVolumeMapping(
|
||||
// volumegroupsnapshot its a snapshotID and its empty in case of
|
||||
// volumegroup.
|
||||
AddVolumesMapping(
|
||||
ctx context.Context,
|
||||
pool,
|
||||
reservedUUID,
|
||||
volumeID,
|
||||
value string) error
|
||||
// RemoveVolumeMapping removes volumeIDs mapping from the UUID directory.
|
||||
RemoveVolumeMapping(
|
||||
reservedUUID string,
|
||||
volumeMap map[string]string) error
|
||||
// RemoveVolumesMapping removes volumeIDs mapping from the UUID directory.
|
||||
RemoveVolumesMapping(
|
||||
ctx context.Context,
|
||||
pool,
|
||||
reservedUUID string,
|
||||
@ -403,17 +404,16 @@ func (vgjc *VolumeGroupJournalConnection) GetVolumeGroupAttributes(
|
||||
return groupAttributes, nil
|
||||
}
|
||||
|
||||
func (vgjc *VolumeGroupJournalConnection) AddVolumeMapping(
|
||||
func (vgjc *VolumeGroupJournalConnection) AddVolumesMapping(
|
||||
ctx context.Context,
|
||||
pool,
|
||||
reservedUUID,
|
||||
volumeID,
|
||||
value string,
|
||||
reservedUUID string,
|
||||
volumeMap map[string]string,
|
||||
) error {
|
||||
err := setOMapKeys(ctx, vgjc.connection, pool, vgjc.config.namespace, vgjc.config.cephUUIDDirectoryPrefix+reservedUUID,
|
||||
map[string]string{volumeID: value})
|
||||
volumeMap)
|
||||
if err != nil {
|
||||
log.ErrorLog(ctx, "failed adding volume mapping: %v", err)
|
||||
log.ErrorLog(ctx, "failed to add volumeMap %v: %w ", volumeMap, err)
|
||||
|
||||
return err
|
||||
}
|
||||
@ -421,7 +421,7 @@ func (vgjc *VolumeGroupJournalConnection) AddVolumeMapping(
|
||||
return nil
|
||||
}
|
||||
|
||||
func (vgjc *VolumeGroupJournalConnection) RemoveVolumeMapping(
|
||||
func (vgjc *VolumeGroupJournalConnection) RemoveVolumesMapping(
|
||||
ctx context.Context,
|
||||
pool,
|
||||
reservedUUID string,
|
||||
|
Loading…
Reference in New Issue
Block a user