forked from thecodeteam/csi-scaleio
/
controller.go
775 lines (660 loc) · 19.1 KB
/
controller.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
package service
import (
"fmt"
"strconv"
"strings"
"golang.org/x/net/context"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"github.com/container-storage-interface/spec/lib/go/csi"
log "github.com/sirupsen/logrus"
"github.com/thecodeteam/goscaleio"
siotypes "github.com/thecodeteam/goscaleio/types/v1"
"github.com/thecodeteam/gocsi"
)
const (
// KeyStoragePool is the key used to get the storagepool name from the
// volume create parameters map
KeyStoragePool = "storagepool"
// DefaultVolumeSizeKiB is default volume size to create on a scaleIO
// cluster when no size is given, expressed in KiB
DefaultVolumeSizeKiB = 16 * kiBytesInGiB
// VolSizeMultipleGiB is the volume size that ScaleIO creates volumes as
// a multiple of, meaning that all volume sizes are a multiple of this
// number
VolSizeMultipleGiB = 8
// bytesInKiB is the number of bytes in a kibibyte
bytesInKiB = 1024
// kiBytesInGiB is the number of kibibytes in a gibibyte
kiBytesInGiB = 1024 * 1024
// bytesInGiB is the number of bytes in a gibibyte
bytesInGiB = kiBytesInGiB * bytesInKiB
removeModeOnlyMe = "ONLY_ME"
sioGatewayNotFound = "Not found"
sioGatewayVolumeNotFound = "Could not find the volume"
sioGatewayVolumeNameInUse = "Volume name already in use. Please use a different name."
errNoMultiMap = "volume not enabled for mapping to multiple hosts"
errUnknownAccessMode = "access mode cannot be UNKNOWN"
errNoMultiNodeWriter = "multi-node with writer(s) only supported for block access type"
)
var (
emptyDelResp = &csi.DeleteVolumeResponse{}
emptyProbeResp = &csi.ControllerProbeResponse{}
emptyCtrlPubResp = &csi.ControllerPublishVolumeResponse{}
emptyCtrlUnpubResp = &csi.ControllerUnpublishVolumeResponse{}
)
func (s *service) CreateVolume(
ctx context.Context,
req *csi.CreateVolumeRequest) (
*csi.CreateVolumeResponse, error) {
if err := s.requireProbe(ctx); err != nil {
return nil, err
}
cr := req.GetCapacityRange()
sizeInKiB, err := validateVolSize(cr)
if err != nil {
return nil, err
}
params := req.GetParameters()
// We require the storagePool name for creation
sp, ok := params[KeyStoragePool]
if !ok {
return nil, status.Errorf(codes.InvalidArgument,
"`%s` is a required parameter", KeyStoragePool)
}
volType := s.getVolProvisionType(params)
name := req.GetName()
if name == "" {
return nil, gocsi.ErrVolumeNameRequired
}
fields := map[string]interface{}{
"name": name,
"sizeInKiB": sizeInKiB,
"storagePool": sp,
"volType": volType,
}
log.WithFields(fields).Info("creating volume")
volumeParam := &siotypes.VolumeParam{
Name: name,
VolumeSizeInKb: strconv.Itoa(sizeInKiB),
VolumeType: volType,
}
createResp, err := s.adminClient.CreateVolume(volumeParam, sp)
if err != nil {
// handle case where volume already exists
if !strings.EqualFold(err.Error(), sioGatewayVolumeNameInUse) {
return nil, status.Errorf(codes.Internal,
"error when creating volume: %s", err.Error())
}
}
var id string
if createResp == nil {
// volume already exists, look it up by name
id, err = s.GetVolumeID(ctx, name)
if err != nil {
return nil, status.Errorf(codes.Internal, err.Error())
}
} else {
id = createResp.ID
}
vol, err := s.getVolByID(id)
if err != nil {
return nil, status.Errorf(codes.Unavailable,
"error retrieving volume details: %s", err.Error())
}
vi := getCSIVolumeInfo(vol)
// since the volume could have already exists, double check that the
// volume has the expected parameters
spID, err := s.getStoragePoolID(sp)
if err != nil {
return nil, status.Errorf(codes.Unavailable,
"volume exists, but could not verify parameters: %s",
err.Error())
}
if vol.StoragePoolID != spID {
return nil, status.Errorf(codes.Unavailable,
"volume exists, but in different storage pool than requested")
}
if (vi.CapacityBytes / bytesInKiB) != uint64(sizeInKiB) {
return nil, status.Errorf(codes.Unavailable,
"volume exists, but at different size than requested")
}
csiResp := &csi.CreateVolumeResponse{
VolumeInfo: vi,
}
s.clearCache()
return csiResp, nil
}
func (s *service) clearCache() {
s.volCacheRWL.Lock()
defer s.volCacheRWL.Unlock()
s.volCache = make([]*siotypes.Volume, 0)
}
// validateVolSize uses the CapacityRange range params to determine what size
// volume to create, and returns an error if volume size would be greater than
// the given limit. Returned size is in KiB
func validateVolSize(cr *csi.CapacityRange) (int, error) {
minSize := cr.GetRequiredBytes()
maxSize := cr.GetLimitBytes()
if minSize == 0 {
minSize = DefaultVolumeSizeKiB
} else {
minSize = minSize / bytesInKiB
}
var (
sizeGiB uint64
sizeKiB uint64
sizeB uint64
)
// ScaleIO creates volumes in multiples of 8GiB, rounding up.
// Determine what actual size of volume will be, and check that
// we do not exceed maxSize
sizeGiB = minSize / kiBytesInGiB
mod := sizeGiB % VolSizeMultipleGiB
if mod > 0 {
sizeGiB = sizeGiB - mod + VolSizeMultipleGiB
}
sizeB = sizeGiB * bytesInGiB
if maxSize != 0 {
if sizeB > maxSize {
return 0, status.Errorf(
codes.OutOfRange,
"volume size %d > limit_bytes: %d", sizeB, maxSize)
}
}
sizeKiB = sizeGiB * kiBytesInGiB
return int(sizeKiB), nil
}
func (s *service) DeleteVolume(
ctx context.Context,
req *csi.DeleteVolumeRequest) (
*csi.DeleteVolumeResponse, error) {
if err := s.requireProbe(ctx); err != nil {
return nil, err
}
id := req.GetVolumeId()
vol, err := s.getVolByID(id)
if err != nil {
if strings.EqualFold(err.Error(), sioGatewayVolumeNotFound) {
return nil, gocsi.ErrVolumeNotFound(id)
}
return nil, status.Errorf(codes.Internal,
"failure checking volume status before deletion: %s",
err.Error())
}
if len(vol.MappedSdcInfo) > 0 {
// Volume is in use
return nil, status.Errorf(codes.FailedPrecondition,
"volume in use by %s", vol.MappedSdcInfo[0].SdcID)
}
tgtVol := goscaleio.NewVolume(s.adminClient)
tgtVol.Volume = vol
err = tgtVol.RemoveVolume(removeModeOnlyMe)
if err != nil {
return nil, status.Errorf(codes.Internal,
"error removing volume: %s", err.Error())
}
s.clearCache()
return emptyDelResp, nil
}
func (s *service) ControllerPublishVolume(
ctx context.Context,
req *csi.ControllerPublishVolumeRequest) (
*csi.ControllerPublishVolumeResponse, error) {
if err := s.requireProbe(ctx); err != nil {
return nil, err
}
volID := req.GetVolumeId()
if volID == "" {
return nil, gocsi.ErrVolumeIDRequired
}
vol, err := s.getVolByID(volID)
if err != nil {
if strings.EqualFold(err.Error(), sioGatewayVolumeNotFound) {
return nil, gocsi.ErrVolumeNotFound(volID)
}
return nil, status.Errorf(codes.Internal,
"failure checking volume status before controller publish: %s",
err.Error())
}
nodeID := req.GetNodeId()
if nodeID == "" {
return nil, gocsi.ErrNodeIDRequired
}
sdcID, err := s.getSDCID(nodeID)
if err != nil {
return nil, status.Errorf(codes.NotFound, err.Error())
}
vc := req.GetVolumeCapability()
if vc == nil {
return nil, gocsi.ErrVolumeCapabilityRequired
}
am := vc.GetAccessMode()
if am == nil {
return nil, gocsi.ErrAccessModeRequired
}
if am.Mode == csi.VolumeCapability_AccessMode_UNKNOWN {
return nil, status.Error(codes.InvalidArgument,
errUnknownAccessMode)
}
// Check if volume is published to any node already
if len(vol.MappedSdcInfo) > 0 {
vcs := []*csi.VolumeCapability{req.GetVolumeCapability()}
isBlock := accTypeIsBlock(vcs)
for _, sdc := range vol.MappedSdcInfo {
if sdc.SdcID == sdcID {
// volume already mapped
log.Debug("volume already mapped")
return emptyCtrlPubResp, nil
}
}
if !vol.MappingToAllSdcsEnabled {
return nil, status.Error(codes.AlreadyExists,
errNoMultiMap)
}
switch am.Mode {
case csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER:
fallthrough
case csi.VolumeCapability_AccessMode_SINGLE_NODE_READER_ONLY:
return nil, status.Errorf(codes.AlreadyExists,
"volume already published to SDC id: %s", vol.MappedSdcInfo[0].SdcID)
case csi.VolumeCapability_AccessMode_MULTI_NODE_SINGLE_WRITER:
fallthrough
case csi.VolumeCapability_AccessMode_MULTI_NODE_MULTI_WRITER:
return nil, status.Error(codes.InvalidArgument,
errNoMultiNodeWriter)
}
if !isBlock {
// multi-mapping Mount volumes is never allowed
return nil, status.Error(codes.AlreadyExists,
errUnknownAccessMode)
}
}
mapVolumeSdcParam := &siotypes.MapVolumeSdcParam{
SdcID: sdcID,
AllowMultipleMappings: "false",
AllSdcs: "",
}
targetVolume := goscaleio.NewVolume(s.adminClient)
targetVolume.Volume = &siotypes.Volume{ID: vol.ID}
err = targetVolume.MapVolumeSdc(mapVolumeSdcParam)
if err != nil {
return nil, status.Errorf(codes.Internal,
"error mapping volume to node: %s", err.Error())
}
return emptyCtrlPubResp, nil
}
func (s *service) ControllerUnpublishVolume(
ctx context.Context,
req *csi.ControllerUnpublishVolumeRequest) (
*csi.ControllerUnpublishVolumeResponse, error) {
if err := s.requireProbe(ctx); err != nil {
return nil, err
}
volID := req.GetVolumeId()
if volID == "" {
return nil, gocsi.ErrVolumeIDRequired
}
vol, err := s.getVolByID(volID)
if err != nil {
if strings.EqualFold(err.Error(), sioGatewayVolumeNotFound) {
return nil, gocsi.ErrVolumeNotFound(volID)
}
return nil, status.Errorf(codes.Internal,
"failure checking volume status before controller unpublish: %s",
err.Error())
}
nodeID := req.GetNodeId()
if nodeID == "" {
return nil, gocsi.ErrNodeIDRequired
}
sdcID, err := s.getSDCID(nodeID)
if err != nil {
return nil, status.Errorf(codes.NotFound, err.Error())
}
// check if volume is attached to node at all
mappedToNode := false
for _, mapping := range vol.MappedSdcInfo {
if mapping.SdcID == sdcID {
mappedToNode = true
break
}
}
if !mappedToNode {
return emptyCtrlUnpubResp, nil
}
targetVolume := goscaleio.NewVolume(s.adminClient)
targetVolume.Volume = vol
unmapVolumeSdcParam := &siotypes.UnmapVolumeSdcParam{
SdcID: sdcID,
IgnoreScsiInitiators: "true",
AllSdcs: "",
}
if err = targetVolume.UnmapVolumeSdc(unmapVolumeSdcParam); err != nil {
return nil, status.Errorf(codes.Internal,
"error unmapping volume from node: %s", err.Error())
}
return emptyCtrlUnpubResp, nil
}
func (s *service) ValidateVolumeCapabilities(
ctx context.Context,
req *csi.ValidateVolumeCapabilitiesRequest) (
*csi.ValidateVolumeCapabilitiesResponse, error) {
if err := s.requireProbe(ctx); err != nil {
return nil, err
}
volID := req.GetVolumeId()
vol, err := s.getVolByID(volID)
if err != nil {
if strings.EqualFold(err.Error(), sioGatewayVolumeNotFound) {
return nil, gocsi.ErrVolumeNotFound(volID)
}
return nil, status.Errorf(codes.Internal,
"failure checking volume status for capabilities: %s",
err.Error())
}
vcs := req.GetVolumeCapabilities()
supported, reason := valVolumeCaps(vcs, vol)
resp := &csi.ValidateVolumeCapabilitiesResponse{
Supported: supported,
}
if !supported {
resp.Message = reason
}
return resp, nil
}
func accTypeIsBlock(vcs []*csi.VolumeCapability) bool {
for _, vc := range vcs {
if at := vc.GetBlock(); at != nil {
return true
}
}
return false
}
func valVolumeCaps(
vcs []*csi.VolumeCapability,
vol *siotypes.Volume) (bool, string) {
var (
supported = true
isBlock = accTypeIsBlock(vcs)
reason string
)
for _, vc := range vcs {
am := vc.GetAccessMode()
if am == nil {
continue
}
switch am.Mode {
case csi.VolumeCapability_AccessMode_UNKNOWN:
supported = false
reason = errUnknownAccessMode
case csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER:
fallthrough
case csi.VolumeCapability_AccessMode_SINGLE_NODE_READER_ONLY:
break
case csi.VolumeCapability_AccessMode_MULTI_NODE_READER_ONLY:
if !vol.MappingToAllSdcsEnabled {
supported = false
reason = errNoMultiMap
}
case csi.VolumeCapability_AccessMode_MULTI_NODE_SINGLE_WRITER:
fallthrough
case csi.VolumeCapability_AccessMode_MULTI_NODE_MULTI_WRITER:
if !vol.MappingToAllSdcsEnabled {
supported = false
reason = errNoMultiMap
}
if !isBlock {
supported = false
reason = errNoMultiNodeWriter
}
}
}
return supported, reason
}
func (s *service) ListVolumes(
ctx context.Context,
req *csi.ListVolumesRequest) (
*csi.ListVolumesResponse, error) {
if err := s.requireProbe(ctx); err != nil {
return nil, err
}
var (
startToken uint32
cacheLen uint32
)
if v := req.StartingToken; v != "" {
i, err := strconv.ParseUint(v, 10, 32)
if err != nil {
return nil, status.Errorf(
codes.Aborted,
"unable to parse startingToken:%v into uint32",
req.StartingToken)
}
startToken = uint32(i)
}
// Get the length of cached volumes. Do it in a funcion so as not to
// hold the lock
func() {
s.volCacheRWL.RLock()
defer s.volCacheRWL.RUnlock()
cacheLen = uint32(len(s.volCache))
}()
var (
lvols uint32
sioVols []*siotypes.Volume
err error
maxEntries = req.MaxEntries
)
if startToken == 0 || (startToken > 0 && cacheLen == 0) {
// make call to cluster to get all volumes
sioVols, err = s.adminClient.GetVolume("", "", "", "", false)
if err != nil {
return nil, status.Errorf(
codes.Internal,
"unable to list volumes: %s", err.Error())
}
lvols = uint32(len(sioVols))
if maxEntries > 0 && maxEntries < lvols {
// We want to cache this volume list so that we don't
// have to get all the volumes again on the next call
func() {
s.volCacheRWL.Lock()
defer s.volCacheRWL.Unlock()
s.volCache = make([]*siotypes.Volume, lvols)
copy(s.volCache, sioVols)
cacheLen = lvols
}()
}
} else {
lvols = cacheLen
}
if startToken > lvols {
return nil, status.Errorf(
codes.Aborted,
"startingToken=%d > len(vols)=%d",
startToken, lvols)
}
// Discern the number of remaining entries.
rem := lvols - startToken
// If maxEntries is 0 or greater than the number of remaining entries then
// set maxEntries to the number of remaining entries.
if maxEntries == 0 || maxEntries > rem {
maxEntries = rem
}
var (
entries = make(
[]*csi.ListVolumesResponse_Entry,
maxEntries)
source []*siotypes.Volume
)
if startToken == 0 && req.MaxEntries == 0 {
// Use the just populated sioVols
source = sioVols
} else {
// Return only the requested vols from the cache
cacheVols := make([]*siotypes.Volume, maxEntries)
// Copy vols from cache so we don't keep lock entire time
func() {
s.volCacheRWL.RLock()
defer s.volCacheRWL.RUnlock()
j := startToken
for i := 0; i < len(entries); i++ {
cacheVols[i] = s.volCache[i]
j++
}
}()
source = cacheVols
}
for i, vol := range source {
entries[i] = &csi.ListVolumesResponse_Entry{
VolumeInfo: getCSIVolumeInfo(vol),
}
}
var nextToken string
if n := startToken + uint32(len(source)); n < lvols {
nextToken = fmt.Sprintf("%d", n)
}
return &csi.ListVolumesResponse{
Entries: entries,
NextToken: nextToken,
}, nil
}
func (s *service) GetCapacity(
ctx context.Context,
req *csi.GetCapacityRequest) (
*csi.GetCapacityResponse, error) {
if err := s.requireProbe(ctx); err != nil {
return nil, err
}
var statsFunc func() (*siotypes.Statistics, error)
// Default to get Capacity of system
statsFunc = s.system.GetStatistics
params := req.GetParameters()
if len(params) > 0 {
// if storage pool is given, get capacity of storage pool
if spname, ok := params[KeyStoragePool]; ok {
sp, err := s.adminClient.FindStoragePool("", spname, "")
if err != nil {
return nil, status.Errorf(codes.Internal,
"unable to look up storage pool: %s, err: %s",
spname, err.Error())
}
spc := goscaleio.NewStoragePoolEx(s.adminClient, sp)
statsFunc = spc.GetStatistics
}
}
stats, err := statsFunc()
if err != nil {
return nil, status.Errorf(codes.Internal,
"unable to get system stats: %s", err.Error())
}
return &csi.GetCapacityResponse{
AvailableCapacity: uint64(stats.CapacityAvailableForVolumeAllocationInKb) * bytesInKiB,
}, nil
}
func (s *service) ControllerGetCapabilities(
ctx context.Context,
req *csi.ControllerGetCapabilitiesRequest) (
*csi.ControllerGetCapabilitiesResponse, error) {
return &csi.ControllerGetCapabilitiesResponse{
Capabilities: []*csi.ControllerServiceCapability{
&csi.ControllerServiceCapability{
Type: &csi.ControllerServiceCapability_Rpc{
Rpc: &csi.ControllerServiceCapability_RPC{
Type: csi.ControllerServiceCapability_RPC_CREATE_DELETE_VOLUME,
},
},
},
&csi.ControllerServiceCapability{
Type: &csi.ControllerServiceCapability_Rpc{
Rpc: &csi.ControllerServiceCapability_RPC{
Type: csi.ControllerServiceCapability_RPC_PUBLISH_UNPUBLISH_VOLUME,
},
},
},
&csi.ControllerServiceCapability{
Type: &csi.ControllerServiceCapability_Rpc{
Rpc: &csi.ControllerServiceCapability_RPC{
Type: csi.ControllerServiceCapability_RPC_LIST_VOLUMES,
},
},
},
&csi.ControllerServiceCapability{
Type: &csi.ControllerServiceCapability_Rpc{
Rpc: &csi.ControllerServiceCapability_RPC{
Type: csi.ControllerServiceCapability_RPC_GET_CAPACITY,
},
},
},
},
}, nil
}
func (s *service) ControllerProbe(
ctx context.Context,
req *csi.ControllerProbeRequest) (
*csi.ControllerProbeResponse, error) {
// Check that we have the details needed to login to the Gateway
if s.opts.Endpoint == "" {
return nil, status.Error(codes.FailedPrecondition,
"missing ScaleIO Gateway endpoint")
}
if s.opts.User == "" {
return nil, status.Error(codes.FailedPrecondition,
"missing ScaleIO MDM user")
}
if s.opts.Password == "" {
return nil, status.Error(codes.FailedPrecondition,
"missing ScaleIO MDM password")
}
if s.opts.SystemName == "" {
return nil, status.Error(codes.FailedPrecondition,
"missing ScaleIO system name")
}
// Create our ScaleIO API client, if needed
if s.adminClient == nil {
c, err := goscaleio.NewClientWithArgs(
s.opts.Endpoint, "", s.opts.Insecure, true)
if err != nil {
return nil, status.Errorf(codes.FailedPrecondition,
"unable to create ScaleIO client: %s", err.Error())
}
s.adminClient = c
}
if s.adminClient.GetToken() == "" {
_, err := s.adminClient.Authenticate(&goscaleio.ConfigConnect{
Endpoint: s.opts.Endpoint,
Username: s.opts.User,
Password: s.opts.Password,
})
if err != nil {
return nil, status.Errorf(codes.FailedPrecondition,
"unable to login to ScaleIO Gateway: %s", err.Error())
}
}
if s.system == nil {
system, err := s.adminClient.FindSystem(
"", s.opts.SystemName, "")
if err != nil {
return nil, status.Errorf(codes.FailedPrecondition,
"unable to find matching ScaleIO system name: %s",
err.Error())
}
s.system = system
}
return emptyProbeResp, nil
}
func (s *service) requireProbe(ctx context.Context) error {
if s.adminClient == nil {
if !s.opts.AutoProbe {
return status.Error(codes.FailedPrecondition,
"Controller Service has not been probed")
}
log.Debug("probing controller service automatically")
if _, err := s.ControllerProbe(ctx, &csi.ControllerProbeRequest{}); err != nil {
return status.Errorf(codes.FailedPrecondition,
"failed to probe/init plugin: %s", err.Error())
}
}
return nil
}