Skip to content

Commit 499bc30

Browse files
authored
Update CSI spec dependency (#3511)
Signed-off-by: Deepak Kinni <[email protected]>
1 parent fe40ed4 commit 499bc30

File tree

11 files changed

+94
-88
lines changed

11 files changed

+94
-88
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ toolchain go1.24.2
77
require (
88
github.com/agiledragon/gomonkey/v2 v2.13.0
99
github.com/akutz/gofsutil v0.1.2
10-
github.com/container-storage-interface/spec v1.9.0
10+
github.com/container-storage-interface/spec v1.11.0
1111
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc
1212
github.com/evanphx/json-patch/v5 v5.9.0
1313
github.com/fsnotify/fsnotify v1.7.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UF
3232
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
3333
github.com/chai2010/gettext-go v1.0.2 h1:1Lwwip6Q2QGsAdl/ZKPCwTe9fe0CjlUbqj5bFNSjIRk=
3434
github.com/chai2010/gettext-go v1.0.2/go.mod h1:y+wnP2cHYaVj19NZhYKAwEMH2CI1gNHeQQ+5AjwawxA=
35-
github.com/container-storage-interface/spec v1.9.0 h1:zKtX4STsq31Knz3gciCYCi1SXtO2HJDecIjDVboYavY=
36-
github.com/container-storage-interface/spec v1.9.0/go.mod h1:ZfDu+3ZRyeVqxZM0Ds19MVLkN2d1XJ5MAfi1L3VjlT0=
35+
github.com/container-storage-interface/spec v1.11.0 h1:H/YKTOeUZwHtyPOr9raR+HgFmGluGCklulxDYxSdVNM=
36+
github.com/container-storage-interface/spec v1.11.0/go.mod h1:DtUvaQszPml1YJfIK7c00mlv6/g4wNMLanLgiUbKFRI=
3737
github.com/containerd/containerd/api v1.8.0 h1:hVTNJKR8fMc/2Tiw60ZRijntNMd1U+JVMyTRdsD2bS0=
3838
github.com/containerd/containerd/api v1.8.0/go.mod h1:dFv4lt6S20wTu/hMcP4350RL87qPWLVa/OHOwmmdnYc=
3939
github.com/containerd/errdefs v1.0.0 h1:tg5yIfIlQIrxYtu9ajqY42W3lpS19XqdxRQeEwYG8PI=

pkg/csi/service/common/types.go

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,27 +30,19 @@ var (
3030
// BlockVolumeCaps represents how the block volume could be accessed.
3131
// CNS block volumes support only SINGLE_NODE_WRITER where the volume is
3232
// attached to a single node at any given time.
33-
BlockVolumeCaps = []csi.VolumeCapability_AccessMode{
34-
{
35-
Mode: csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER,
36-
},
33+
BlockVolumeCaps = []csi.VolumeCapability_AccessMode_Mode{
34+
csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER,
3735
}
3836

3937
// MultiNodeVolumeCaps represents how the file volume or shared raw block volume
4038
// could be accessed.
4139
// CNS file volumes or shared raw block volumes support
4240
// MULTI_NODE_READER_ONLY, MULTI_NODE_SINGLE_WRITER
4341
// and MULTI_NODE_MULTI_WRITER
44-
MultiNodeVolumeCaps = []csi.VolumeCapability_AccessMode{
45-
{
46-
Mode: csi.VolumeCapability_AccessMode_MULTI_NODE_READER_ONLY,
47-
},
48-
{
49-
Mode: csi.VolumeCapability_AccessMode_MULTI_NODE_SINGLE_WRITER,
50-
},
51-
{
52-
Mode: csi.VolumeCapability_AccessMode_MULTI_NODE_MULTI_WRITER,
53-
},
42+
MultiNodeVolumeCaps = []csi.VolumeCapability_AccessMode_Mode{
43+
csi.VolumeCapability_AccessMode_MULTI_NODE_READER_ONLY,
44+
csi.VolumeCapability_AccessMode_MULTI_NODE_SINGLE_WRITER,
45+
csi.VolumeCapability_AccessMode_MULTI_NODE_MULTI_WRITER,
5446
}
5547

5648
// ErrNotFound represents not found error

pkg/csi/service/common/util.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,12 +185,12 @@ func IsVolumeReadOnly(capability *csi.VolumeCapability) bool {
185185
// validateVolumeCapabilities validates the access mode in given volume
186186
// capabilities in validAccessModes.
187187
func validateVolumeCapabilities(volCaps []*csi.VolumeCapability,
188-
validAccessModes []csi.VolumeCapability_AccessMode, volumeType string) error {
188+
validAccessModes []csi.VolumeCapability_AccessMode_Mode, volumeType string) error {
189189
// Validate if all capabilities of the volume are supported.
190190
for _, volCap := range volCaps {
191191
found := false
192192
for _, validAccessMode := range validAccessModes {
193-
if volCap.AccessMode.GetMode() == validAccessMode.GetMode() {
193+
if volCap.AccessMode.GetMode() == validAccessMode {
194194
found = true
195195
break
196196
}

pkg/csi/service/driver.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ type vsphereCSIDriver struct {
6767
// A map storing all volumes with ongoing operations so that additional operations
6868
// for that same volume (as defined by VolumeID) return an Aborted error
6969
volumeLocks *node.VolumeLocks
70+
csi.UnimplementedNodeServer
71+
csi.UnimplementedIdentityServer
7072
}
7173

7274
// If k8s node died unexpectedly in an earlier run, the unix socket is left

pkg/csi/service/node.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func (driver *vsphereCSIDriver) NodeStageVolume(
5151
*csi.NodeStageVolumeResponse, error) {
5252
ctx = logger.NewContextWithLogger(ctx)
5353
log := logger.GetLogger(ctx)
54-
log.Infof("NodeStageVolume: called with args %+v", *req)
54+
log.Infof("NodeStageVolume: called with args %+v", req)
5555

5656
volumeID := req.GetVolumeId()
5757
volCap := req.GetVolumeCapability()
@@ -112,7 +112,7 @@ func (driver *vsphereCSIDriver) NodeUnstageVolume(
112112
*csi.NodeUnstageVolumeResponse, error) {
113113
ctx = logger.NewContextWithLogger(ctx)
114114
log := logger.GetLogger(ctx)
115-
log.Infof("NodeUnstageVolume: called with args %+v", *req)
115+
log.Infof("NodeUnstageVolume: called with args %+v", req)
116116

117117
// Validate arguments
118118
volumeID := req.GetVolumeId()
@@ -177,7 +177,7 @@ func (driver *vsphereCSIDriver) NodePublishVolume(
177177
*csi.NodePublishVolumeResponse, error) {
178178
ctx = logger.NewContextWithLogger(ctx)
179179
log := logger.GetLogger(ctx)
180-
log.Infof("NodePublishVolume: called with args %+v", *req)
180+
log.Infof("NodePublishVolume: called with args %+v", req)
181181
var err error
182182
volumeID := req.GetVolumeId()
183183
if len(volumeID) == 0 {
@@ -245,7 +245,7 @@ func (driver *vsphereCSIDriver) NodeUnpublishVolume(
245245
*csi.NodeUnpublishVolumeResponse, error) {
246246
ctx = logger.NewContextWithLogger(ctx)
247247
log := logger.GetLogger(ctx)
248-
log.Infof("NodeUnpublishVolume: called with args %+v", *req)
248+
log.Infof("NodeUnpublishVolume: called with args %+v", req)
249249

250250
volID := req.GetVolumeId()
251251
target := req.GetTargetPath()
@@ -275,7 +275,7 @@ func (driver *vsphereCSIDriver) NodeGetVolumeStats(
275275
*csi.NodeGetVolumeStatsResponse, error) {
276276
ctx = logger.NewContextWithLogger(ctx)
277277
log := logger.GetLogger(ctx)
278-
log.Infof("NodeGetVolumeStats: called with args %+v", *req)
278+
log.Infof("NodeGetVolumeStats: called with args %+v", req)
279279

280280
var err error
281281
targetPath := req.GetVolumePath()
@@ -377,7 +377,7 @@ func (driver *vsphereCSIDriver) NodeGetInfo(
377377
*csi.NodeGetInfoResponse, error) {
378378
ctx = logger.NewContextWithLogger(ctx)
379379
log := logger.GetLogger(ctx)
380-
log.Infof("NodeGetInfo: called with args %+v", *req)
380+
log.Infof("NodeGetInfo: called with args %+v", req)
381381

382382
driver.osUtils.ShouldContinue(ctx)
383383

@@ -508,7 +508,7 @@ func (driver *vsphereCSIDriver) NodeExpandVolume(
508508
*csi.NodeExpandVolumeResponse, error) {
509509
ctx = logger.NewContextWithLogger(ctx)
510510
log := logger.GetLogger(ctx)
511-
log.Infof("NodeExpandVolume: called with args %+v", *req)
511+
log.Infof("NodeExpandVolume: called with args %+v", req)
512512

513513
volumeID := req.GetVolumeId()
514514
if len(volumeID) == 0 {

pkg/csi/service/vanilla/controller.go

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ type controller struct {
7979
authMgr common.AuthorizationService
8080
authMgrs map[string]*common.AuthManager
8181
topologyMgr commoncotypes.ControllerTopologyService
82+
csi.UnimplementedControllerServer
8283
}
8384

8485
var (
@@ -2005,7 +2006,7 @@ func (c *controller) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequ
20052006
volumeType := prometheus.PrometheusUnknownVolumeType
20062007
createVolumeInternal := func() (
20072008
*csi.CreateVolumeResponse, string, error) {
2008-
log.Infof("CreateVolume: called with args %+v", *req)
2009+
log.Infof("CreateVolume: called with args %+v", req)
20092010
// TODO: If the err is returned by invoking CNS API, then faultType should be
20102011
// populated by the underlying layer.
20112012
// If the request failed due to validate the request, "csi.fault.InvalidArgument" will be return.
@@ -2098,7 +2099,7 @@ func (c *controller) DeleteVolume(ctx context.Context, req *csi.DeleteVolumeRequ
20982099

20992100
deleteVolumeInternal := func() (
21002101
*csi.DeleteVolumeResponse, string, error) {
2101-
log.Infof("DeleteVolume: called with args: %+v", *req)
2102+
log.Infof("DeleteVolume: called with args: %+v", req)
21022103
// TODO: If the err is returned by invoking CNS API, then faultType should be
21032104
// populated by the underlying layer.
21042105
// If the request failed due to validate the request, "csi.fault.InvalidArgument" will be return.
@@ -2241,7 +2242,7 @@ func (c *controller) ControllerPublishVolume(ctx context.Context, req *csi.Contr
22412242

22422243
controllerPublishVolumeInternal := func() (
22432244
*csi.ControllerPublishVolumeResponse, string, error) {
2244-
log.Infof("ControllerPublishVolume: called with args %+v", *req)
2245+
log.Infof("ControllerPublishVolume: called with args %+v", req)
22452246
// TODO: If the err is returned by invoking CNS API, then faultType should be
22462247
// populated by the underlying layer.
22472248
// If the request failed due to validate the request, "csi.fault.InvalidArgument" will be return.
@@ -2252,7 +2253,7 @@ func (c *controller) ControllerPublishVolume(ctx context.Context, req *csi.Contr
22522253
if err != nil {
22532254

22542255
return nil, csifault.CSIInvalidArgumentFault, logger.LogNewErrorCodef(log, codes.Internal,
2255-
"validation for PublishVolume Request: %+v has failed. Error: %v", *req, err)
2256+
"validation for PublishVolume Request: %+v has failed. Error: %v", req, err)
22562257
}
22572258
publishInfo := make(map[string]string)
22582259
_, volumeManager, err := getVCenterAndVolumeManagerForVolumeID(ctx, c, req.VolumeId, volumeInfoService)
@@ -2389,7 +2390,7 @@ func (c *controller) ControllerUnpublishVolume(ctx context.Context, req *csi.Con
23892390
controllerUnpublishVolumeInternal := func() (
23902391
*csi.ControllerUnpublishVolumeResponse, string, error) {
23912392
var faultType string
2392-
log.Infof("ControllerUnpublishVolume: called with args %+v", *req)
2393+
log.Infof("ControllerUnpublishVolume: called with args %+v", req)
23932394
// TODO: If the err is returned by invoking CNS API, then faultType should be
23942395
// populated by the underlying layer.
23952396
// If the request failed due to validate the request, "csi.fault.InvalidArgument" will be return.
@@ -2399,7 +2400,7 @@ func (c *controller) ControllerUnpublishVolume(ctx context.Context, req *csi.Con
23992400
err := validateVanillaControllerUnpublishVolumeRequest(ctx, req)
24002401
if err != nil {
24012402
return nil, csifault.CSIInvalidArgumentFault, logger.LogNewErrorCodef(log, codes.Internal,
2402-
"validation for UnpublishVolume Request: %+v has failed. Error: %v", *req, err)
2403+
"validation for UnpublishVolume Request: %+v has failed. Error: %v", req, err)
24032404
}
24042405

24052406
_, volumeManager, err := getVCenterAndVolumeManagerForVolumeID(ctx, c, req.VolumeId, volumeInfoService)
@@ -2532,7 +2533,7 @@ func (c *controller) ControllerExpandVolume(ctx context.Context, req *csi.Contro
25322533
faultType string
25332534
)
25342535

2535-
log.Infof("ControllerExpandVolume: called with args %+v", *req)
2536+
log.Infof("ControllerExpandVolume: called with args %+v", req)
25362537
// TODO: If the err is returned by invoking CNS API, then faultType should be
25372538
// populated by the underlying layer.
25382539
// If the request failed due to validate the request, "csi.fault.InvalidArgument" will be return.
@@ -2569,7 +2570,8 @@ func (c *controller) ControllerExpandVolume(ctx context.Context, req *csi.Contro
25692570
isOnlineExpansionEnabled := commonco.ContainerOrchestratorUtility.IsFSSEnabled(ctx, common.OnlineVolumeExtend)
25702571
err = validateVanillaControllerExpandVolumeRequest(ctx, req, isOnlineExpansionEnabled, isOnlineExpansionSupported)
25712572
if err != nil {
2572-
msg := fmt.Sprintf("validation for ExpandVolume Request: %+v has failed. Error: %v", *req, err)
2573+
msg := fmt.Sprintf("validation for ExpandVolume Request: %+v has failed. Error: %v",
2574+
req, err)
25732575
log.Error(msg)
25742576
return nil, csifault.CSIInternalFault, err
25752577
}
@@ -2654,7 +2656,7 @@ func (c *controller) ValidateVolumeCapabilities(ctx context.Context, req *csi.Va
26542656
*csi.ValidateVolumeCapabilitiesResponse, error) {
26552657
ctx = logger.NewContextWithLogger(ctx)
26562658
log := logger.GetLogger(ctx)
2657-
log.Infof("ControllerGetCapabilities: called with args %+v", *req)
2659+
log.Infof("ControllerGetCapabilities: called with args %+v", req)
26582660
volCaps := req.GetVolumeCapabilities()
26592661
var confirmed *csi.ValidateVolumeCapabilitiesResponse_Confirmed
26602662
if err := common.IsValidVolumeCapabilities(ctx, volCaps); err == nil {
@@ -2686,7 +2688,7 @@ func (c *controller) ListVolumes(ctx context.Context, req *csi.ListVolumesReques
26862688
}
26872689

26882690
listVolumesInternal := func() (*csi.ListVolumesResponse, string, error) {
2689-
log.Debugf("ListVolumes: called with args %+v", *req)
2691+
log.Debugf("ListVolumes: called with args %+v", req)
26902692

26912693
startingToken := 0
26922694
if req.StartingToken != "" {
@@ -2918,7 +2920,7 @@ func (c *controller) GetCapacity(ctx context.Context, req *csi.GetCapacityReques
29182920
*csi.GetCapacityResponse, error) {
29192921
ctx = logger.NewContextWithLogger(ctx)
29202922
log := logger.GetLogger(ctx)
2921-
log.Infof("GetCapacity: called with args %+v", *req)
2923+
log.Infof("GetCapacity: called with args %+v", req)
29222924
return nil, logger.LogNewErrorCode(log, codes.Unimplemented, "getCapacity")
29232925
}
29242926

@@ -2962,7 +2964,7 @@ func (c *controller) ControllerGetCapabilities(ctx context.Context, req *csi.Con
29622964
*csi.ControllerGetCapabilitiesResponse, error) {
29632965
ctx = logger.NewContextWithLogger(ctx)
29642966
log := logger.GetLogger(ctx)
2965-
log.Infof("ControllerGetCapabilities: called with args %+v", *req)
2967+
log.Infof("ControllerGetCapabilities: called with args %+v", req)
29662968

29672969
controllerCaps := []csi.ControllerServiceCapability_RPC_Type{
29682970
csi.ControllerServiceCapability_RPC_CREATE_DELETE_VOLUME,
@@ -3003,7 +3005,7 @@ func (c *controller) CreateSnapshot(ctx context.Context, req *csi.CreateSnapshot
30033005
granularMaxSnapshotsPerBlockVolumeInVSAN int
30043006
granularMaxSnapshotsPerBlockVolumeInVVOL int
30053007
)
3006-
log.Infof("CreateSnapshot: called with args %+v", *req)
3008+
log.Infof("CreateSnapshot: called with args %+v", req)
30073009

30083010
isBlockVolumeSnapshotEnabled := commonco.ContainerOrchestratorUtility.IsFSSEnabled(ctx, common.BlockVolumeSnapshot)
30093011
if !isBlockVolumeSnapshotEnabled {
@@ -3033,7 +3035,7 @@ func (c *controller) CreateSnapshot(ctx context.Context, req *csi.CreateSnapshot
30333035
// Validate CreateSnapshotRequest
30343036
if err := validateVanillaCreateSnapshotRequestRequest(ctx, req); err != nil {
30353037
return nil, logger.LogNewErrorCodef(log, codes.Internal,
3036-
"validation for CreateSnapshot Request: %+v has failed. Error: %v", *req, err)
3038+
"validation for CreateSnapshot Request: %+v has failed. Error: %v", req, err)
30373039
}
30383040

30393041
// Check if the source volume is migrated vSphere volume
@@ -3174,7 +3176,7 @@ func (c *controller) DeleteSnapshot(ctx context.Context, req *csi.DeleteSnapshot
31743176
volumeManager cnsvolume.Manager
31753177
err error
31763178
)
3177-
log.Infof("DeleteSnapshot: called with args %+v", *req)
3179+
log.Infof("DeleteSnapshot: called with args %+v", req)
31783180

31793181
isBlockVolumeSnapshotEnabled :=
31803182
commonco.ContainerOrchestratorUtility.IsFSSEnabled(ctx, common.BlockVolumeSnapshot)
@@ -3250,7 +3252,7 @@ func (c *controller) ListSnapshots(ctx context.Context, req *csi.ListSnapshotsRe
32503252
nextToken string
32513253
err error
32523254
)
3253-
log.Infof("ListSnapshots: called with args %+v", *req)
3255+
log.Infof("ListSnapshots: called with args %+v", req)
32543256
err = validateVanillaListSnapshotRequest(ctx, req)
32553257
if err != nil {
32563258
return nil, err
@@ -3525,14 +3527,14 @@ func (c *controller) ControllerGetVolume(ctx context.Context, req *csi.Controlle
35253527
*csi.ControllerGetVolumeResponse, error) {
35263528
ctx = logger.NewContextWithLogger(ctx)
35273529
log := logger.GetLogger(ctx)
3528-
log.Infof("ControllerGetVolume: called with args %+v", *req)
3530+
log.Infof("ControllerGetVolume: called with args %+v", req)
35293531
return nil, logger.LogNewErrorCode(log, codes.Unimplemented, "controllerGetVolume")
35303532
}
35313533

35323534
func (c *controller) ControllerModifyVolume(ctx context.Context, req *csi.ControllerModifyVolumeRequest) (
35333535
*csi.ControllerModifyVolumeResponse, error) {
35343536
ctx = logger.NewContextWithLogger(ctx)
35353537
log := logger.GetLogger(ctx)
3536-
log.Infof("ControllerModifyVolume: called with args %+v", *req)
3538+
log.Infof("ControllerModifyVolume: called with args %+v", req)
35373539
return nil, logger.LogNewErrorCode(log, codes.Unimplemented, "ControllerModifyVolume")
35383540
}

pkg/csi/service/vanilla/controller_test.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import (
3535
"github.com/vmware/govmomi/vim25"
3636
"google.golang.org/grpc/codes"
3737
"google.golang.org/grpc/status"
38+
"google.golang.org/protobuf/encoding/prototext"
3839

3940
"github.com/container-storage-interface/spec/lib/go/csi"
4041
clientset "k8s.io/client-go/kubernetes"
@@ -772,7 +773,7 @@ func TestExtendVolume(t *testing.T) {
772773
},
773774
VolumeCapability: capabilities[0],
774775
}
775-
t.Logf("ControllerExpandVolume will be called with req +%v", *reqExpand)
776+
t.Logf("ControllerExpandVolume will be called with req +%v", prototext.Format(reqExpand))
776777
respExpand, err := ct.controller.ControllerExpandVolume(ctx, reqExpand)
777778
if err != nil {
778779
t.Fatal(err)
@@ -830,7 +831,7 @@ func TestMigratedExtendVolume(t *testing.T) {
830831
RequiredBytes: 1024,
831832
},
832833
}
833-
t.Logf("ControllerExpandVolume will be called with req +%v", *reqExpand)
834+
t.Logf("ControllerExpandVolume will be called with req +%v", prototext.Format(reqExpand))
834835
_, err := ct.controller.ControllerExpandVolume(ctx, reqExpand)
835836
if err != nil {
836837
t.Logf("Expected error received. migrated volume with VMDK path can not be expanded")
@@ -923,7 +924,7 @@ func TestCompleteControllerFlow(t *testing.T) {
923924
VolumeCapability: capabilities[0],
924925
Readonly: false,
925926
}
926-
t.Logf("ControllerPublishVolume will be called with req +%v", *reqControllerPublishVolume)
927+
t.Logf("ControllerPublishVolume will be called with req +%v", prototext.Format(reqControllerPublishVolume))
927928
respControllerPublishVolume, err := ct.controller.ControllerPublishVolume(ctx, reqControllerPublishVolume)
928929
if err != nil {
929930
t.Fatal(err)
@@ -936,7 +937,8 @@ func TestCompleteControllerFlow(t *testing.T) {
936937
VolumeId: volID,
937938
NodeId: NodeID,
938939
}
939-
t.Logf("ControllerUnpublishVolume will be called with req +%v", *reqControllerUnpublishVolume)
940+
t.Logf("ControllerUnpublishVolume will be called with req +%v",
941+
prototext.Format(reqControllerUnpublishVolume))
940942
_, err = ct.controller.ControllerUnpublishVolume(ctx, reqControllerUnpublishVolume)
941943
if err != nil {
942944
t.Fatal(err)

0 commit comments

Comments
 (0)