Skip to content

Commit

Permalink
Merge pull request #796 from yussufsh/main
Browse files Browse the repository at this point in the history
Upgrade github.com/container-storage-interface/spec
  • Loading branch information
k8s-ci-robot authored Dec 14, 2024
2 parents c8a4f6d + e9734d1 commit af26a3a
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 77 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ The IBM Power Virtual Systems Container Storage Interface (CSI) Driver provides
# CSI Specification Compatibility Matrix
| PowerVS CSI Driver | Kubernetes | CSI | Golang |
| ----------------------------- | ----------- | -------- | -------- |
| main | 1.30 | 1.9.0 | 1.22 |
| main | 1.30 | 1.10.0 | 1.22 |
| 0.7.0 | 1.30 | 1.9.0 | 1.22 |
| 0.6.0 | 1.29 | 1.9.0 | 1.21 |
| 0.5.0 | 1.28 | 1.8.0 | 1.20 |
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/IBM-Cloud/power-go-client v1.8.3
github.com/IBM/go-sdk-core/v5 v5.18.1
github.com/IBM/platform-services-go-sdk v0.71.2
github.com/container-storage-interface/spec v1.9.0
github.com/container-storage-interface/spec v1.10.0
github.com/davecgh/go-spew v1.1.1
github.com/google/go-cmp v0.6.0
github.com/kubernetes-csi/csi-test v2.2.0+incompatible
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK3
github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/container-storage-interface/spec v1.9.0 h1:zKtX4STsq31Knz3gciCYCi1SXtO2HJDecIjDVboYavY=
github.com/container-storage-interface/spec v1.9.0/go.mod h1:ZfDu+3ZRyeVqxZM0Ds19MVLkN2d1XJ5MAfi1L3VjlT0=
github.com/container-storage-interface/spec v1.10.0 h1:YkzWPV39x+ZMTa6Ax2czJLLwpryrQ+dPesB34mrRMXA=
github.com/container-storage-interface/spec v1.10.0/go.mod h1:DtUvaQszPml1YJfIK7c00mlv6/g4wNMLanLgiUbKFRI=
github.com/coreos/go-semver v0.3.1 h1:yi21YpKnrx1gt5R+la8n5WgS0kCrsPp33dmEyHReZr4=
github.com/coreos/go-semver v0.3.1/go.mod h1:irMmmIw/7yzSRPWryHsK7EYSg09caPQL03VsM8rvUec=
github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8iXXhfZs=
Expand Down
83 changes: 25 additions & 58 deletions pkg/driver/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,31 +30,14 @@ import (
"sigs.k8s.io/ibm-powervs-block-csi-driver/pkg/util"
)

var (

// Supported volume capabilities
volumeCaps = []csi.VolumeCapability_AccessMode{
{
Mode: csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER,
},
{
Mode: csi.VolumeCapability_AccessMode_MULTI_NODE_MULTI_WRITER,
},
{
Mode: csi.VolumeCapability_AccessMode_MULTI_NODE_READER_ONLY,
},
}

// Shareable volume capabilities
shareableVolumeCaps = []csi.VolumeCapability_AccessMode{
{
Mode: csi.VolumeCapability_AccessMode_MULTI_NODE_MULTI_WRITER,
},
{
Mode: csi.VolumeCapability_AccessMode_MULTI_NODE_READER_ONLY,
},
}
// Supported access modes
const (
SingleNodeWriter = csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER
MultiNodeMultiWriter = csi.VolumeCapability_AccessMode_MULTI_NODE_MULTI_WRITER
MultiNodeReaderOnly = csi.VolumeCapability_AccessMode_MULTI_NODE_READER_ONLY
)

var (
// controllerCaps represents the capability of controller service
controllerCaps = []csi.ControllerServiceCapability_RPC_Type{
csi.ControllerServiceCapability_RPC_CREATE_DELETE_VOLUME,
Expand All @@ -68,6 +51,7 @@ type controllerService struct {
cloud cloud.Cloud
driverOptions *Options
volumeLocks *util.VolumeLocks
csi.UnimplementedControllerServer
}

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

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

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

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

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

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

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

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

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

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

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

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

func isValidVolumeCapabilities(volCaps []*csi.VolumeCapability) bool {
hasSupport := func(cap *csi.VolumeCapability) bool {
for _, c := range volumeCaps {
if c.GetMode() == cap.AccessMode.GetMode() {
return true
}
}
return false
}

foundAll := true
for _, c := range volCaps {
if !hasSupport(c) {
foundAll = false
mode := c.AccessMode.GetMode()
if mode != SingleNodeWriter && mode != MultiNodeMultiWriter && mode != MultiNodeReaderOnly {
return false
}
}
return foundAll
return true
}

// Check if the volume is shareable
func isShareableVolume(volCaps []*csi.VolumeCapability) bool {
isShareable := func(cap *csi.VolumeCapability) bool {
for _, c := range shareableVolumeCaps {
if c.GetMode() == cap.AccessMode.GetMode() {
return true
}
}
return false
}

for _, c := range volCaps {
if isShareable(c) {
mode := c.AccessMode.GetMode()
if mode == MultiNodeMultiWriter || mode == MultiNodeReaderOnly {
return true
}
}
Expand Down
1 change: 1 addition & 0 deletions pkg/driver/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ const (
type Driver struct {
controllerService
nodeService
csi.UnimplementedIdentityServer

srv *grpc.Server
options *Options
Expand Down
6 changes: 3 additions & 3 deletions pkg/driver/identity.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
)

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

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

func (d *Driver) Probe(ctx context.Context, req *csi.ProbeRequest) (*csi.ProbeResponse, error) {
klog.V(6).Infof("Probe: called with args %+v", *req)
klog.V(6).Infof("Probe: called with args %+v", req)
return &csi.ProbeResponse{}, nil
}
17 changes: 9 additions & 8 deletions pkg/driver/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ type nodeService struct {
pvmInstanceId string
volumeLocks *util.VolumeLocks
stats StatsUtils
csi.UnimplementedNodeServer
}

// newNodeService creates a new node service
Expand Down Expand Up @@ -112,7 +113,7 @@ func newNodeService(driverOptions *Options) nodeService {
}

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

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

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

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

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

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

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

func (d *nodeService) NodeUnpublishVolume(ctx context.Context, req *csi.NodeUnpublishVolumeRequest) (*csi.NodeUnpublishVolumeResponse, error) {
klog.V(4).Infof("NodeUnpublishVolume: called with args %+v", *req)
klog.V(4).Infof("NodeUnpublishVolume: called with args %+v", req)
volumeID := req.GetVolumeId()
if len(volumeID) == 0 {
return nil, status.Error(codes.InvalidArgument, "Volume ID not provided")
Expand Down Expand Up @@ -498,7 +499,7 @@ func (d *nodeService) NodeUnpublishVolume(ctx context.Context, req *csi.NodeUnpu
func (d *nodeService) NodeGetVolumeStats(ctx context.Context, req *csi.NodeGetVolumeStatsRequest) (*csi.NodeGetVolumeStatsResponse, error) {
var resp *csi.NodeGetVolumeStatsResponse
if req != nil {
klog.V(4).Infof("NodeGetVolumeStats: called with args %+v", *req)
klog.V(4).Infof("NodeGetVolumeStats: called with args %+v", req)
}

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

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

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

in, err := d.cloud.GetPVMInstanceByID(d.pvmInstanceId)
if err != nil {
Expand Down
8 changes: 4 additions & 4 deletions pkg/driver/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -551,19 +551,19 @@ func TestNodeExpandVolume(t *testing.T) {

tests := []struct {
name string
request csi.NodeExpandVolumeRequest
request *csi.NodeExpandVolumeRequest
expectResponseCode codes.Code
expectMock func(mockMounter mocks.MockMounter)
volumeLock bool
}{
{
name: "fail missing volumeId",
request: csi.NodeExpandVolumeRequest{},
request: &csi.NodeExpandVolumeRequest{},
expectResponseCode: codes.InvalidArgument,
},
{
name: "fail if volume already locked",
request: csi.NodeExpandVolumeRequest{
request: &csi.NodeExpandVolumeRequest{
VolumeId: "test-volume-id",
},
expectResponseCode: codes.InvalidArgument,
Expand All @@ -581,7 +581,7 @@ func TestNodeExpandVolume(t *testing.T) {
powervsDriver.volumeLocks.TryAcquire(test.request.VolumeId)
defer powervsDriver.volumeLocks.Release(test.request.VolumeId)
}
_, err := powervsDriver.NodeExpandVolume(context.Background(), &test.request)
_, err := powervsDriver.NodeExpandVolume(context.Background(), test.request)
if err != nil {
if test.expectResponseCode != codes.OK {
expectErr(t, err, test.expectResponseCode)
Expand Down

0 comments on commit af26a3a

Please sign in to comment.