mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-14 02:43:36 +00:00
rbd: add manager GetSnapshotByID and SnapshotResolver interface
A (CSI) VolumeGroupSnapshot object contains references to Snapshot IDs (or CSI Snapshot handles). In order to work with a VolumeGroupSnapshot struct, the Snapshot IDs need to be resolved into rbdSnapshot structs. Signed-off-by: Niels de Vos <ndevos@ibm.com>
This commit is contained in:
committed by
mergify[bot]
parent
455a90e9f4
commit
9bea3feff1
@ -139,6 +139,31 @@ func (mgr *rbdManager) GetVolumeByID(ctx context.Context, id string) (types.Volu
|
||||
return volume, nil
|
||||
}
|
||||
|
||||
func (mgr *rbdManager) GetSnapshotByID(ctx context.Context, id string) (types.Snapshot, error) {
|
||||
creds, err := mgr.getCredentials()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
snapshot, err := genSnapFromSnapID(ctx, id, creds, mgr.secrets)
|
||||
if err != nil {
|
||||
switch {
|
||||
case errors.Is(err, ErrImageNotFound):
|
||||
err = fmt.Errorf("volume %s not found: %w", id, err)
|
||||
|
||||
return nil, err
|
||||
case errors.Is(err, util.ErrPoolNotFound):
|
||||
err = fmt.Errorf("pool %s not found for %s: %w", snapshot.Pool, id, err)
|
||||
|
||||
return nil, err
|
||||
default:
|
||||
return nil, fmt.Errorf("failed to get volume from id %q: %w", id, err)
|
||||
}
|
||||
}
|
||||
|
||||
return snapshot, nil
|
||||
}
|
||||
|
||||
func (mgr *rbdManager) GetVolumeGroupByID(ctx context.Context, id string) (types.VolumeGroup, error) {
|
||||
creds, err := mgr.getCredentials()
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user