Skip to content

Commit

Permalink
gofumpt code
Browse files Browse the repository at this point in the history
  • Loading branch information
mdutka-dell committed Oct 30, 2023
1 parent 4783033 commit d3265eb
Show file tree
Hide file tree
Showing 16 changed files with 298 additions and 273 deletions.
141 changes: 67 additions & 74 deletions service/controller.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion service/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
func TestControllerProbe(t *testing.T) {
DriverConfig = testConf.unityConfig

//Dynamic update of config
// Dynamic update of config
err := testConf.service.BeforeServe(context.Background(), nil, nil)
if err != nil {
t.Fatalf("TestBeforeServe failed with error %v", err)
Expand Down
28 changes: 17 additions & 11 deletions service/csi_extension_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,23 +49,29 @@ var GetMetricsCollection = getMetricsCollection
var CreateMetricsCollection = createMetricsCollection

// MetricsCollectionInterval is used for interval to use in the creation of a Unity MetricsCollection
var MetricsCollectionInterval = 5 // seconds
// CollectionWait - Collection wait time
var CollectionWait = (MetricsCollectionInterval + 1) * 1000
var (
MetricsCollectionInterval = 5 // seconds
// CollectionWait - Collection wait time
CollectionWait = (MetricsCollectionInterval + 1) * 1000
)

var metricsCollectionCache sync.Map
var currentIOCount = []string{
"sp.*.storage.lun.*.currentIOCount",
}
var (
metricsCollectionCache sync.Map
currentIOCount = []string{
"sp.*.storage.lun.*.currentIOCount",
}
)

Check failure on line 63 in service/csi_extension_server.go

View workflow job for this annotation

GitHub Actions / golangci-lint

File is not `gofumpt`-ed (gofumpt)
var fileSystemRWs = []string{
"sp.*.storage.filesystem.*.clientReads",
"sp.*.storage.filesystem.*.clientWrites",
}

var cacheRWLock sync.RWMutex
var kickoffOnce sync.Once
var refreshCount atomic.Int32
var refreshEnabled bool
var (
cacheRWLock sync.RWMutex
kickoffOnce sync.Once
refreshCount atomic.Int32
refreshEnabled bool
)

// Constants that can be used across module
const (
Expand Down
85 changes: 52 additions & 33 deletions service/csi_extension_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,8 @@ func TestValidateVolumeHostConnectivityVolumeIds(t *testing.T) {
Connected: true,
Messages: []string{
"iSCSI Health is good for array:array1, Health:ALRT_COMPONENT_OK",
"sv_1 on array array1 has no IOs"},
"sv_1 on array array1 has no IOs",
},
IosInProgress: false,
},
},
Expand All @@ -247,7 +248,8 @@ func TestValidateVolumeHostConnectivityVolumeIds(t *testing.T) {
Connected: true,
Messages: []string{
"iSCSI Health is good for array:array1, Health:ALRT_COMPONENT_OK",
"sv_1 on array array1 has no IOs"},
"sv_1 on array array1 has no IOs",
},
IosInProgress: false,
},
},
Expand All @@ -270,7 +272,8 @@ func TestValidateVolumeHostConnectivityVolumeIds(t *testing.T) {
VolumeIds: []string{
"vol1-iscsi-array1-sv_1",
"vol1-iscsi-array2-sv_2",
"vol1-iscsi-array3-sv_3"},
"vol1-iscsi-array3-sv_3",
},
},
expectedResponse: &podmon.ValidateVolumeHostConnectivityResponse{
Connected: true,
Expand Down Expand Up @@ -453,7 +456,6 @@ func TestValidateVolumeHostConnectivityFC(t *testing.T) {

var testCases map[string]testCaseSpec
testCases = map[string]testCaseSpec{

"Default Array, Good FC HostConnections": {
setup: func() {
testConf.service.opts.AutoProbe = true
Expand Down Expand Up @@ -577,7 +579,8 @@ func TestVolumeIOCheck(t *testing.T) {
VolumeIds: []string{
"vol1-iscsi-array1-sv_1",
"vol1-iscsi-array2-sv_2",
"vol1-iscsi-array3-sv_3"},
"vol1-iscsi-array3-sv_3",
},
},
expectedResponse: &podmon.ValidateVolumeHostConnectivityResponse{
Connected: true,
Expand Down Expand Up @@ -609,7 +612,8 @@ func TestVolumeIOCheck(t *testing.T) {
VolumeIds: []string{
"vol1-iscsi-array1-sv_1",
"vol1-iscsi-array2-sv_2",
"vol1-iscsi-array3-sv_3"},
"vol1-iscsi-array3-sv_3",
},
},
expectedResponse: &podmon.ValidateVolumeHostConnectivityResponse{
Connected: true,
Expand Down Expand Up @@ -648,7 +652,8 @@ func TestVolumeIOCheck(t *testing.T) {
VolumeIds: []string{
"vol1-iscsi-array1-sv_1",
"vol1-iscsi-array2-sv_2",
"vol1-iscsi-array3-sv_3"},
"vol1-iscsi-array3-sv_3",
},
},
expectedResponse: &podmon.ValidateVolumeHostConnectivityResponse{
Connected: true,
Expand Down Expand Up @@ -688,7 +693,8 @@ func TestVolumeIOCheck(t *testing.T) {
VolumeIds: []string{
"vol1-iscsi-array1-sv_1",
"vol1-iscsi-array2-sv_2",
"vol1-iscsi-array3-sv_3"},
"vol1-iscsi-array3-sv_3",
},
},
expectedResponse: &podmon.ValidateVolumeHostConnectivityResponse{
Connected: true,
Expand Down Expand Up @@ -756,7 +762,8 @@ func TestVolumeIOCheck(t *testing.T) {
VolumeIds: []string{
"vol1-iscsi-array1-sv_1",
"vol1-iscsi-array2-sv_2",
"vol1-iscsi-array3-sv_3"},
"vol1-iscsi-array3-sv_3",
},
},
expectedResponse: &podmon.ValidateVolumeHostConnectivityResponse{
Connected: true,
Expand Down Expand Up @@ -803,7 +810,8 @@ func TestFileSystemIOCheck(t *testing.T) {
VolumeIds: []string{
"vol1-nfs-array1-fs_1",
"vol1-nfs-array2-fs_2",
"vol1-nfs-array3-fs_3"},
"vol1-nfs-array3-fs_3",
},
},
expectedResponse: &podmon.ValidateVolumeHostConnectivityResponse{
Connected: true,
Expand Down Expand Up @@ -835,7 +843,8 @@ func TestFileSystemIOCheck(t *testing.T) {
VolumeIds: []string{
"vol1-nfs-array1-fs_1",
"vol1-nfs-array2-fs_2",
"vol1-nfs-array3-fs_3"},
"vol1-nfs-array3-fs_3",
},
},
expectedResponse: &podmon.ValidateVolumeHostConnectivityResponse{
Connected: true,
Expand Down Expand Up @@ -884,7 +893,8 @@ func TestFileSystemIOCheck(t *testing.T) {
VolumeIds: []string{
"vol1-nfs-array1-fs_1",
"vol1-nfs-array2-fs_2",
"vol1-nfs-array3-fs_3"},
"vol1-nfs-array3-fs_3",
},
},
expectedResponse: &podmon.ValidateVolumeHostConnectivityResponse{
Connected: true,
Expand Down Expand Up @@ -962,7 +972,8 @@ func TestFileSystemIOCheck(t *testing.T) {
VolumeIds: []string{
"vol1-nfs-array1-fs_1",
"vol1-nfs-array2-fs_2",
"vol1-nfs-array3-fs_3"},
"vol1-nfs-array3-fs_3",
},
},
expectedResponse: &podmon.ValidateVolumeHostConnectivityResponse{
Connected: true,
Expand Down Expand Up @@ -1044,7 +1055,8 @@ func TestFileSystemIOCheck(t *testing.T) {
VolumeIds: []string{
"vol1-nfs-array1-fs_1",
"vol1-nfs-array2-fs_2",
"vol1-nfs-array3-fs_3"},
"vol1-nfs-array3-fs_3",
},
},
expectedResponse: &podmon.ValidateVolumeHostConnectivityResponse{
Connected: true,
Expand Down Expand Up @@ -1102,7 +1114,8 @@ func TestFileSystemIOCheck(t *testing.T) {
VolumeIds: []string{
"vol1-nfs-array1-fs_1",
"vol1-nfs-array2-fs_2",
"vol1-nfs-array3-fs_3"},
"vol1-nfs-array3-fs_3",
},
},
expectedResponse: &podmon.ValidateVolumeHostConnectivityResponse{
Connected: true,
Expand Down Expand Up @@ -1164,7 +1177,8 @@ func TestFileSystemIOCheck(t *testing.T) {
VolumeIds: []string{
"vol1-nfs-array1-fs_1",
"vol1-nfs-array2-fs_2",
"vol1-nfs-array3-fs_3"},
"vol1-nfs-array3-fs_3",
},
},
expectedResponse: &podmon.ValidateVolumeHostConnectivityResponse{
Connected: true,
Expand Down Expand Up @@ -1227,7 +1241,8 @@ func TestFileSystemIOCheck(t *testing.T) {
VolumeIds: []string{
"vol1-nfs-array1-fs_1",
"vol1-nfs-array2-fs_2",
"vol1-nfs-array3-fs_3"},
"vol1-nfs-array3-fs_3",
},
},
expectedResponse: &podmon.ValidateVolumeHostConnectivityResponse{
Connected: true,
Expand Down Expand Up @@ -1303,7 +1318,8 @@ func TestFileSystemIOCheck(t *testing.T) {
VolumeIds: []string{
"vol1-nfs-array1-fs_1",
"vol1-nfs-array2-fs_2",
"vol1-nfs-array3-fs_3"},
"vol1-nfs-array3-fs_3",
},
},
expectedResponse: &podmon.ValidateVolumeHostConnectivityResponse{
Connected: true,
Expand Down Expand Up @@ -1385,7 +1401,8 @@ func TestFileSystemIOCheck(t *testing.T) {
// <PV_NAME>-<PROTOCOL>-<ARRAYID>-<LUN_ID>
VolumeIds: []string{
"vol1-nfs-array1-fs_1",
"vol1-nfs-array2-fs_2"},
"vol1-nfs-array2-fs_2",
},
},
expectedResponse: &podmon.ValidateVolumeHostConnectivityResponse{
Connected: true,
Expand Down Expand Up @@ -1644,20 +1661,22 @@ func runTestCases(ctx context.Context, t *testing.T, testCases map[string]testCa
}
}

var mockGetArrayFromVolumeFail string
var mockGetArrayIDErr error
var mockRequireProbeErr error
var mockGetHost *types.Host
var mockGetHostErr error
var mockGetUnity *gounity.Client
var mockGetUnityErr error
var mockFindHostInitiatorErr error
var mockBadInitiator string
var mockFindInitatorFail string
var mockGetMetricsCollectionError error
var mockCreateMetricsCollectionError error
var mockMetricsCollectionID int
var mockMetricValueMap map[string]interface{}
var (
mockGetArrayFromVolumeFail string
mockGetArrayIDErr error
mockRequireProbeErr error
mockGetHost *types.Host
mockGetHostErr error
mockGetUnity *gounity.Client
mockGetUnityErr error
mockFindHostInitiatorErr error
mockBadInitiator string
mockFindInitatorFail string
mockGetMetricsCollectionError error
mockCreateMetricsCollectionError error
mockMetricsCollectionID int
mockMetricValueMap map[string]interface{}
)

func defaultMocks() {
GetHostID = mockGetHostID
Expand Down
12 changes: 6 additions & 6 deletions service/envvars.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ const (
// violation of the CSI spec
EnvAutoProbe = "X_CSI_UNITY_AUTOPROBE"

//EnvPvtMountDir is required to Node Unstage volume where the volume has been mounted
//as a global mount via CSI-Unity v1.0 or v1.1
// EnvPvtMountDir is required to Node Unstage volume where the volume has been mounted
// as a global mount via CSI-Unity v1.0 or v1.1
EnvPvtMountDir = "X_CSI_PRIVATE_MOUNT_DIR"

//EnvEphemeralStagingPath - Ephemeral staging path
// EnvEphemeralStagingPath - Ephemeral staging path
EnvEphemeralStagingPath = "X_CSI_EPHEMERAL_STAGING_PATH"

// EnvISCSIChroot is the path to which the driver will chroot before
Expand All @@ -44,14 +44,14 @@ const (
// EnvKubeConfigPath indicates kubernetes configuration that has to be used by CSI Driver
EnvKubeConfigPath = "KUBECONFIG"

//SyncNodeInfoTimeInterval - Time interval to add node info to array. Default 60 minutes.
//X_CSI_UNITY_SYNC_NODEINFO_INTERVAL has been deprecated and will be removes in a future release
// SyncNodeInfoTimeInterval - Time interval to add node info to array. Default 60 minutes.
// X_CSI_UNITY_SYNC_NODEINFO_INTERVAL has been deprecated and will be removes in a future release
SyncNodeInfoTimeInterval = "X_CSI_UNITY_SYNC_NODEINFO_INTERVAL"

// EnvAllowRWOMultiPodAccess - Environment variable to configure sharing of a single volume across multiple pods within the same node
// Multi-node access is still not allowed for ReadWriteOnce Mount volumes.
// Enabling this option techincally violates the CSI 1.3 spec in the NodePublishVolume stating the required error returns.
//X_CSI_UNITY_ALLOW_MULTI_POD_ACCESS has been deprecated and will be removes in a future release
// X_CSI_UNITY_ALLOW_MULTI_POD_ACCESS has been deprecated and will be removes in a future release
EnvAllowRWOMultiPodAccess = "X_CSI_UNITY_ALLOW_MULTI_POD_ACCESS"

// EnvIsVolumeHealthMonitorEnabled - Environment variable to enable/disable health monitor of CSI volumes
Expand Down
10 changes: 6 additions & 4 deletions service/identity.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ import (
func (s *service) Probe(
ctx context.Context,
req *csi.ProbeRequest) (
*csi.ProbeResponse, error) {
*csi.ProbeResponse, error,
) {
ctx, log, _ := GetRunidLog(ctx)
log.Infof("Executing Probe with args: %+v", *req)
if strings.EqualFold(s.mode, "controller") {
Expand All @@ -47,8 +48,8 @@ func (s *service) Probe(
func (s *service) GetPluginInfo(
ctx context.Context,
req *csi.GetPluginInfoRequest) (
*csi.GetPluginInfoResponse, error) {

*csi.GetPluginInfoResponse, error,
) {
return &csi.GetPluginInfoResponse{
Name: Name,
VendorVersion: core.SemVer,
Expand All @@ -59,7 +60,8 @@ func (s *service) GetPluginInfo(
func (s *service) GetPluginCapabilities(
ctx context.Context,
req *csi.GetPluginCapabilitiesRequest) (
*csi.GetPluginCapabilitiesResponse, error) {
*csi.GetPluginCapabilitiesResponse, error,
) {
ctx, log, _ := GetRunidLog(ctx)
log.Infof("Executing GetPluginCapabilities with args: %+v", *req)
return &csi.GetPluginCapabilitiesResponse{
Expand Down
Loading

0 comments on commit d3265eb

Please sign in to comment.