mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-12-18 02:50:30 +00:00
cephfs/volumeidentifier: changed volume ID scheme
volumes have "csi-cephfs-dyn-" prefix when they are provisioned dynamically (provisionVolume=true) and have "csi-cephfs-sta-" prefix when they are provisioned statically by the user (provisionVolume=false)
This commit is contained in:
parent
374176c6ce
commit
69ecce1e75
@ -21,6 +21,12 @@ import (
|
||||
"github.com/pborman/uuid"
|
||||
)
|
||||
|
||||
const (
|
||||
dynamicallyProvisionedVolumePrefix = "csi-cephfs-dyn-"
|
||||
staticallyProvisionedVolumePrefix = "csi-cephfs-sta-"
|
||||
volumePrefixLen = len(dynamicallyProvisionedVolumePrefix)
|
||||
)
|
||||
|
||||
type volumeIdentifier struct {
|
||||
name, uuid, id string
|
||||
}
|
||||
@ -31,7 +37,24 @@ func newVolumeIdentifier(volOptions *volumeOptions, req *csi.CreateVolumeRequest
|
||||
uuid: uuid.NewUUID().String(),
|
||||
}
|
||||
|
||||
volId.id = "csi-cephfs-" + volId.uuid
|
||||
prefix := staticallyProvisionedVolumePrefix
|
||||
if volOptions.ProvisionVolume {
|
||||
prefix = dynamicallyProvisionedVolumePrefix
|
||||
}
|
||||
|
||||
volId.id = prefix + volId.uuid
|
||||
|
||||
return &volId
|
||||
}
|
||||
|
||||
func uuidFromVolumeId(volId string) string {
|
||||
return volId[volumePrefixLen:]
|
||||
}
|
||||
|
||||
func isDynProvision(volId string) bool {
|
||||
if len(volId) <= volumePrefixLen {
|
||||
return false
|
||||
}
|
||||
|
||||
return volId[:volumePrefixLen] == dynamicallyProvisionedVolumePrefix
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user