mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-12-18 02:50:30 +00:00
check snapshot feature
This commit is contained in:
parent
4312907f7b
commit
38aa575925
@ -236,6 +236,10 @@ func (cs *controllerServer) CreateSnapshot(ctx context.Context, req *csi.CreateS
|
||||
if err != nil {
|
||||
return nil, status.Error(codes.NotFound, fmt.Sprintf("Source Volume ID %s cannot found", req.GetSourceVolumeId()))
|
||||
}
|
||||
if !hasSnapshotFeature(rbdVolume.ImageFeatures) {
|
||||
return nil, fmt.Errorf("Volume(%s) has not snapshot feature(layering)", req.GetSourceVolumeId())
|
||||
}
|
||||
|
||||
rbdSnap.VolName = rbdVolume.VolName
|
||||
rbdSnap.SnapName = snapName
|
||||
snapshotID := "csi-rbd-" + rbdVolume.VolName + "-snap-" + uniqueID
|
||||
|
@ -254,6 +254,16 @@ func getRBDSnapshotOptions(snapOptions map[string]string) (*rbdSnapshot, error)
|
||||
return rbdSnap, nil
|
||||
}
|
||||
|
||||
func hasSnapshotFeature(imageFeatures string) bool {
|
||||
arr := strings.Split(imageFeatures, ",")
|
||||
for _, f := range arr {
|
||||
if f == "layering" {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func attachRBDImage(volOptions *rbdVolume, userId string, credentials map[string]string) (string, error) {
|
||||
var err error
|
||||
var output []byte
|
||||
|
Loading…
Reference in New Issue
Block a user