mirror of
https://github.com/SynologyOpenSource/synology-csi.git
synced 2026-05-05 03:17:12 +00:00
Merge pull request #60 from rtim75/feature/populate-lun-description-with-pvc-info
Add pvc-namespace/pvc-name to lun descriptions
This commit is contained in:
@@ -96,6 +96,7 @@ spec:
|
||||
- --timeout=60s
|
||||
- --csi-address=$(ADDRESS)
|
||||
- --v=5
|
||||
- --extra-create-metadata
|
||||
env:
|
||||
- name: ADDRESS
|
||||
value: /var/lib/csi/sockets/pluginproxy/csi.sock
|
||||
|
||||
@@ -96,6 +96,7 @@ spec:
|
||||
- --timeout=60s
|
||||
- --csi-address=$(ADDRESS)
|
||||
- --v=5
|
||||
- --extra-create-metadata
|
||||
env:
|
||||
- name: ADDRESS
|
||||
value: /var/lib/csi/sockets/pluginproxy/csi.sock
|
||||
|
||||
@@ -132,10 +132,20 @@ func (cs *controllerServer) CreateVolume(ctx context.Context, req *csi.CreateVol
|
||||
// used only in NodeStageVolume though VolumeContext
|
||||
formatOptions := params["formatOptions"]
|
||||
|
||||
lunDescription := ""
|
||||
if _, ok := params["csi.storage.k8s.io/pvc/name"]; ok {
|
||||
// if the /pvc/name is present, the namespace is present too
|
||||
// as these parameters are reserved by external-provisioner
|
||||
pvcNamespace := params["csi.storage.k8s.io/pvc/namespace"]
|
||||
pvcName := params["csi.storage.k8s.io/pvc/name"]
|
||||
lunDescription = pvcNamespace + "/" + pvcName
|
||||
}
|
||||
|
||||
spec := &models.CreateK8sVolumeSpec{
|
||||
DsmIp: params["dsm"],
|
||||
K8sVolumeName: volName,
|
||||
LunName: models.GenLunName(volName),
|
||||
LunDescription: lunDescription,
|
||||
ShareName: models.GenShareName(volName),
|
||||
Location: params["location"],
|
||||
Size: sizeInByte,
|
||||
|
||||
@@ -168,7 +168,7 @@ func (service *DsmService) createMappingTarget(dsm *webapi.DSM, spec *models.Cre
|
||||
}
|
||||
targetSpec := webapi.TargetCreateSpec{
|
||||
Name: spec.TargetName,
|
||||
Iqn: genTargetIqn(),
|
||||
Iqn: genTargetIqn(),
|
||||
}
|
||||
|
||||
log.Debugf("TargetCreate spec: %v", targetSpec)
|
||||
@@ -224,10 +224,11 @@ func (service *DsmService) createVolumeByDsm(dsm *webapi.DSM, spec *models.Creat
|
||||
|
||||
// 3. Create LUN
|
||||
lunSpec := webapi.LunCreateSpec{
|
||||
Name: spec.LunName,
|
||||
Location: spec.Location,
|
||||
Size: spec.Size,
|
||||
Type: lunType,
|
||||
Name: spec.LunName,
|
||||
Description: spec.LunDescription,
|
||||
Location: spec.Location,
|
||||
Size: spec.Size,
|
||||
Type: lunType,
|
||||
}
|
||||
|
||||
log.Debugf("LunCreate spec: %v", lunSpec)
|
||||
|
||||
@@ -67,11 +67,12 @@ type LunDevAttrib struct {
|
||||
}
|
||||
|
||||
type LunCreateSpec struct {
|
||||
Name string
|
||||
Location string
|
||||
Size int64
|
||||
Type string
|
||||
DevAttribs []LunDevAttrib
|
||||
Name string
|
||||
Description string
|
||||
Location string
|
||||
Size int64
|
||||
Type string
|
||||
DevAttribs []LunDevAttrib
|
||||
}
|
||||
|
||||
type LunUpdateSpec struct {
|
||||
@@ -165,6 +166,7 @@ func (dsm *DSM) LunCreate(spec LunCreateSpec) (string, error) {
|
||||
params.Add("size", strconv.FormatInt(int64(spec.Size), 10))
|
||||
params.Add("type", spec.Type)
|
||||
params.Add("location", spec.Location)
|
||||
params.Add("description", spec.Description)
|
||||
|
||||
js, err := json.Marshal(spec.DevAttribs)
|
||||
if err != nil {
|
||||
@@ -497,4 +499,4 @@ func (dsm *DSM) SnapshotClone(spec SnapshotCloneSpec) (string, error) {
|
||||
}
|
||||
|
||||
return snapshotCloneResp.Uuid, nil
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ type CreateK8sVolumeSpec struct {
|
||||
DsmIp string
|
||||
K8sVolumeName string
|
||||
LunName string
|
||||
LunDescription string
|
||||
ShareName string
|
||||
Location string
|
||||
Size int64
|
||||
|
||||
Reference in New Issue
Block a user