From 4de2906d051adeaf0c6e71bd1f35a0a607aa575a Mon Sep 17 00:00:00 2001 From: Deepak Kinni Date: Wed, 22 Jan 2025 14:17:46 -0800 Subject: [PATCH] Update CSI spec dependency Signed-off-by: Deepak Kinni --- go.mod | 4 +- go.sum | 4 +- pkg/csi/service/common/types.go | 20 +++------- pkg/csi/service/common/util.go | 4 +- pkg/csi/service/driver.go | 2 + pkg/csi/service/node.go | 16 ++++---- pkg/csi/service/vanilla/controller.go | 39 +++++++++--------- pkg/csi/service/vanilla/controller_test.go | 10 +++-- pkg/csi/service/wcp/controller.go | 40 ++++++++++--------- pkg/csi/service/wcpguest/controller.go | 46 +++++++++++++--------- 10 files changed, 99 insertions(+), 86 deletions(-) diff --git a/go.mod b/go.mod index e4174d5342..0b71f4c354 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.22.8 require ( github.com/agiledragon/gomonkey/v2 v2.3.1 github.com/akutz/gofsutil v0.1.2 - github.com/container-storage-interface/spec v1.9.0 + github.com/container-storage-interface/spec v1.11.0 github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc github.com/evanphx/json-patch/v5 v5.9.0 github.com/fsnotify/fsnotify v1.7.0 @@ -27,6 +27,7 @@ require ( go.uber.org/zap v1.26.0 golang.org/x/crypto v0.26.0 golang.org/x/sync v0.10.0 + golang.org/x/sys v0.24.0 google.golang.org/grpc v1.67.1 google.golang.org/protobuf v1.34.2 gopkg.in/gcfg.v1 v1.2.3 @@ -164,7 +165,6 @@ require ( go.uber.org/multierr v1.11.0 // indirect golang.org/x/net v0.28.0 // indirect golang.org/x/oauth2 v0.22.0 // indirect - golang.org/x/sys v0.24.0 // indirect golang.org/x/term v0.23.0 // indirect golang.org/x/text v0.21.0 // indirect golang.org/x/time v0.5.0 // indirect diff --git a/go.sum b/go.sum index ed08d5d9de..78682fe4ce 100644 --- a/go.sum +++ b/go.sum @@ -64,8 +64,8 @@ github.com/cilium/ebpf v0.9.1/go.mod h1:+OhNOIXx/Fnu1IE8bJz2dzOA+VSfyTfdNUVdlQnx github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= -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.11.0 h1:H/YKTOeUZwHtyPOr9raR+HgFmGluGCklulxDYxSdVNM= +github.com/container-storage-interface/spec v1.11.0/go.mod h1:DtUvaQszPml1YJfIK7c00mlv6/g4wNMLanLgiUbKFRI= github.com/containerd/cgroups v1.0.1/go.mod h1:0SJrPIenamHDcZhEcJMNBB85rHcUsw4f25ZfBiPYRkU= github.com/containerd/cgroups v1.1.0 h1:v8rEWFl6EoqHB+swVNjVoCJE8o3jX7e8nqBGPLaDFBM= github.com/containerd/cgroups v1.1.0/go.mod h1:6ppBcbh/NOOUU+dMKrykgaBnK9lCIBxHqJDGwsa1mIw= diff --git a/pkg/csi/service/common/types.go b/pkg/csi/service/common/types.go index fbfc82841e..6d6bcb5ad2 100644 --- a/pkg/csi/service/common/types.go +++ b/pkg/csi/service/common/types.go @@ -30,25 +30,17 @@ var ( // BlockVolumeCaps represents how the block volume could be accessed. // CNS block volumes support only SINGLE_NODE_WRITER where the volume is // attached to a single node at any given time. - BlockVolumeCaps = []csi.VolumeCapability_AccessMode{ - { - Mode: csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER, - }, + BlockVolumeCaps = []csi.VolumeCapability_AccessMode_Mode{ + csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER, } // FileVolumeCaps represents how the file volume could be accessed. // CNS file volumes supports MULTI_NODE_READER_ONLY, MULTI_NODE_SINGLE_WRITER // and MULTI_NODE_MULTI_WRITER - FileVolumeCaps = []csi.VolumeCapability_AccessMode{ - { - Mode: csi.VolumeCapability_AccessMode_MULTI_NODE_READER_ONLY, - }, - { - Mode: csi.VolumeCapability_AccessMode_MULTI_NODE_SINGLE_WRITER, - }, - { - Mode: csi.VolumeCapability_AccessMode_MULTI_NODE_MULTI_WRITER, - }, + FileVolumeCaps = []csi.VolumeCapability_AccessMode_Mode{ + csi.VolumeCapability_AccessMode_MULTI_NODE_READER_ONLY, + csi.VolumeCapability_AccessMode_MULTI_NODE_SINGLE_WRITER, + csi.VolumeCapability_AccessMode_MULTI_NODE_MULTI_WRITER, } // ErrNotFound represents not found error diff --git a/pkg/csi/service/common/util.go b/pkg/csi/service/common/util.go index 3009e47908..42e409d661 100644 --- a/pkg/csi/service/common/util.go +++ b/pkg/csi/service/common/util.go @@ -165,12 +165,12 @@ func IsVolumeReadOnly(capability *csi.VolumeCapability) bool { // validateVolumeCapabilities validates the access mode in given volume // capabilities in validAccessModes. func validateVolumeCapabilities(volCaps []*csi.VolumeCapability, - validAccessModes []csi.VolumeCapability_AccessMode, volumeType string) error { + validAccessModes []csi.VolumeCapability_AccessMode_Mode, volumeType string) error { // Validate if all capabilities of the volume are supported. for _, volCap := range volCaps { found := false for _, validAccessMode := range validAccessModes { - if volCap.AccessMode.GetMode() == validAccessMode.GetMode() { + if volCap.AccessMode.GetMode() == validAccessMode { found = true break } diff --git a/pkg/csi/service/driver.go b/pkg/csi/service/driver.go index 3c9c887329..3dfda90ac9 100644 --- a/pkg/csi/service/driver.go +++ b/pkg/csi/service/driver.go @@ -67,6 +67,8 @@ type vsphereCSIDriver struct { // A map storing all volumes with ongoing operations so that additional operations // for that same volume (as defined by VolumeID) return an Aborted error volumeLocks *node.VolumeLocks + csi.UnimplementedNodeServer + csi.UnimplementedIdentityServer } // If k8s node died unexpectedly in an earlier run, the unix socket is left diff --git a/pkg/csi/service/node.go b/pkg/csi/service/node.go index 06d0552064..170303eb22 100644 --- a/pkg/csi/service/node.go +++ b/pkg/csi/service/node.go @@ -21,6 +21,8 @@ import ( "os" "strconv" + "google.golang.org/protobuf/encoding/prototext" + "github.com/container-storage-interface/spec/lib/go/csi" cnstypes "github.com/vmware/govmomi/cns/types" "github.com/vmware/govmomi/units" @@ -52,7 +54,7 @@ func (driver *vsphereCSIDriver) NodeStageVolume( *csi.NodeStageVolumeResponse, error) { ctx = logger.NewContextWithLogger(ctx) log := logger.GetLogger(ctx) - log.Infof("NodeStageVolume: called with args %+v", *req) + log.Infof("NodeStageVolume: called with args %+v", prototext.Format(req)) volumeID := req.GetVolumeId() volCap := req.GetVolumeCapability() @@ -113,7 +115,7 @@ func (driver *vsphereCSIDriver) NodeUnstageVolume( *csi.NodeUnstageVolumeResponse, error) { ctx = logger.NewContextWithLogger(ctx) log := logger.GetLogger(ctx) - log.Infof("NodeUnstageVolume: called with args %+v", *req) + log.Infof("NodeUnstageVolume: called with args %+v", prototext.Format(req)) // Validate arguments volumeID := req.GetVolumeId() @@ -178,7 +180,7 @@ func (driver *vsphereCSIDriver) NodePublishVolume( *csi.NodePublishVolumeResponse, error) { ctx = logger.NewContextWithLogger(ctx) log := logger.GetLogger(ctx) - log.Infof("NodePublishVolume: called with args %+v", *req) + log.Infof("NodePublishVolume: called with args %+v", prototext.Format(req)) var err error volumeID := req.GetVolumeId() if len(volumeID) == 0 { @@ -246,7 +248,7 @@ func (driver *vsphereCSIDriver) NodeUnpublishVolume( *csi.NodeUnpublishVolumeResponse, error) { ctx = logger.NewContextWithLogger(ctx) log := logger.GetLogger(ctx) - log.Infof("NodeUnpublishVolume: called with args %+v", *req) + log.Infof("NodeUnpublishVolume: called with args %+v", prototext.Format(req)) volID := req.GetVolumeId() target := req.GetTargetPath() @@ -276,7 +278,7 @@ func (driver *vsphereCSIDriver) NodeGetVolumeStats( *csi.NodeGetVolumeStatsResponse, error) { ctx = logger.NewContextWithLogger(ctx) log := logger.GetLogger(ctx) - log.Infof("NodeGetVolumeStats: called with args %+v", *req) + log.Infof("NodeGetVolumeStats: called with args %+v", prototext.Format(req)) var err error targetPath := req.GetVolumePath() @@ -378,7 +380,7 @@ func (driver *vsphereCSIDriver) NodeGetInfo( *csi.NodeGetInfoResponse, error) { ctx = logger.NewContextWithLogger(ctx) log := logger.GetLogger(ctx) - log.Infof("NodeGetInfo: called with args %+v", *req) + log.Infof("NodeGetInfo: called with args %+v", prototext.Format(req)) driver.osUtils.ShouldContinue(ctx) @@ -514,7 +516,7 @@ func (driver *vsphereCSIDriver) NodeExpandVolume( *csi.NodeExpandVolumeResponse, error) { ctx = logger.NewContextWithLogger(ctx) log := logger.GetLogger(ctx) - log.Infof("NodeExpandVolume: called with args %+v", *req) + log.Infof("NodeExpandVolume: called with args %+v", prototext.Format(req)) volumeID := req.GetVolumeId() if len(volumeID) == 0 { diff --git a/pkg/csi/service/vanilla/controller.go b/pkg/csi/service/vanilla/controller.go index 3e12285e52..32c2334964 100644 --- a/pkg/csi/service/vanilla/controller.go +++ b/pkg/csi/service/vanilla/controller.go @@ -35,6 +35,7 @@ import ( "github.com/vmware/govmomi/units" "github.com/vmware/govmomi/vim25/types" "google.golang.org/grpc/codes" + "google.golang.org/protobuf/encoding/prototext" "google.golang.org/protobuf/types/known/timestamppb" apierrors "k8s.io/apimachinery/pkg/api/errors" @@ -79,6 +80,7 @@ type controller struct { authMgr common.AuthorizationService authMgrs map[string]*common.AuthManager topologyMgr commoncotypes.ControllerTopologyService + csi.UnimplementedControllerServer } var ( @@ -1958,7 +1960,7 @@ func (c *controller) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequ volumeType := prometheus.PrometheusUnknownVolumeType createVolumeInternal := func() ( *csi.CreateVolumeResponse, string, error) { - log.Infof("CreateVolume: called with args %+v", *req) + log.Infof("CreateVolume: called with args %+v", prototext.Format(req)) // TODO: If the err is returned by invoking CNS API, then faultType should be // populated by the underlying layer. // If the request failed due to validate the request, "csi.fault.InvalidArgument" will be return. @@ -2051,7 +2053,7 @@ func (c *controller) DeleteVolume(ctx context.Context, req *csi.DeleteVolumeRequ deleteVolumeInternal := func() ( *csi.DeleteVolumeResponse, string, error) { - log.Infof("DeleteVolume: called with args: %+v", *req) + log.Infof("DeleteVolume: called with args: %+v", prototext.Format(req)) // TODO: If the err is returned by invoking CNS API, then faultType should be // populated by the underlying layer. // If the request failed due to validate the request, "csi.fault.InvalidArgument" will be return. @@ -2194,7 +2196,7 @@ func (c *controller) ControllerPublishVolume(ctx context.Context, req *csi.Contr controllerPublishVolumeInternal := func() ( *csi.ControllerPublishVolumeResponse, string, error) { - log.Infof("ControllerPublishVolume: called with args %+v", *req) + log.Infof("ControllerPublishVolume: called with args %+v", prototext.Format(req)) // TODO: If the err is returned by invoking CNS API, then faultType should be // populated by the underlying layer. // If the request failed due to validate the request, "csi.fault.InvalidArgument" will be return. @@ -2205,7 +2207,7 @@ func (c *controller) ControllerPublishVolume(ctx context.Context, req *csi.Contr if err != nil { return nil, csifault.CSIInvalidArgumentFault, logger.LogNewErrorCodef(log, codes.Internal, - "validation for PublishVolume Request: %+v has failed. Error: %v", *req, err) + "validation for PublishVolume Request: %+v has failed. Error: %v", prototext.Format(req), err) } publishInfo := make(map[string]string) _, volumeManager, err := getVCenterAndVolumeManagerForVolumeID(ctx, c, req.VolumeId, volumeInfoService) @@ -2342,7 +2344,7 @@ func (c *controller) ControllerUnpublishVolume(ctx context.Context, req *csi.Con controllerUnpublishVolumeInternal := func() ( *csi.ControllerUnpublishVolumeResponse, string, error) { var faultType string - log.Infof("ControllerUnpublishVolume: called with args %+v", *req) + log.Infof("ControllerUnpublishVolume: called with args %+v", prototext.Format(req)) // TODO: If the err is returned by invoking CNS API, then faultType should be // populated by the underlying layer. // If the request failed due to validate the request, "csi.fault.InvalidArgument" will be return. @@ -2352,7 +2354,7 @@ func (c *controller) ControllerUnpublishVolume(ctx context.Context, req *csi.Con err := validateVanillaControllerUnpublishVolumeRequest(ctx, req) if err != nil { return nil, csifault.CSIInvalidArgumentFault, logger.LogNewErrorCodef(log, codes.Internal, - "validation for UnpublishVolume Request: %+v has failed. Error: %v", *req, err) + "validation for UnpublishVolume Request: %+v has failed. Error: %v", prototext.Format(req), err) } _, volumeManager, err := getVCenterAndVolumeManagerForVolumeID(ctx, c, req.VolumeId, volumeInfoService) @@ -2485,7 +2487,7 @@ func (c *controller) ControllerExpandVolume(ctx context.Context, req *csi.Contro faultType string ) - log.Infof("ControllerExpandVolume: called with args %+v", *req) + log.Infof("ControllerExpandVolume: called with args %+v", prototext.Format(req)) // TODO: If the err is returned by invoking CNS API, then faultType should be // populated by the underlying layer. // If the request failed due to validate the request, "csi.fault.InvalidArgument" will be return. @@ -2522,7 +2524,8 @@ func (c *controller) ControllerExpandVolume(ctx context.Context, req *csi.Contro isOnlineExpansionEnabled := commonco.ContainerOrchestratorUtility.IsFSSEnabled(ctx, common.OnlineVolumeExtend) err = validateVanillaControllerExpandVolumeRequest(ctx, req, isOnlineExpansionEnabled, isOnlineExpansionSupported) if err != nil { - msg := fmt.Sprintf("validation for ExpandVolume Request: %+v has failed. Error: %v", *req, err) + msg := fmt.Sprintf("validation for ExpandVolume Request: %+v has failed. Error: %v", + prototext.Format(req), err) log.Error(msg) return nil, csifault.CSIInternalFault, err } @@ -2607,7 +2610,7 @@ func (c *controller) ValidateVolumeCapabilities(ctx context.Context, req *csi.Va *csi.ValidateVolumeCapabilitiesResponse, error) { ctx = logger.NewContextWithLogger(ctx) log := logger.GetLogger(ctx) - log.Infof("ControllerGetCapabilities: called with args %+v", *req) + log.Infof("ControllerGetCapabilities: called with args %+v", prototext.Format(req)) volCaps := req.GetVolumeCapabilities() var confirmed *csi.ValidateVolumeCapabilitiesResponse_Confirmed if err := common.IsValidVolumeCapabilities(ctx, volCaps); err == nil { @@ -2639,7 +2642,7 @@ func (c *controller) ListVolumes(ctx context.Context, req *csi.ListVolumesReques } listVolumesInternal := func() (*csi.ListVolumesResponse, string, error) { - log.Debugf("ListVolumes: called with args %+v", *req) + log.Debugf("ListVolumes: called with args %+v", prototext.Format(req)) startingToken := 0 if req.StartingToken != "" { @@ -2871,7 +2874,7 @@ func (c *controller) GetCapacity(ctx context.Context, req *csi.GetCapacityReques *csi.GetCapacityResponse, error) { ctx = logger.NewContextWithLogger(ctx) log := logger.GetLogger(ctx) - log.Infof("GetCapacity: called with args %+v", *req) + log.Infof("GetCapacity: called with args %+v", prototext.Format(req)) return nil, logger.LogNewErrorCode(log, codes.Unimplemented, "getCapacity") } @@ -2915,7 +2918,7 @@ func (c *controller) ControllerGetCapabilities(ctx context.Context, req *csi.Con *csi.ControllerGetCapabilitiesResponse, error) { ctx = logger.NewContextWithLogger(ctx) log := logger.GetLogger(ctx) - log.Infof("ControllerGetCapabilities: called with args %+v", *req) + log.Infof("ControllerGetCapabilities: called with args %+v", prototext.Format(req)) controllerCaps := []csi.ControllerServiceCapability_RPC_Type{ csi.ControllerServiceCapability_RPC_CREATE_DELETE_VOLUME, @@ -2956,7 +2959,7 @@ func (c *controller) CreateSnapshot(ctx context.Context, req *csi.CreateSnapshot granularMaxSnapshotsPerBlockVolumeInVSAN int granularMaxSnapshotsPerBlockVolumeInVVOL int ) - log.Infof("CreateSnapshot: called with args %+v", *req) + log.Infof("CreateSnapshot: called with args %+v", prototext.Format(req)) isBlockVolumeSnapshotEnabled := commonco.ContainerOrchestratorUtility.IsFSSEnabled(ctx, common.BlockVolumeSnapshot) if !isBlockVolumeSnapshotEnabled { @@ -2986,7 +2989,7 @@ func (c *controller) CreateSnapshot(ctx context.Context, req *csi.CreateSnapshot // Validate CreateSnapshotRequest if err := validateVanillaCreateSnapshotRequestRequest(ctx, req); err != nil { return nil, logger.LogNewErrorCodef(log, codes.Internal, - "validation for CreateSnapshot Request: %+v has failed. Error: %v", *req, err) + "validation for CreateSnapshot Request: %+v has failed. Error: %v", prototext.Format(req), err) } // Check if the source volume is migrated vSphere volume @@ -3117,7 +3120,7 @@ func (c *controller) DeleteSnapshot(ctx context.Context, req *csi.DeleteSnapshot volumeManager cnsvolume.Manager err error ) - log.Infof("DeleteSnapshot: called with args %+v", *req) + log.Infof("DeleteSnapshot: called with args %+v", prototext.Format(req)) isBlockVolumeSnapshotEnabled := commonco.ContainerOrchestratorUtility.IsFSSEnabled(ctx, common.BlockVolumeSnapshot) @@ -3193,7 +3196,7 @@ func (c *controller) ListSnapshots(ctx context.Context, req *csi.ListSnapshotsRe nextToken string err error ) - log.Infof("ListSnapshots: called with args %+v", *req) + log.Infof("ListSnapshots: called with args %+v", prototext.Format(req)) err = validateVanillaListSnapshotRequest(ctx, req) if err != nil { return nil, err @@ -3468,7 +3471,7 @@ func (c *controller) ControllerGetVolume(ctx context.Context, req *csi.Controlle *csi.ControllerGetVolumeResponse, error) { ctx = logger.NewContextWithLogger(ctx) log := logger.GetLogger(ctx) - log.Infof("ControllerGetVolume: called with args %+v", *req) + log.Infof("ControllerGetVolume: called with args %+v", prototext.Format(req)) return nil, logger.LogNewErrorCode(log, codes.Unimplemented, "controllerGetVolume") } @@ -3476,6 +3479,6 @@ func (c *controller) ControllerModifyVolume(ctx context.Context, req *csi.Contro *csi.ControllerModifyVolumeResponse, error) { ctx = logger.NewContextWithLogger(ctx) log := logger.GetLogger(ctx) - log.Infof("ControllerModifyVolume: called with args %+v", *req) + log.Infof("ControllerModifyVolume: called with args %+v", prototext.Format(req)) return nil, logger.LogNewErrorCode(log, codes.Unimplemented, "ControllerModifyVolume") } diff --git a/pkg/csi/service/vanilla/controller_test.go b/pkg/csi/service/vanilla/controller_test.go index a60fa6d832..3d7df2fd52 100644 --- a/pkg/csi/service/vanilla/controller_test.go +++ b/pkg/csi/service/vanilla/controller_test.go @@ -33,6 +33,7 @@ import ( "github.com/vmware/govmomi/pbm/types" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" + "google.golang.org/protobuf/encoding/prototext" "github.com/container-storage-interface/spec/lib/go/csi" "github.com/vmware/govmomi/simulator" @@ -766,7 +767,7 @@ func TestExtendVolume(t *testing.T) { }, VolumeCapability: capabilities[0], } - t.Logf("ControllerExpandVolume will be called with req +%v", *reqExpand) + t.Logf("ControllerExpandVolume will be called with req +%v", prototext.Format(reqExpand)) respExpand, err := ct.controller.ControllerExpandVolume(ctx, reqExpand) if err != nil { t.Fatal(err) @@ -824,7 +825,7 @@ func TestMigratedExtendVolume(t *testing.T) { RequiredBytes: 1024, }, } - t.Logf("ControllerExpandVolume will be called with req +%v", *reqExpand) + t.Logf("ControllerExpandVolume will be called with req +%v", prototext.Format(reqExpand)) _, err := ct.controller.ControllerExpandVolume(ctx, reqExpand) if err != nil { t.Logf("Expected error received. migrated volume with VMDK path can not be expanded") @@ -913,7 +914,7 @@ func TestCompleteControllerFlow(t *testing.T) { VolumeCapability: capabilities[0], Readonly: false, } - t.Logf("ControllerPublishVolume will be called with req +%v", *reqControllerPublishVolume) + t.Logf("ControllerPublishVolume will be called with req +%v", prototext.Format(reqControllerPublishVolume)) respControllerPublishVolume, err := ct.controller.ControllerPublishVolume(ctx, reqControllerPublishVolume) if err != nil { t.Fatal(err) @@ -926,7 +927,8 @@ func TestCompleteControllerFlow(t *testing.T) { VolumeId: volID, NodeId: NodeID, } - t.Logf("ControllerUnpublishVolume will be called with req +%v", *reqControllerUnpublishVolume) + t.Logf("ControllerUnpublishVolume will be called with req +%v", + prototext.Format(reqControllerUnpublishVolume)) _, err = ct.controller.ControllerUnpublishVolume(ctx, reqControllerUnpublishVolume) if err != nil { t.Fatal(err) diff --git a/pkg/csi/service/wcp/controller.go b/pkg/csi/service/wcp/controller.go index 481f845a00..e2b832e4e5 100644 --- a/pkg/csi/service/wcp/controller.go +++ b/pkg/csi/service/wcp/controller.go @@ -27,6 +27,8 @@ import ( "sync" "time" + "google.golang.org/protobuf/encoding/prototext" + "github.com/container-storage-interface/spec/lib/go/csi" "github.com/davecgh/go-spew/spew" "github.com/fsnotify/fsnotify" @@ -100,6 +102,7 @@ type controller struct { manager *common.Manager authMgr common.AuthorizationService topologyMgr commoncotypes.ControllerTopologyService + csi.UnimplementedControllerServer } // New creates a CNS controller. @@ -1158,7 +1161,7 @@ func (c *controller) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequ volumeType := prometheus.PrometheusUnknownVolumeType createVolumeInternal := func() ( *csi.CreateVolumeResponse, string, error) { - log.Infof("CreateVolume: called with args %+v", *req) + log.Infof("CreateVolume: called with args %+v", prototext.Format(req)) isWorkloadDomainIsolationEnabled := commonco.ContainerOrchestratorUtility. IsFSSEnabled(ctx, common.WorkloadDomainIsolation) // TODO: If the err is returned by invoking CNS API, then faultType should be @@ -1177,7 +1180,8 @@ func (c *controller) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequ // Validate create request. err := validateWCPCreateVolumeRequest(ctx, req, isBlockRequest) if err != nil { - msg := fmt.Sprintf("Validation for CreateVolume Request: %+v has failed. Error: %+v", *req, err) + msg := fmt.Sprintf("Validation for CreateVolume Request: %+v has failed. Error: %+v", + prototext.Format(req), err) log.Error(msg) return nil, csifault.CSIInvalidArgumentFault, err } @@ -1239,14 +1243,14 @@ func (c *controller) DeleteVolume(ctx context.Context, req *csi.DeleteVolumeRequ cnsVolumeType := common.UnknownVolumeType deleteVolumeInternal := func() (*csi.DeleteVolumeResponse, string, error) { - log.Infof("DeleteVolume: called with args: %+v", *req) + log.Infof("DeleteVolume: called with args: %+v", prototext.Format(req)) // TODO: If the err is returned by invoking CNS API, then faultType should be // populated by the underlying layer. // For all other cases, the faultType will be set to "csi.fault.Internal" for now. // Later we may need to define different csi faults. err := validateWCPDeleteVolumeRequest(ctx, req) if err != nil { - msg := fmt.Sprintf("Validation for DeleteVolume Request: %+v has failed. Error: %+v", *req, err) + msg := fmt.Sprintf("Validation for DeleteVolume Request: %+v has failed. Error: %+v", prototext.Format(req), err) log.Error(msg) return nil, csifault.CSIInvalidArgumentFault, err } @@ -1330,7 +1334,7 @@ func (c *controller) ControllerPublishVolume(ctx context.Context, req *csi.Contr controllerPublishVolumeInternal := func() ( *csi.ControllerPublishVolumeResponse, string, error) { - log.Infof("ControllerPublishVolume: called with args %+v", *req) + log.Infof("ControllerPublishVolume: called with args %+v", prototext.Format(req)) // TODO: If the err is returned by invoking CNS API, then faultType should be // populated by the underlying layer. // If the request failed due to validate the request, "csi.fault.InvalidArgument" will be return. @@ -1339,7 +1343,7 @@ func (c *controller) ControllerPublishVolume(ctx context.Context, req *csi.Contr // Later we may need to define different csi faults. err := validateWCPControllerPublishVolumeRequest(ctx, req) if err != nil { - msg := fmt.Sprintf("Validation for PublishVolume Request: %+v has failed. Error: %v", *req, err) + msg := fmt.Sprintf("Validation for PublishVolume Request: %+v has failed. Error: %v", prototext.Format(req), err) log.Errorf(msg) return nil, csifault.CSIInvalidArgumentFault, err } @@ -1488,7 +1492,7 @@ func (c *controller) ControllerUnpublishVolume(ctx context.Context, req *csi.Con volumeType := prometheus.PrometheusUnknownVolumeType controllerUnpublishVolumeInternal := func() ( *csi.ControllerUnpublishVolumeResponse, string, error) { - log.Infof("ControllerUnpublishVolume: called with args %+v", *req) + log.Infof("ControllerUnpublishVolume: called with args %+v", prototext.Format(req)) // TODO: If the err is returned by invoking CNS API, then faultType should be // populated by the underlying layer. // If the request failed due to validate the request, "csi.fault.InvalidArgument" will be return. @@ -1497,7 +1501,7 @@ func (c *controller) ControllerUnpublishVolume(ctx context.Context, req *csi.Con // Later we may need to define different csi faults. err := validateWCPControllerUnpublishVolumeRequest(ctx, req) if err != nil { - msg := fmt.Sprintf("Validation for UnpublishVolume Request: %+v has failed. Error: %v", *req, err) + msg := fmt.Sprintf("Validation for UnpublishVolume Request: %+v has failed. Error: %v", prototext.Format(req), err) log.Error(msg) return nil, csifault.CSIInvalidArgumentFault, err } @@ -1752,7 +1756,7 @@ func (c *controller) ValidateVolumeCapabilities(ctx context.Context, req *csi.Va *csi.ValidateVolumeCapabilitiesResponse, error) { ctx = logger.NewContextWithLogger(ctx) log := logger.GetLogger(ctx) - log.Infof("ControllerGetCapabilities: called with args %+v", *req) + log.Infof("ControllerGetCapabilities: called with args %+v", prototext.Format(req)) volCaps := req.GetVolumeCapabilities() var confirmed *csi.ValidateVolumeCapabilitiesResponse_Confirmed if err := common.IsValidVolumeCapabilities(ctx, volCaps); err == nil { @@ -1776,7 +1780,7 @@ func (c *controller) ListVolumes(ctx context.Context, req *csi.ListVolumesReques return nil, status.Error(codes.Unimplemented, "list volumes FSS disabled") } controllerListVolumeInternal := func() (*csi.ListVolumesResponse, string, error) { - log.Debugf("ListVolumes called with args %+v, expectedStartingIndex %v", *req, expectedStartingIndex) + log.Debugf("ListVolumes called with args %+v, expectedStartingIndex %v", prototext.Format(req), expectedStartingIndex) k8sVolumeIDs := commonco.ContainerOrchestratorUtility.GetAllVolumes() startingIdx := 0 @@ -1887,7 +1891,7 @@ func (c *controller) GetCapacity(ctx context.Context, req *csi.GetCapacityReques *csi.GetCapacityResponse, error) { ctx = logger.NewContextWithLogger(ctx) log := logger.GetLogger(ctx) - log.Infof("GetCapacity: called with args %+v", *req) + log.Infof("GetCapacity: called with args %+v", prototext.Format(req)) return nil, status.Error(codes.Unimplemented, "") } @@ -1896,7 +1900,7 @@ func (c *controller) ControllerGetCapabilities(ctx context.Context, req *csi.Con ctx = logger.NewContextWithLogger(ctx) log := logger.GetLogger(ctx) - log.Infof("ControllerGetCapabilities: called with args %+v", *req) + log.Infof("ControllerGetCapabilities: called with args %+v", prototext.Format(req)) var caps []*csi.ControllerServiceCapability if commonco.ContainerOrchestratorUtility.IsFSSEnabled(ctx, common.ListVolumes) { controllerCaps = append(controllerCaps, csi.ControllerServiceCapability_RPC_LIST_VOLUMES, @@ -1921,7 +1925,7 @@ func (c *controller) CreateSnapshot(ctx context.Context, req *csi.CreateSnapshot ctx = logger.NewContextWithLogger(ctx) log := logger.GetLogger(ctx) - log.Infof("WCP CreateSnapshot: called with args %+v", *req) + log.Infof("WCP CreateSnapshot: called with args %+v", prototext.Format(req)) isBlockVolumeSnapshotWCPEnabled := commonco.ContainerOrchestratorUtility.IsFSSEnabled(ctx, common.BlockVolumeSnapshot) if !isBlockVolumeSnapshotWCPEnabled { return nil, logger.LogNewErrorCode(log, codes.Unimplemented, "createSnapshot") @@ -1931,7 +1935,7 @@ func (c *controller) CreateSnapshot(ctx context.Context, req *csi.CreateSnapshot // Validate CreateSnapshotRequest if err := validateWCPCreateSnapshotRequest(ctx, req); err != nil { return nil, logger.LogNewErrorCodef(log, codes.Internal, - "validation for CreateSnapshot Request: %+v has failed. Error: %v", *req, err) + "validation for CreateSnapshot Request: %+v has failed. Error: %v", prototext.Format(req), err) } volumeID := req.GetSourceVolumeId() @@ -2067,7 +2071,7 @@ func (c *controller) DeleteSnapshot(ctx context.Context, req *csi.DeleteSnapshot ctx = logger.NewContextWithLogger(ctx) log := logger.GetLogger(ctx) - log.Infof("DeleteSnapshot: called with args %+v", *req) + log.Infof("DeleteSnapshot: called with args %+v", prototext.Format(req)) volumeType := prometheus.PrometheusBlockVolumeType start := time.Now() isBlockVolumeSnapshotWCPEnabled := commonco.ContainerOrchestratorUtility.IsFSSEnabled(ctx, common.BlockVolumeSnapshot) @@ -2145,7 +2149,7 @@ func (c *controller) ListSnapshots(ctx context.Context, req *csi.ListSnapshotsRe ctx = logger.NewContextWithLogger(ctx) log := logger.GetLogger(ctx) volumeType := prometheus.PrometheusBlockVolumeType - log.Infof("ListSnapshots: called with args %+v", *req) + log.Infof("ListSnapshots: called with args %+v", prototext.Format(req)) isBlockVolumeSnapshotWCPEnabled := commonco.ContainerOrchestratorUtility.IsFSSEnabled(ctx, common.BlockVolumeSnapshot) if !isBlockVolumeSnapshotWCPEnabled { return nil, logger.LogNewErrorCode(log, codes.Unimplemented, "listSnapshot") @@ -2205,7 +2209,7 @@ func (c *controller) ControllerExpandVolume(ctx context.Context, req *csi.Contro return nil, csifault.CSIUnimplementedFault, logger.LogNewErrorCode(log, codes.Unimplemented, "expandVolume feature is disabled on the cluster") } - log.Infof("ControllerExpandVolume: called with args %+v", *req) + log.Infof("ControllerExpandVolume: called with args %+v", prototext.Format(req)) // TODO: If the err is returned by invoking CNS API, then faultType should be // populated by the underlying layer. // If the request failed due to validate the request, "csi.fault.InvalidArgument" will be return. @@ -2242,7 +2246,7 @@ func (c *controller) ControllerExpandVolume(ctx context.Context, req *csi.Contro isOnlineExpansionEnabled := commonco.ContainerOrchestratorUtility.IsFSSEnabled(ctx, common.OnlineVolumeExtend) err = validateWCPControllerExpandVolumeRequest(ctx, req, c.manager, isOnlineExpansionEnabled) if err != nil { - log.Errorf("validation for ExpandVolume Request: %+v has failed. Error: %v", *req, err) + log.Errorf("validation for ExpandVolume Request: %+v has failed. Error: %v", prototext.Format(req), err) return nil, csifault.CSIInvalidArgumentFault, err } volumeType = prometheus.PrometheusBlockVolumeType diff --git a/pkg/csi/service/wcpguest/controller.go b/pkg/csi/service/wcpguest/controller.go index 8de8ef27e0..9476d8b06a 100644 --- a/pkg/csi/service/wcpguest/controller.go +++ b/pkg/csi/service/wcpguest/controller.go @@ -26,6 +26,8 @@ import ( "strings" "time" + "google.golang.org/protobuf/encoding/prototext" + "github.com/container-storage-interface/spec/lib/go/csi" "github.com/davecgh/go-spew/spew" "github.com/fsnotify/fsnotify" @@ -83,6 +85,7 @@ type controller struct { tanzukubernetesClusterUID string tanzukubernetesClusterName string guestClusterDist string + csi.UnimplementedControllerServer } // New creates a CNS controller @@ -260,7 +263,7 @@ func (c *controller) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequ createVolumeInternal := func() ( *csi.CreateVolumeResponse, string, error) { - log.Infof("CreateVolume: called with args %+v", *req) + log.Infof("CreateVolume: called with args %+v", prototext.Format(req)) // TODO: If the err is returned by invoking CNS API, then faultType should be // populated by the underlying layer. // If the request failed due to validate the request, "csi.fault.InvalidArgument" will be return. @@ -269,7 +272,8 @@ func (c *controller) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequ // Later we may need to define different csi faults. err := validateGuestClusterCreateVolumeRequest(ctx, req) if err != nil { - log.Errorf("validation for CreateVolume Request: %+v has failed. Error: %+v", *req, err) + log.Errorf("validation for CreateVolume Request: %+v has failed. Error: %+v", + prototext.Format(req), err) return nil, csifault.CSIInvalidArgumentFault, err } isFileVolumeRequest := common.IsFileVolumeRequest(ctx, req.GetVolumeCapabilities()) @@ -478,7 +482,7 @@ func (c *controller) DeleteVolume(ctx context.Context, req *csi.DeleteVolumeRequ deleteVolumeInternal := func() ( *csi.DeleteVolumeResponse, string, error) { - log.Infof("DeleteVolume: called with args: %+v", *req) + log.Infof("DeleteVolume: called with args: %+v", prototext.Format(req)) // TODO: If the err is returned by invoking CNS API, then faultType should be // populated by the underlying layer. // If the request failed due to validate the request, "csi.fault.InvalidArgument" will be return. @@ -488,7 +492,8 @@ func (c *controller) DeleteVolume(ctx context.Context, req *csi.DeleteVolumeRequ var err error err = validateGuestClusterDeleteVolumeRequest(ctx, req) if err != nil { - msg := fmt.Sprintf("Validation for Delete Volume Request: %+v has failed. Error: %+v", *req, err) + msg := fmt.Sprintf("Validation for Delete Volume Request: %+v has failed. Error: %+v", + prototext.Format(req), err) log.Error(msg) return nil, csifault.CSIInvalidArgumentFault, err } @@ -516,10 +521,11 @@ func (c *controller) DeleteVolume(ctx context.Context, req *csi.DeleteVolumeRequ ctx, req.VolumeId, *metav1.NewDeleteOptions(0)) if err != nil { if errors.IsNotFound(err) { - log.Debugf("PVC: %q not found in the Supervisor cluster. Assuming this volume to be deleted.", req.VolumeId) + log.Debugf("PVC: %q not found in the Supervisor cluster. Assuming this volume to be deleted.", + req.VolumeId) return &csi.DeleteVolumeResponse{}, "", nil } - msg := fmt.Sprintf("DeleteVolume Request: %+v has failed. Error: %+v", *req, err) + msg := fmt.Sprintf("DeleteVolume Request: %+v has failed. Error: %+v", prototext.Format(req), err) log.Error(msg) return nil, csifault.CSIInternalFault, status.Errorf(codes.Internal, msg) } @@ -568,7 +574,7 @@ func (c *controller) ControllerPublishVolume(ctx context.Context, req *csi.Contr controllerPublishVolumeInternal := func() ( *csi.ControllerPublishVolumeResponse, string, error) { - log.Infof("ControllerPublishVolume: called with args %+v", *req) + log.Infof("ControllerPublishVolume: called with args %+v", prototext.Format(req)) // TODO: If the err is returned by invoking CNS API, then faultType should be // populated by the underlying layer. // If the request failed due to validate the request, "csi.fault.InvalidArgument" will be return. @@ -581,7 +587,8 @@ func (c *controller) ControllerPublishVolume(ctx context.Context, req *csi.Contr err := validateGuestClusterControllerPublishVolumeRequest(ctx, req) if err != nil { - msg := fmt.Sprintf("Validation for PublishVolume Request: %+v has failed. Error: %v", *req, err) + msg := fmt.Sprintf("Validation for PublishVolume Request: %+v has failed. Error: %v", + prototext.Format(req), err) log.Error(msg) return nil, csifault.CSIInvalidArgumentFault, status.Errorf(codes.Internal, msg) } @@ -914,7 +921,7 @@ func (c *controller) ControllerUnpublishVolume(ctx context.Context, req *csi.Con controllerUnpublishVolumeInternal := func() ( *csi.ControllerUnpublishVolumeResponse, string, error) { - log.Infof("ControllerUnpublishVolume: called with args %+v", *req) + log.Infof("ControllerUnpublishVolume: called with args %+v", prototext.Format(req)) // TODO: If the err is returned by invoking CNS API, then faultType should be // populated by the underlying layer. // If the request failed due to validate the request, "csi.fault.InvalidArgument" will be return. @@ -924,7 +931,8 @@ func (c *controller) ControllerUnpublishVolume(ctx context.Context, req *csi.Con err := validateGuestClusterControllerUnpublishVolumeRequest(ctx, req) if err != nil { - msg := fmt.Sprintf("Validation for UnpublishVolume Request: %+v has failed. Error: %v", *req, err) + msg := fmt.Sprintf("Validation for UnpublishVolume Request: %+v has failed. Error: %v", + prototext.Format(req), err) log.Error(msg) return nil, csifault.CSIInvalidArgumentFault, err } @@ -1206,7 +1214,7 @@ func (c *controller) ControllerExpandVolume(ctx context.Context, req *csi.Contro log.Warn(msg) return nil, csifault.CSIUnimplementedFault, status.Error(codes.Unimplemented, msg) } - log.Infof("ControllerExpandVolume: called with args %+v", *req) + log.Infof("ControllerExpandVolume: called with args %+v", prototext.Format(req)) // TODO: If the err is returned by invoking CNS API, then faultType should be // populated by the underlying layer. // If the request failed due to validate the request, "csi.fault.InvalidArgument" will be return. @@ -1351,7 +1359,7 @@ func (c *controller) ValidateVolumeCapabilities(ctx context.Context, req *csi.Va *csi.ValidateVolumeCapabilitiesResponse, error) { log := logger.GetLogger(ctx) - log.Infof("ValidateVolumeCapabilities: called with args %+v", *req) + log.Infof("ValidateVolumeCapabilities: called with args %+v", prototext.Format(req)) volCaps := req.GetVolumeCapabilities() var confirmed *csi.ValidateVolumeCapabilitiesResponse_Confirmed if err := common.IsValidVolumeCapabilities(ctx, volCaps); err == nil { @@ -1367,7 +1375,7 @@ func (c *controller) ListVolumes(ctx context.Context, req *csi.ListVolumesReques ctx = logger.NewContextWithLogger(ctx) log := logger.GetLogger(ctx) - log.Infof("ListVolumes: called with args %+v", *req) + log.Infof("ListVolumes: called with args %+v", prototext.Format(req)) return nil, status.Error(codes.Unimplemented, "") } @@ -1375,7 +1383,7 @@ func (c *controller) GetCapacity(ctx context.Context, req *csi.GetCapacityReques *csi.GetCapacityResponse, error) { ctx = logger.NewContextWithLogger(ctx) log := logger.GetLogger(ctx) - log.Infof("GetCapacity: called with args %+v", *req) + log.Infof("GetCapacity: called with args %+v", prototext.Format(req)) // Setting capacity to MaxInt64 for all topologies except for those which have been marked for deletion by VI Admin. totalcapacity := int64(math.MaxInt64) @@ -1412,7 +1420,7 @@ func (c *controller) ControllerGetCapabilities(ctx context.Context, req *csi.Con ctx = logger.NewContextWithLogger(ctx) log := logger.GetLogger(ctx) - log.Infof("ControllerGetCapabilities: called with args %+v", *req) + log.Infof("ControllerGetCapabilities: called with args %+v", prototext.Format(req)) var caps []*csi.ControllerServiceCapability for _, cap := range controllerCaps { c := &csi.ControllerServiceCapability{ @@ -1433,7 +1441,7 @@ func (c *controller) CreateSnapshot(ctx context.Context, req *csi.CreateSnapshot log := logger.GetLogger(ctx) start := time.Now() volumeType := prometheus.PrometheusBlockVolumeType - log.Infof("CreateSnapshot: called with args %+v", *req) + log.Infof("CreateSnapshot: called with args %+v", prototext.Format(req)) isBlockVolumeSnapshotWCPEnabled := commonco.ContainerOrchestratorUtility.IsFSSEnabled(ctx, common.BlockVolumeSnapshot) if !isBlockVolumeSnapshotWCPEnabled { @@ -1554,7 +1562,7 @@ func (c *controller) DeleteSnapshot(ctx context.Context, req *csi.DeleteSnapshot log := logger.GetLogger(ctx) start := time.Now() volumeType := prometheus.PrometheusBlockVolumeType - log.Infof("DeleteSnapshot: called with args %+v", *req) + log.Infof("DeleteSnapshot: called with args %+v", prototext.Format(req)) isBlockVolumeSnapshotWCPEnabled := commonco.ContainerOrchestratorUtility.IsFSSEnabled(ctx, common.BlockVolumeSnapshot) if !isBlockVolumeSnapshotWCPEnabled { return nil, logger.LogNewErrorCode(log, codes.Unimplemented, "deleteSnapshot") @@ -1625,13 +1633,13 @@ func (c *controller) ListSnapshots(ctx context.Context, req *csi.ListSnapshotsRe log := logger.GetLogger(ctx) start := time.Now() volumeType := prometheus.PrometheusBlockVolumeType - log.Infof("ListSnapshots: called with args %+v", *req) + log.Infof("ListSnapshots: called with args %+v", prototext.Format(req)) isBlockVolumeSnapshotEnabled := commonco.ContainerOrchestratorUtility.IsFSSEnabled(ctx, common.BlockVolumeSnapshot) if !isBlockVolumeSnapshotEnabled { return nil, logger.LogNewErrorCode(log, codes.Unimplemented, "listSnapshot") } listSnapshotsInternal := func() (*csi.ListSnapshotsResponse, error) { - log.Infof("ListSnapshots: called with args %+v", *req) + log.Infof("ListSnapshots: called with args %+v", prototext.Format(req)) maxEntries := common.QuerySnapshotLimit if req.MaxEntries != 0 { log.Warnf("Specifying MaxEntries in ListSnapshotRequest is not supported,"+