mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-14 02:43:36 +00:00
rbd: convert rbdVolume to rbdSnapshot
After cloning the RBD snapshot, an rbdVolume is returned for the CSI.Snapshot object. In order to use the rbdSnapshot.ToCSI() function, the rbdVolume needs to be converted (back) to an rbdSnaphot. Signed-off-by: Niels de Vos <ndevos@ibm.com>
This commit is contained in:
committed by
mergify[bot]
parent
503d10eb1a
commit
869aaced7d
@ -32,7 +32,6 @@ import (
|
||||
"github.com/kubernetes-csi/csi-lib-utils/protosanitizer"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
"google.golang.org/protobuf/types/known/timestamppb"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -1236,14 +1235,13 @@ func (cs *ControllerServer) CreateSnapshot(
|
||||
return nil, status.Error(codes.Internal, err.Error())
|
||||
}
|
||||
|
||||
csiSnap, err := vol.toSnapshot().ToCSI(ctx)
|
||||
if err != nil {
|
||||
return nil, status.Error(codes.Internal, err.Error())
|
||||
}
|
||||
|
||||
return &csi.CreateSnapshotResponse{
|
||||
Snapshot: &csi.Snapshot{
|
||||
SizeBytes: vol.VolSize,
|
||||
SnapshotId: vol.VolID,
|
||||
SourceVolumeId: req.GetSourceVolumeId(),
|
||||
CreationTime: timestamppb.New(*vol.CreatedAt),
|
||||
ReadyToUse: true,
|
||||
},
|
||||
Snapshot: csiSnap,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@ -1296,14 +1294,13 @@ func cloneFromSnapshot(
|
||||
}
|
||||
}
|
||||
|
||||
csiSnap, err := rbdSnap.ToCSI(ctx)
|
||||
if err != nil {
|
||||
return nil, status.Error(codes.Internal, err.Error())
|
||||
}
|
||||
|
||||
return &csi.CreateSnapshotResponse{
|
||||
Snapshot: &csi.Snapshot{
|
||||
SizeBytes: rbdSnap.VolSize,
|
||||
SnapshotId: rbdSnap.VolID,
|
||||
SourceVolumeId: rbdSnap.SourceVolumeID,
|
||||
CreationTime: timestamppb.New(*rbdSnap.CreatedAt),
|
||||
ReadyToUse: true,
|
||||
},
|
||||
Snapshot: csiSnap,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user