mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-17 20:00:23 +00:00
journal: remove snapshot specific name from group
Adjusted method names to not have any specific things to volumesnapshot as we want to reuse the same journal for volumegroup as well. Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
parent
95733b3a91
commit
f346f3d201
@ -461,7 +461,7 @@ func (cs *ControllerServer) createSnapshotAndAddMapping(
|
||||
}
|
||||
defer j.Destroy()
|
||||
// Add the snapshot to the volume group journal
|
||||
err = j.AddVolumeSnapshotMapping(ctx,
|
||||
err = j.AddVolumeMapping(ctx,
|
||||
vgo.MetadataPool,
|
||||
vgs.ReservedID,
|
||||
req.GetSourceVolumeId(),
|
||||
@ -640,7 +640,7 @@ func (cs *ControllerServer) deleteSnapshotsAndUndoReservation(ctx context.Contex
|
||||
return err
|
||||
}
|
||||
// remove the entry from the omap
|
||||
err = j.RemoveVolumeSnapshotMapping(
|
||||
err = j.RemoveVolumeMapping(
|
||||
ctx,
|
||||
vgo.MetadataPool,
|
||||
vgsi.ReservedID,
|
||||
|
@ -169,7 +169,7 @@ func NewVolumeGroupOptionsFromID(
|
||||
vgs.RequestName = groupAttributes.RequestName
|
||||
vgs.FsVolumeGroupSnapshotName = groupAttributes.GroupName
|
||||
vgs.VolumeGroupSnapshotID = volumeGroupSnapshotID
|
||||
vgs.VolumeSnapshotMap = groupAttributes.VolumeSnapshotMap
|
||||
vgs.VolumeSnapshotMap = groupAttributes.VolumeMap
|
||||
|
||||
return volOptions, &vgs, nil
|
||||
}
|
||||
@ -208,7 +208,7 @@ func CheckVolumeGroupSnapExists(
|
||||
vgs.RequestName = volOptions.RequestName
|
||||
vgs.ReservedID = volGroupData.GroupUUID
|
||||
vgs.FsVolumeGroupSnapshotName = volGroupData.GroupName
|
||||
vgs.VolumeSnapshotMap = volGroupData.VolumeGroupAttributes.VolumeSnapshotMap
|
||||
vgs.VolumeSnapshotMap = volGroupData.VolumeGroupAttributes.VolumeMap
|
||||
|
||||
// found a snapshot already available, process and return it!
|
||||
vgs.VolumeGroupSnapshotID, err = util.GenerateVolID(ctx, volOptions.Monitors, cr, volOptions.FscID,
|
||||
|
@ -41,7 +41,7 @@ type VolumeGroupJournal interface {
|
||||
UndoReservation(
|
||||
ctx context.Context,
|
||||
csiJournalPool,
|
||||
snapshotGroupName,
|
||||
groupName,
|
||||
reqName string) error
|
||||
// GetGroupAttributes fetches all keys and their values, from a UUID directory,
|
||||
// returning VolumeGroupAttributes structure.
|
||||
@ -55,15 +55,17 @@ type VolumeGroupJournal interface {
|
||||
journalPoolID int64,
|
||||
reqName,
|
||||
namePrefix string) (string, string, error)
|
||||
// AddVolumeSnapshotMapping adds a volumeID and snapshotID mapping to the UUID directory.
|
||||
AddVolumeSnapshotMapping(
|
||||
// AddVolumeMapping adds a volumeID and value mapping 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(
|
||||
ctx context.Context,
|
||||
pool,
|
||||
reservedUUID,
|
||||
volumeID,
|
||||
snapshotID string) error
|
||||
// RemoveVolumeSnapshotMapping removes a volumeID and snapshotID mapping from the UUID directory.
|
||||
RemoveVolumeSnapshotMapping(
|
||||
value string) error
|
||||
// RemoveVolumeMapping removes a volumeID mapping from the UUID directory.
|
||||
RemoveVolumeMapping(
|
||||
ctx context.Context,
|
||||
pool,
|
||||
reservedUUID,
|
||||
@ -222,7 +224,7 @@ func (vgjc *VolumeGroupJournalConnection) CheckReservation(ctx context.Context,
|
||||
volGroupData.GroupName = savedVolumeGroupAttributes.GroupName
|
||||
volGroupData.VolumeGroupAttributes = &VolumeGroupAttributes{}
|
||||
volGroupData.VolumeGroupAttributes.RequestName = savedVolumeGroupAttributes.RequestName
|
||||
volGroupData.VolumeGroupAttributes.VolumeSnapshotMap = savedVolumeGroupAttributes.VolumeSnapshotMap
|
||||
volGroupData.VolumeGroupAttributes.VolumeMap = savedVolumeGroupAttributes.VolumeMap
|
||||
|
||||
return volGroupData, nil
|
||||
}
|
||||
@ -361,9 +363,9 @@ func (vgjc *VolumeGroupJournalConnection) ReserveName(ctx context.Context,
|
||||
// VolumeGroupAttributes contains the request name and the volumeID's and
|
||||
// the corresponding snapshotID's.
|
||||
type VolumeGroupAttributes struct {
|
||||
RequestName string // Contains the request name for the passed in UUID
|
||||
GroupName string // Contains the group name
|
||||
VolumeSnapshotMap map[string]string // Contains the volumeID and the corresponding snapshotID mapping
|
||||
RequestName string // Contains the request name for the passed in UUID
|
||||
GroupName string // Contains the group name
|
||||
VolumeMap map[string]string // Contains the volumeID and the corresponding value mapping
|
||||
}
|
||||
|
||||
func (vgjc *VolumeGroupJournalConnection) GetVolumeGroupAttributes(
|
||||
@ -393,25 +395,25 @@ func (vgjc *VolumeGroupJournalConnection) GetVolumeGroupAttributes(
|
||||
// looking for volumeID/snapshotID mapping
|
||||
delete(values, cj.csiNameKey)
|
||||
delete(values, cj.csiImageKey)
|
||||
groupAttributes.VolumeSnapshotMap = map[string]string{}
|
||||
groupAttributes.VolumeMap = map[string]string{}
|
||||
for k, v := range values {
|
||||
groupAttributes.VolumeSnapshotMap[k] = v
|
||||
groupAttributes.VolumeMap[k] = v
|
||||
}
|
||||
|
||||
return groupAttributes, nil
|
||||
}
|
||||
|
||||
func (vgjc *VolumeGroupJournalConnection) AddVolumeSnapshotMapping(
|
||||
func (vgjc *VolumeGroupJournalConnection) AddVolumeMapping(
|
||||
ctx context.Context,
|
||||
pool,
|
||||
reservedUUID,
|
||||
volumeID,
|
||||
snapshotID string,
|
||||
value string,
|
||||
) error {
|
||||
err := setOMapKeys(ctx, vgjc.connection, pool, vgjc.config.namespace, vgjc.config.cephUUIDDirectoryPrefix+reservedUUID,
|
||||
map[string]string{volumeID: snapshotID})
|
||||
map[string]string{volumeID: value})
|
||||
if err != nil {
|
||||
log.ErrorLog(ctx, "failed adding volume snapshot mapping: %v", err)
|
||||
log.ErrorLog(ctx, "failed adding volume mapping: %v", err)
|
||||
|
||||
return err
|
||||
}
|
||||
@ -419,7 +421,7 @@ func (vgjc *VolumeGroupJournalConnection) AddVolumeSnapshotMapping(
|
||||
return nil
|
||||
}
|
||||
|
||||
func (vgjc *VolumeGroupJournalConnection) RemoveVolumeSnapshotMapping(
|
||||
func (vgjc *VolumeGroupJournalConnection) RemoveVolumeMapping(
|
||||
ctx context.Context,
|
||||
pool,
|
||||
reservedUUID,
|
||||
@ -429,7 +431,7 @@ func (vgjc *VolumeGroupJournalConnection) RemoveVolumeSnapshotMapping(
|
||||
vgjc.config.cephUUIDDirectoryPrefix+reservedUUID,
|
||||
[]string{volumeID})
|
||||
if err != nil {
|
||||
log.ErrorLog(ctx, "failed removing volume snapshot mapping: %v", err)
|
||||
log.ErrorLog(ctx, "failed removing volume mapping from group: key %q: %v", volumeID, err)
|
||||
|
||||
return err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user