Skip to content

Commit

Permalink
rbd: implement Manager.GetVolumeGroupSnapshotByID
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
nixpanic committed Nov 6, 2024
1 parent b83bb19 commit 58e5fa9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
17 changes: 17 additions & 0 deletions internal/rbd/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,23 @@ func (mgr *rbdManager) CreateVolumeGroup(ctx context.Context, name string) (type
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(
ctx context.Context,
vg types.VolumeGroup,
Expand Down
4 changes: 4 additions & 0 deletions internal/rbd/types/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ type Manager interface {
// and records details about it in the journal.
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
// VolumeGroupSnapshot from the VolumeGroup. All snapshots in the
// returned VolumeGroupSnapshot have been taken while I/O on the
Expand Down

0 comments on commit 58e5fa9

Please sign in to comment.