Skip to content

Commit af26a3a

Browse files
authored
Merge pull request #796 from yussufsh/main
Upgrade github.com/container-storage-interface/spec
2 parents c8a4f6d + e9734d1 commit af26a3a

File tree

8 files changed

+46
-77
lines changed

8 files changed

+46
-77
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ The IBM Power Virtual Systems Container Storage Interface (CSI) Driver provides
88
# CSI Specification Compatibility Matrix
99
| PowerVS CSI Driver | Kubernetes | CSI | Golang |
1010
| ----------------------------- | ----------- | -------- | -------- |
11-
| main | 1.30 | 1.9.0 | 1.22 |
11+
| main | 1.30 | 1.10.0 | 1.22 |
1212
| 0.7.0 | 1.30 | 1.9.0 | 1.22 |
1313
| 0.6.0 | 1.29 | 1.9.0 | 1.21 |
1414
| 0.5.0 | 1.28 | 1.8.0 | 1.20 |

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ require (
66
github.com/IBM-Cloud/power-go-client v1.8.3
77
github.com/IBM/go-sdk-core/v5 v5.18.1
88
github.com/IBM/platform-services-go-sdk v0.71.2
9-
github.com/container-storage-interface/spec v1.9.0
9+
github.com/container-storage-interface/spec v1.10.0
1010
github.com/davecgh/go-spew v1.1.1
1111
github.com/google/go-cmp v0.6.0
1212
github.com/kubernetes-csi/csi-test v2.2.0+incompatible

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK3
2424
github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
2525
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
2626
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
27-
github.com/container-storage-interface/spec v1.9.0 h1:zKtX4STsq31Knz3gciCYCi1SXtO2HJDecIjDVboYavY=
28-
github.com/container-storage-interface/spec v1.9.0/go.mod h1:ZfDu+3ZRyeVqxZM0Ds19MVLkN2d1XJ5MAfi1L3VjlT0=
27+
github.com/container-storage-interface/spec v1.10.0 h1:YkzWPV39x+ZMTa6Ax2czJLLwpryrQ+dPesB34mrRMXA=
28+
github.com/container-storage-interface/spec v1.10.0/go.mod h1:DtUvaQszPml1YJfIK7c00mlv6/g4wNMLanLgiUbKFRI=
2929
github.com/coreos/go-semver v0.3.1 h1:yi21YpKnrx1gt5R+la8n5WgS0kCrsPp33dmEyHReZr4=
3030
github.com/coreos/go-semver v0.3.1/go.mod h1:irMmmIw/7yzSRPWryHsK7EYSg09caPQL03VsM8rvUec=
3131
github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8iXXhfZs=

pkg/driver/controller.go

Lines changed: 25 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -30,31 +30,14 @@ import (
3030
"sigs.k8s.io/ibm-powervs-block-csi-driver/pkg/util"
3131
)
3232

33-
var (
34-
35-
// Supported volume capabilities
36-
volumeCaps = []csi.VolumeCapability_AccessMode{
37-
{
38-
Mode: csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER,
39-
},
40-
{
41-
Mode: csi.VolumeCapability_AccessMode_MULTI_NODE_MULTI_WRITER,
42-
},
43-
{
44-
Mode: csi.VolumeCapability_AccessMode_MULTI_NODE_READER_ONLY,
45-
},
46-
}
47-
48-
// Shareable volume capabilities
49-
shareableVolumeCaps = []csi.VolumeCapability_AccessMode{
50-
{
51-
Mode: csi.VolumeCapability_AccessMode_MULTI_NODE_MULTI_WRITER,
52-
},
53-
{
54-
Mode: csi.VolumeCapability_AccessMode_MULTI_NODE_READER_ONLY,
55-
},
56-
}
33+
// Supported access modes
34+
const (
35+
SingleNodeWriter = csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER
36+
MultiNodeMultiWriter = csi.VolumeCapability_AccessMode_MULTI_NODE_MULTI_WRITER
37+
MultiNodeReaderOnly = csi.VolumeCapability_AccessMode_MULTI_NODE_READER_ONLY
38+
)
5739

40+
var (
5841
// controllerCaps represents the capability of controller service
5942
controllerCaps = []csi.ControllerServiceCapability_RPC_Type{
6043
csi.ControllerServiceCapability_RPC_CREATE_DELETE_VOLUME,
@@ -68,6 +51,7 @@ type controllerService struct {
6851
cloud cloud.Cloud
6952
driverOptions *Options
7053
volumeLocks *util.VolumeLocks
54+
csi.UnimplementedControllerServer
7155
}
7256

7357
// Provider holds information from the cloud provider.
@@ -142,7 +126,7 @@ func newControllerService(driverOptions *Options) controllerService {
142126
}
143127

144128
func (d *controllerService) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest) (*csi.CreateVolumeResponse, error) {
145-
klog.V(4).Infof("CreateVolume: called with args %+v", *req)
129+
klog.V(4).Infof("CreateVolume: called with args %+v", req)
146130
volName := req.GetName()
147131
if len(volName) == 0 {
148132
return nil, status.Error(codes.InvalidArgument, "Volume name not provided")
@@ -212,7 +196,7 @@ func (d *controllerService) CreateVolume(ctx context.Context, req *csi.CreateVol
212196
}
213197

214198
func (d *controllerService) DeleteVolume(ctx context.Context, req *csi.DeleteVolumeRequest) (*csi.DeleteVolumeResponse, error) {
215-
klog.V(4).Infof("DeleteVolume: called with args: %+v", *req)
199+
klog.V(4).Infof("DeleteVolume: called with args: %+v", req)
216200
volumeID := req.GetVolumeId()
217201
if len(volumeID) == 0 {
218202
return nil, status.Error(codes.InvalidArgument, "Volume ID not provided")
@@ -238,7 +222,7 @@ func (d *controllerService) DeleteVolume(ctx context.Context, req *csi.DeleteVol
238222
}
239223

240224
func (d *controllerService) ControllerPublishVolume(ctx context.Context, req *csi.ControllerPublishVolumeRequest) (*csi.ControllerPublishVolumeResponse, error) {
241-
klog.V(4).Infof("ControllerPublishVolume: called with args %+v", *req)
225+
klog.V(4).Infof("ControllerPublishVolume: called with args %+v", req)
242226
volumeID := req.GetVolumeId()
243227
if len(volumeID) == 0 {
244228
return nil, status.Error(codes.InvalidArgument, "Volume ID not provided")
@@ -300,7 +284,7 @@ func (d *controllerService) ControllerPublishVolume(ctx context.Context, req *cs
300284
}
301285

302286
func (d *controllerService) ControllerUnpublishVolume(ctx context.Context, req *csi.ControllerUnpublishVolumeRequest) (*csi.ControllerUnpublishVolumeResponse, error) {
303-
klog.V(4).Infof("ControllerUnpublishVolume: called with args %+v", *req)
287+
klog.V(4).Infof("ControllerUnpublishVolume: called with args %+v", req)
304288
volumeID := req.GetVolumeId()
305289
if len(volumeID) == 0 {
306290
return nil, status.Error(codes.InvalidArgument, "Volume ID not provided")
@@ -337,7 +321,7 @@ func (d *controllerService) ControllerUnpublishVolume(ctx context.Context, req *
337321
}
338322

339323
func (d *controllerService) ControllerGetCapabilities(ctx context.Context, req *csi.ControllerGetCapabilitiesRequest) (*csi.ControllerGetCapabilitiesResponse, error) {
340-
klog.V(4).Infof("ControllerGetCapabilities: called with args %+v", *req)
324+
klog.V(4).Infof("ControllerGetCapabilities: called with args %+v", req)
341325
var caps []*csi.ControllerServiceCapability
342326
for _, cap := range controllerCaps {
343327
c := &csi.ControllerServiceCapability{
@@ -353,17 +337,17 @@ func (d *controllerService) ControllerGetCapabilities(ctx context.Context, req *
353337
}
354338

355339
func (d *controllerService) GetCapacity(ctx context.Context, req *csi.GetCapacityRequest) (*csi.GetCapacityResponse, error) {
356-
klog.V(4).Infof("GetCapacity: called with args %+v", *req)
340+
klog.V(4).Infof("GetCapacity: called with args %+v", req)
357341
return nil, status.Error(codes.Unimplemented, "")
358342
}
359343

360344
func (d *controllerService) ListVolumes(ctx context.Context, req *csi.ListVolumesRequest) (*csi.ListVolumesResponse, error) {
361-
klog.V(4).Infof("ListVolumes: called with args %+v", *req)
345+
klog.V(4).Infof("ListVolumes: called with args %+v", req)
362346
return nil, status.Error(codes.Unimplemented, "")
363347
}
364348

365349
func (d *controllerService) ValidateVolumeCapabilities(ctx context.Context, req *csi.ValidateVolumeCapabilitiesRequest) (*csi.ValidateVolumeCapabilitiesResponse, error) {
366-
klog.V(4).Infof("ValidateVolumeCapabilities: called with args %+v", *req)
350+
klog.V(4).Infof("ValidateVolumeCapabilities: called with args %+v", req)
367351
volumeID := req.GetVolumeId()
368352
if len(volumeID) == 0 {
369353
return nil, status.Error(codes.InvalidArgument, "Volume ID not provided")
@@ -391,7 +375,7 @@ func (d *controllerService) ValidateVolumeCapabilities(ctx context.Context, req
391375
}
392376

393377
func (d *controllerService) ControllerExpandVolume(ctx context.Context, req *csi.ControllerExpandVolumeRequest) (*csi.ControllerExpandVolumeResponse, error) {
394-
klog.V(4).Infof("ControllerExpandVolume: called with args %+v", *req)
378+
klog.V(4).Infof("ControllerExpandVolume: called with args %+v", req)
395379
volumeID := req.GetVolumeId()
396380
if len(volumeID) == 0 {
397381
return nil, status.Error(codes.InvalidArgument, "Volume ID not provided")
@@ -425,47 +409,30 @@ func (d *controllerService) ControllerExpandVolume(ctx context.Context, req *csi
425409
}
426410

427411
func (d *controllerService) ControllerGetVolume(ctx context.Context, req *csi.ControllerGetVolumeRequest) (*csi.ControllerGetVolumeResponse, error) {
428-
klog.V(4).Infof("ControllerGetVolume: called with args %+v", *req)
412+
klog.V(4).Infof("ControllerGetVolume: called with args %+v", req)
429413
return nil, status.Error(codes.Unimplemented, "")
430414
}
431415

432416
func (d *controllerService) ControllerModifyVolume(ctx context.Context, req *csi.ControllerModifyVolumeRequest) (*csi.ControllerModifyVolumeResponse, error) {
433-
klog.V(4).InfoS("ControllerModifyVolume: called with args %+v", *req)
417+
klog.V(4).InfoS("ControllerModifyVolume: called with args %+v", req)
434418
return nil, status.Error(codes.Unimplemented, "")
435419
}
436420

437421
func isValidVolumeCapabilities(volCaps []*csi.VolumeCapability) bool {
438-
hasSupport := func(cap *csi.VolumeCapability) bool {
439-
for _, c := range volumeCaps {
440-
if c.GetMode() == cap.AccessMode.GetMode() {
441-
return true
442-
}
443-
}
444-
return false
445-
}
446-
447-
foundAll := true
448422
for _, c := range volCaps {
449-
if !hasSupport(c) {
450-
foundAll = false
423+
mode := c.AccessMode.GetMode()
424+
if mode != SingleNodeWriter && mode != MultiNodeMultiWriter && mode != MultiNodeReaderOnly {
425+
return false
451426
}
452427
}
453-
return foundAll
428+
return true
454429
}
455430

456431
// Check if the volume is shareable
457432
func isShareableVolume(volCaps []*csi.VolumeCapability) bool {
458-
isShareable := func(cap *csi.VolumeCapability) bool {
459-
for _, c := range shareableVolumeCaps {
460-
if c.GetMode() == cap.AccessMode.GetMode() {
461-
return true
462-
}
463-
}
464-
return false
465-
}
466-
467433
for _, c := range volCaps {
468-
if isShareable(c) {
434+
mode := c.AccessMode.GetMode()
435+
if mode == MultiNodeMultiWriter || mode == MultiNodeReaderOnly {
469436
return true
470437
}
471438
}

pkg/driver/driver.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ const (
5151
type Driver struct {
5252
controllerService
5353
nodeService
54+
csi.UnimplementedIdentityServer
5455

5556
srv *grpc.Server
5657
options *Options

pkg/driver/identity.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
)
2525

2626
func (d *Driver) GetPluginInfo(ctx context.Context, req *csi.GetPluginInfoRequest) (*csi.GetPluginInfoResponse, error) {
27-
klog.V(6).Infof("GetPluginInfo: called with args %+v", *req)
27+
klog.V(6).Infof("GetPluginInfo: called with args %+v", req)
2828
resp := &csi.GetPluginInfoResponse{
2929
Name: DriverName,
3030
VendorVersion: driverVersion,
@@ -34,7 +34,7 @@ func (d *Driver) GetPluginInfo(ctx context.Context, req *csi.GetPluginInfoReques
3434
}
3535

3636
func (d *Driver) GetPluginCapabilities(ctx context.Context, req *csi.GetPluginCapabilitiesRequest) (*csi.GetPluginCapabilitiesResponse, error) {
37-
klog.V(6).Infof("GetPluginCapabilities: called with args %+v", *req)
37+
klog.V(6).Infof("GetPluginCapabilities: called with args %+v", req)
3838
resp := &csi.GetPluginCapabilitiesResponse{
3939
Capabilities: []*csi.PluginCapability{
4040
{
@@ -58,6 +58,6 @@ func (d *Driver) GetPluginCapabilities(ctx context.Context, req *csi.GetPluginCa
5858
}
5959

6060
func (d *Driver) Probe(ctx context.Context, req *csi.ProbeRequest) (*csi.ProbeResponse, error) {
61-
klog.V(6).Infof("Probe: called with args %+v", *req)
61+
klog.V(6).Infof("Probe: called with args %+v", req)
6262
return &csi.ProbeResponse{}, nil
6363
}

pkg/driver/node.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ type nodeService struct {
7070
pvmInstanceId string
7171
volumeLocks *util.VolumeLocks
7272
stats StatsUtils
73+
csi.UnimplementedNodeServer
7374
}
7475

7576
// newNodeService creates a new node service
@@ -112,7 +113,7 @@ func newNodeService(driverOptions *Options) nodeService {
112113
}
113114

114115
func (d *nodeService) NodeStageVolume(ctx context.Context, req *csi.NodeStageVolumeRequest) (*csi.NodeStageVolumeResponse, error) {
115-
klog.V(4).Infof("NodeStageVolume: called with args %+v", *req)
116+
klog.V(4).Infof("NodeStageVolume: called with args %+v", req)
116117

117118
volumeID := req.GetVolumeId()
118119
if len(volumeID) == 0 {
@@ -253,7 +254,7 @@ func (d *nodeService) stageVolume(wwn string, req *csi.NodeStageVolumeRequest) e
253254
}
254255

255256
func (d *nodeService) NodeUnstageVolume(ctx context.Context, req *csi.NodeUnstageVolumeRequest) (*csi.NodeUnstageVolumeResponse, error) {
256-
klog.V(4).Infof("NodeUnstageVolume: called with args %+v", *req)
257+
klog.V(4).Infof("NodeUnstageVolume: called with args %+v", req)
257258

258259
volumeID := req.GetVolumeId()
259260
if len(volumeID) == 0 {
@@ -341,7 +342,7 @@ func (d *nodeService) deleteDevice(deviceName string) error {
341342
}
342343

343344
func (d *nodeService) NodeExpandVolume(ctx context.Context, req *csi.NodeExpandVolumeRequest) (*csi.NodeExpandVolumeResponse, error) {
344-
klog.V(4).Infof("NodeExpandVolume: called with args %+v", *req)
345+
klog.V(4).Infof("NodeExpandVolume: called with args %+v", req)
345346

346347
volumeID := req.GetVolumeId()
347348
if len(volumeID) == 0 {
@@ -412,7 +413,7 @@ func (d *nodeService) NodeExpandVolume(ctx context.Context, req *csi.NodeExpandV
412413
}
413414

414415
func (d *nodeService) NodePublishVolume(ctx context.Context, req *csi.NodePublishVolumeRequest) (*csi.NodePublishVolumeResponse, error) {
415-
klog.V(4).Infof("NodePublishVolume: called with args %+v", *req)
416+
klog.V(4).Infof("NodePublishVolume: called with args %+v", req)
416417
volumeID := req.GetVolumeId()
417418
if len(volumeID) == 0 {
418419
return nil, status.Error(codes.InvalidArgument, "Volume ID not provided")
@@ -468,7 +469,7 @@ func (d *nodeService) NodePublishVolume(ctx context.Context, req *csi.NodePublis
468469
}
469470

470471
func (d *nodeService) NodeUnpublishVolume(ctx context.Context, req *csi.NodeUnpublishVolumeRequest) (*csi.NodeUnpublishVolumeResponse, error) {
471-
klog.V(4).Infof("NodeUnpublishVolume: called with args %+v", *req)
472+
klog.V(4).Infof("NodeUnpublishVolume: called with args %+v", req)
472473
volumeID := req.GetVolumeId()
473474
if len(volumeID) == 0 {
474475
return nil, status.Error(codes.InvalidArgument, "Volume ID not provided")
@@ -498,7 +499,7 @@ func (d *nodeService) NodeUnpublishVolume(ctx context.Context, req *csi.NodeUnpu
498499
func (d *nodeService) NodeGetVolumeStats(ctx context.Context, req *csi.NodeGetVolumeStatsRequest) (*csi.NodeGetVolumeStatsResponse, error) {
499500
var resp *csi.NodeGetVolumeStatsResponse
500501
if req != nil {
501-
klog.V(4).Infof("NodeGetVolumeStats: called with args %+v", *req)
502+
klog.V(4).Infof("NodeGetVolumeStats: called with args %+v", req)
502503
}
503504

504505
if req == nil || req.VolumeId == "" {
@@ -567,7 +568,7 @@ func (d *nodeService) NodeGetVolumeStats(ctx context.Context, req *csi.NodeGetVo
567568
}
568569

569570
func (d *nodeService) NodeGetCapabilities(ctx context.Context, req *csi.NodeGetCapabilitiesRequest) (*csi.NodeGetCapabilitiesResponse, error) {
570-
klog.V(4).Infof("NodeGetCapabilities: called with args %+v", *req)
571+
klog.V(4).Infof("NodeGetCapabilities: called with args %+v", req)
571572
var caps []*csi.NodeServiceCapability
572573
for _, cap := range nodeCaps {
573574
c := &csi.NodeServiceCapability{
@@ -583,7 +584,7 @@ func (d *nodeService) NodeGetCapabilities(ctx context.Context, req *csi.NodeGetC
583584
}
584585

585586
func (d *nodeService) NodeGetInfo(ctx context.Context, req *csi.NodeGetInfoRequest) (*csi.NodeGetInfoResponse, error) {
586-
klog.V(4).Infof("NodeGetInfo: called with args %+v", *req)
587+
klog.V(4).Infof("NodeGetInfo: called with args %+v", req)
587588

588589
in, err := d.cloud.GetPVMInstanceByID(d.pvmInstanceId)
589590
if err != nil {

pkg/driver/node_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -551,19 +551,19 @@ func TestNodeExpandVolume(t *testing.T) {
551551

552552
tests := []struct {
553553
name string
554-
request csi.NodeExpandVolumeRequest
554+
request *csi.NodeExpandVolumeRequest
555555
expectResponseCode codes.Code
556556
expectMock func(mockMounter mocks.MockMounter)
557557
volumeLock bool
558558
}{
559559
{
560560
name: "fail missing volumeId",
561-
request: csi.NodeExpandVolumeRequest{},
561+
request: &csi.NodeExpandVolumeRequest{},
562562
expectResponseCode: codes.InvalidArgument,
563563
},
564564
{
565565
name: "fail if volume already locked",
566-
request: csi.NodeExpandVolumeRequest{
566+
request: &csi.NodeExpandVolumeRequest{
567567
VolumeId: "test-volume-id",
568568
},
569569
expectResponseCode: codes.InvalidArgument,
@@ -581,7 +581,7 @@ func TestNodeExpandVolume(t *testing.T) {
581581
powervsDriver.volumeLocks.TryAcquire(test.request.VolumeId)
582582
defer powervsDriver.volumeLocks.Release(test.request.VolumeId)
583583
}
584-
_, err := powervsDriver.NodeExpandVolume(context.Background(), &test.request)
584+
_, err := powervsDriver.NodeExpandVolume(context.Background(), test.request)
585585
if err != nil {
586586
if test.expectResponseCode != codes.OK {
587587
expectErr(t, err, test.expectResponseCode)

0 commit comments

Comments
 (0)