rbd: implement Manager.GetVolumeGroupSnapshotByID

The GetVolumeGroupSnapshotByID function makes it possible to get a
VolumeGroupSnapshot object from the Manager by passing a request-id.
This makes it simple for the Group Controller Server to check if a
VolumeGroupSnapshot already exists, so it is not needed to try and
re-create an existing one.

Signed-off-by: Niels de Vos <ndevos@ibm.com>
This commit is contained in:
Niels de Vos 2024-10-17 17:31:45 +02:00 committed by mergify[bot]
parent 7563f4285d
commit ad381c4ff0
2 changed files with 21 additions and 0 deletions

View File

@ -320,6 +320,23 @@ func (mgr *rbdManager) CreateVolumeGroup(ctx context.Context, name string) (type
return vg, nil return vg, nil
} }
func (mgr *rbdManager) GetVolumeGroupSnapshotByID(
ctx context.Context,
id string,
) (types.VolumeGroupSnapshot, error) {
creds, err := mgr.getCredentials()
if err != nil {
return nil, err
}
vgs, err := rbd_group.GetVolumeGroupSnapshot(ctx, id, mgr.csiID, creds, mgr)
if err != nil {
return nil, fmt.Errorf("failed to get volume group with id %q: %w", id, err)
}
return vgs, nil
}
func (mgr *rbdManager) CreateVolumeGroupSnapshot( func (mgr *rbdManager) CreateVolumeGroupSnapshot(
ctx context.Context, ctx context.Context,
vg types.VolumeGroup, vg types.VolumeGroup,

View File

@ -53,6 +53,10 @@ type Manager interface {
// and records details about it in the journal. // and records details about it in the journal.
CreateVolumeGroup(ctx context.Context, name string) (VolumeGroup, error) CreateVolumeGroup(ctx context.Context, name string) (VolumeGroup, error)
// GetVolumeGroupSnapshotByID resolves the VolumeGroupSnapshot from the
// CSI id/handle.
GetVolumeGroupSnapshotByID(ctx context.Context, id string) (VolumeGroupSnapshot, error)
// CreateVolumeGroupSnapshot instructs the Manager to create a // CreateVolumeGroupSnapshot instructs the Manager to create a
// VolumeGroupSnapshot from the VolumeGroup. All snapshots in the // VolumeGroupSnapshot from the VolumeGroup. All snapshots in the
// returned VolumeGroupSnapshot have been taken while I/O on the // returned VolumeGroupSnapshot have been taken while I/O on the