@@ -116,7 +116,7 @@ func (cs *controllerServer) CreateVolume(ctx context.Context, req *csi.CreateVol
116
116
}
117
117
118
118
lvmType := req .GetParameters ()["type" ]
119
- if ! (lvmType == "linear " || lvmType == "mirror" || lvmType == "striped " ) {
119
+ if ! (lvmType == "striped " || lvmType == "dm-thin " ) {
120
120
return nil , status .Errorf (codes .Internal , "lvmType is incorrect: %s" , lvmType )
121
121
}
122
122
@@ -205,11 +205,17 @@ func (cs *controllerServer) cloneFromSnapshot(ctx context.Context, snapContent *
205
205
ns := srcVol .Spec .NodeAffinity .Required .NodeSelectorTerms
206
206
srcNode := ns [0 ].MatchExpressions [0 ].Values [0 ]
207
207
srcVgName := srcVol .Spec .CSI .VolumeAttributes ["vgName" ]
208
+ srcVgType := srcVol .Spec .CSI .VolumeAttributes ["type" ]
208
209
restoreSize := * snapContent .Status .RestoreSize
209
210
210
211
snapshotLVName := fmt .Sprintf ("lvm-%s" , * snapContent .Status .SnapshotHandle )
211
- srcSnapDev := fmt .Sprintf ("/dev/%s/%s" , srcVgName , snapshotLVName )
212
- klog .V (4 ).Infof ("cloning volume from %s " , srcSnapDev )
212
+ //srcSnapDev := fmt.Sprintf("/dev/%s/%s", srcVgName, snapshotLVName)
213
+ srcInfo := & srcInfo {
214
+ srcLVName : snapshotLVName ,
215
+ srcVGName : srcVgName ,
216
+ srcType : srcVgType ,
217
+ }
218
+ klog .V (4 ).Infof ("cloning volume from %s/%s " , srcVgName , snapshotLVName )
213
219
214
220
if restoreSize > dstSize {
215
221
return status .Error (codes .InvalidArgument , "source volume size is larger than destination volume size" )
@@ -230,7 +236,7 @@ func (cs *controllerServer) cloneFromSnapshot(ctx context.Context, snapContent *
230
236
namespace : cs .namespace ,
231
237
vgName : dstVGName ,
232
238
hostWritePath : cs .hostWritePath ,
233
- srcDev : srcSnapDev ,
239
+ srcInfo : srcInfo ,
234
240
}
235
241
if err := createProvisionerPod (ctx , va ); err != nil {
236
242
klog .Errorf ("error creating provisioner pod :%v" , err )
@@ -244,14 +250,22 @@ func (cs *controllerServer) cloneFromVolume(ctx context.Context, srcVol *v1.Pers
244
250
ns := srcVol .Spec .NodeAffinity .Required .NodeSelectorTerms
245
251
srcNode := ns [0 ].MatchExpressions [0 ].Values [0 ]
246
252
srcVgName := srcVol .Spec .CSI .VolumeAttributes ["vgName" ]
253
+ srcType := srcVol .Spec .CSI .VolumeAttributes ["type" ]
247
254
srcSizeStr := srcVol .Spec .CSI .VolumeAttributes ["RequiredBytes" ]
248
255
srcSize , err := strconv .ParseInt (srcSizeStr , 10 , 64 )
249
256
if err != nil {
250
257
klog .Errorf ("error parsing srcSize: %v" , err )
251
258
return err
252
259
}
253
- srcDev := fmt .Sprintf ("/dev/%s/%s" , srcVgName , srcVol .GetName ())
254
- klog .V (4 ).Infof ("cloning volume from %s " , srcDev )
260
+
261
+ //srcDev := fmt.Sprintf("/dev/%s/%s", srcVgName, srcVol.GetName())
262
+ srcLVName := srcVol .GetName ()
263
+ srcInfo := & srcInfo {
264
+ srcLVName : srcLVName ,
265
+ srcVGName : srcVgName ,
266
+ srcType : srcType ,
267
+ }
268
+ klog .V (4 ).Infof ("cloning volume from %s/%s " , srcVgName , srcLVName )
255
269
256
270
if srcSize > dstSize {
257
271
return status .Error (codes .InvalidArgument , "source volume size is larger than destination volume size" )
@@ -272,7 +286,7 @@ func (cs *controllerServer) cloneFromVolume(ctx context.Context, srcVol *v1.Pers
272
286
namespace : cs .namespace ,
273
287
vgName : dstVGName ,
274
288
hostWritePath : cs .hostWritePath ,
275
- srcDev : srcDev ,
289
+ srcInfo : srcInfo ,
276
290
}
277
291
if err := createProvisionerPod (ctx , va ); err != nil {
278
292
klog .Errorf ("error creating provisioner pod :%v" , err )
@@ -302,6 +316,13 @@ func (cs *controllerServer) DeleteVolume(ctx context.Context, req *csi.DeleteVol
302
316
klog .V (4 ).Infof ("volume %s to be deleted" , volume )
303
317
ns := volume .Spec .NodeAffinity .Required .NodeSelectorTerms
304
318
node := ns [0 ].MatchExpressions [0 ].Values [0 ]
319
+ srcVgName := volume .Spec .CSI .VolumeAttributes ["vgName" ]
320
+ srcType := volume .Spec .CSI .VolumeAttributes ["type" ]
321
+ srcInfo := & srcInfo {
322
+ srcLVName : volID ,
323
+ srcVGName : srcVgName ,
324
+ srcType : srcType ,
325
+ }
305
326
306
327
klog .V (4 ).Infof ("from node %s " , node )
307
328
@@ -318,13 +339,14 @@ func (cs *controllerServer) DeleteVolume(ctx context.Context, req *csi.DeleteVol
318
339
319
340
va := volumeAction {
320
341
action : actionTypeDelete ,
321
- name : req . GetVolumeId () ,
342
+ name : volID ,
322
343
nodeName : node ,
323
344
pullPolicy : cs .pullPolicy ,
324
345
provisionerImage : cs .provisionerImage ,
325
346
kubeClient : cs .kubeClient ,
326
347
namespace : cs .namespace ,
327
348
hostWritePath : cs .hostWritePath ,
349
+ srcInfo : srcInfo ,
328
350
}
329
351
if err := createProvisionerPod (ctx , va ); err != nil {
330
352
klog .Errorf ("error creating provisioner pod :%v" , err )
@@ -430,6 +452,7 @@ func (cs *controllerServer) CreateSnapshot(ctx context.Context, req *csi.CreateS
430
452
ns := volume .Spec .NodeAffinity .Required .NodeSelectorTerms
431
453
node := ns [0 ].MatchExpressions [0 ].Values [0 ]
432
454
vgName := volume .Spec .CSI .VolumeAttributes ["vgName" ]
455
+ lvType := volume .Spec .CSI .VolumeAttributes ["type" ]
433
456
snapSizeStr := volume .Spec .CSI .VolumeAttributes ["RequiredBytes" ]
434
457
snapSize , err := strconv .ParseInt (snapSizeStr , 10 , 64 )
435
458
if err != nil {
@@ -448,6 +471,7 @@ func (cs *controllerServer) CreateSnapshot(ctx context.Context, req *csi.CreateS
448
471
nodeName : node ,
449
472
snapSize : snapSize ,
450
473
vgName : vgName ,
474
+ lvType : lvType ,
451
475
hostWritePath : cs .hostWritePath ,
452
476
kubeClient : cs .kubeClient ,
453
477
namespace : cs .namespace ,
@@ -502,6 +526,7 @@ func (cs *controllerServer) DeleteSnapshot(ctx context.Context, req *csi.DeleteS
502
526
snapshotName : snapName ,
503
527
nodeName : node ,
504
528
vgName : vgName ,
529
+ lvType : "" , // not used
505
530
hostWritePath : cs .hostWritePath ,
506
531
kubeClient : cs .kubeClient ,
507
532
namespace : cs .namespace ,
0 commit comments