Skip to content

Commit 7509075

Browse files
authored
fix more linting errors (#161)
Signed-off-by: Raunak <[email protected]>
1 parent e9e88bb commit 7509075

File tree

11 files changed

+38
-26
lines changed

11 files changed

+38
-26
lines changed

connectivity/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ func (client *Client) DoJSON(r *Request) (int, error) {
188188
err = decode(res.Body, r.ResponseError, r)
189189
if err != nil {
190190
log.Error("Failed to decode error response.")
191-
r.ResponseError = "Failed to decode error response, Error:" + string(res.StatusCode)
191+
r.ResponseError = "Failed to decode error response, Error:" + fmt.Sprintf("%d", res.StatusCode)
192192
return res.StatusCode, err
193193
}
194194
}

dockerplugin/handler/create.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@ import (
66
"encoding/json"
77
"errors"
88
"fmt"
9-
log "github.com/hpe-storage/common-host-libs/logger"
109
"net/http"
1110
"os"
1211
"strings"
1312
"time"
1413

14+
log "github.com/hpe-storage/common-host-libs/logger"
15+
1516
"github.com/hpe-storage/common-host-libs/chapi"
1617
"github.com/hpe-storage/common-host-libs/connectivity"
1718
"github.com/hpe-storage/common-host-libs/dockerplugin/plugin"
@@ -219,7 +220,7 @@ func VolumeDriverCreate(w http.ResponseWriter, r *http.Request) {
219220
// Attach the device, Create filesystem on the device
220221
// nolint : gocyclo
221222
func createFileSystemOnVolume(vols []*model.Volume, pluginReq *PluginRequest, fsOpts *model.FilesystemOpts) (*model.Device, error) {
222-
log.Trace("createFileSystemOnVolume called for %+v", vols)
223+
log.Tracef("createFileSystemOnVolume called for %+v", vols)
223224
log.Traceln("Vol :", vols, "Host :", pluginReq.Host)
224225

225226
// obtain chapi client with large timeout of 5 minutes max for creation

dockerplugin/handler/mount.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,19 @@ import (
66
"encoding/json"
77
"errors"
88
"fmt"
9-
"github.com/hpe-storage/common-host-libs/chapi"
10-
"github.com/hpe-storage/common-host-libs/connectivity"
11-
"github.com/hpe-storage/common-host-libs/dockerplugin/plugin"
12-
"github.com/hpe-storage/common-host-libs/dockerplugin/provider"
13-
log "github.com/hpe-storage/common-host-libs/logger"
14-
"github.com/hpe-storage/common-host-libs/model"
159
"net/http"
1610
"os"
1711
"reflect"
1812
"strconv"
1913
"strings"
2014
"time"
15+
16+
"github.com/hpe-storage/common-host-libs/chapi"
17+
"github.com/hpe-storage/common-host-libs/connectivity"
18+
"github.com/hpe-storage/common-host-libs/dockerplugin/plugin"
19+
"github.com/hpe-storage/common-host-libs/dockerplugin/provider"
20+
log "github.com/hpe-storage/common-host-libs/logger"
21+
"github.com/hpe-storage/common-host-libs/model"
2122
)
2223

2324
const (
@@ -130,7 +131,7 @@ func VolumeDriverMount(w http.ResponseWriter, r *http.Request) {
130131
return
131132
}
132133
volume := volResp.Volume
133-
log.Trace("retrieved volume response from container provider for volume: %+v", volume)
134+
log.Tracef("retrieved volume response from container provider for volume: %+v", volume)
134135

135136
//4. Get mounts from host
136137
err = chapiClient.GetMounts(&respMount, volume.SerialNumber)
@@ -480,7 +481,7 @@ func cleanupStaleMounts(containerProviderClient *connectivity.Client, chapiClien
480481
// 1. the volume is not in use
481482
// 2. the volume is not connected to this iscsi/fc host
482483
if !volumeInfo.InUse || (!isCurrentHostAttachedIscsi(volumeInfo, pluginReq) && !isCurrentHostAttachedFC(volumeInfo, pluginReq)) {
483-
log.Tracef("device state is %s, execute unmount on existing mounts for device %s", device.State, volumeInfo.InUse, device.MpathName)
484+
log.Tracef("device state is %s, execute unmount on existing mounts for device %v %s", device.State, volumeInfo.InUse, device.MpathName)
484485
// check if volume is not in use or in use by a different host
485486
// iterate through all the mounts and unmount
486487
for _, mount := range respMount {

dockerplugin/handler/remove.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@ package handler
55
import (
66
"encoding/json"
77
"errors"
8+
"net/http"
9+
"time"
10+
811
"github.com/hpe-storage/common-host-libs/chapi"
912
"github.com/hpe-storage/common-host-libs/connectivity"
1013
"github.com/hpe-storage/common-host-libs/dockerplugin/plugin"
1114
"github.com/hpe-storage/common-host-libs/dockerplugin/provider"
1215
log "github.com/hpe-storage/common-host-libs/logger"
13-
"net/http"
14-
"time"
1516
)
1617

1718
//@APIVersion 1.0.0
@@ -70,7 +71,7 @@ func VolumeDriverRemove(w http.ResponseWriter, r *http.Request) {
7071
}
7172

7273
volume := volResp.Volume
73-
log.Trace("Volume found :%+v", volume)
74+
log.Tracef("Volume found :%+v", volume)
7475

7576
// Check if the volume has ACR before we attempt to delete the volume
7677
log.Tracef("volume status is %+v ", volResp.Volume.Status)

dockerplugin/plugin/plugin.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ func CreateConfDirectory(confDir string) error {
268268
log.Trace("createConfDirectory called with ", confDir)
269269
_, isDir, err := util.FileExists(confDir)
270270
if err != nil {
271-
log.Error("CreateConfDirectory failed for %s, err %s", confDir, err.Error())
271+
log.Errorf("CreateConfDirectory failed for %s, err %s", confDir, err.Error())
272272
return err
273273
}
274274
if isDir == false {

linux/device.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ func setAltFullPathName(dev *model.Device) (err error) {
392392

393393
// Helper function to perform rescan and detect the newly attached volume (FC/iSCSI volume)
394394
func rescanLoginVolume(volume *model.Volume) error {
395-
log.Traceln(">>>>> rescanLoginVolume %v", volume, "and accessProtocol", volume.AccessProtocol)
395+
log.Traceln(">>>>> rescanLoginVolume", volume, "and accessProtocol", volume.AccessProtocol)
396396
defer log.Traceln("<<<< rescanLoginVolume")
397397
var err error
398398
var primaryVolObj *model.Volume
@@ -441,7 +441,7 @@ func rescanLoginVolume(volume *model.Volume) error {
441441

442442
func rescanLoginVolumeForBackend(volObj *model.Volume) error {
443443

444-
log.Traceln("Called rescanLoginVolumeForBackend %v", volObj, "and accessProtocol", volObj.AccessProtocol)
444+
log.Traceln("Called rescanLoginVolumeForBackend", volObj, "and accessProtocol", volObj.AccessProtocol)
445445
var err error
446446
if strings.EqualFold(volObj.AccessProtocol, "fc") {
447447
// FC volume

logger/logger_test.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"strings"
99
"testing"
1010

11-
"github.com/hpe-storage/common-host-libs/logger"
1211
log "github.com/sirupsen/logrus"
1312
"github.com/stretchr/testify/assert"
1413
)
@@ -151,22 +150,22 @@ func TestInitLogging(t *testing.T) {
151150
}
152151

153152
func TestInitJaeger(t *testing.T) {
154-
_, lg := logger.InitLogging("test.log", nil, true, true)
153+
_, lg := InitLogging("test.log", nil, true, true)
155154

156155
lg.Info("************** Start Workflow 1 **************")
157156
lg.Info("********** Workflow 1 Line 1 **********")
158157
s := lg.StartContext("Workflow 2")
159158
lg.Info("**************** Start Workflow 2 *****************")
160159
lg.Info("********** Workflow 2 Line 1 ******************")
161-
logger.EndContext(s)
160+
EndContext(s)
162161
sp := lg.StartContext("Workflow 2")
163162
lg.Info("**************** Start Workflow 2 *****************")
164163
lg.Info("********** Workflow 2 Line 1 ******************")
165-
logger.EndContext(sp)
164+
EndContext(sp)
166165
sp2 := lg.StartContext("Workflow 3")
167166
lg.Info("**************** Start Workflow 3 *****************")
168167
lg.Info("********** Workflow 3 Line 1 ******************")
169-
logger.EndContext(sp2)
168+
EndContext(sp2)
170169
lg.CloseTracer()
171170

172171
}

logger/test.log

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
time="2021-08-04T10:13:40-07:00" level=info msg="Initialized logging." alsoLogToStderr=true logFileLocation=test.log logLevel=info
2+
time="2021-08-04T10:13:40-07:00" level=info msg="Span Context --- Traceid:Spanid:ParentSpanid:Flags : 11408528cb21a24e:11408528cb21a24e:0000000000000000:1"
3+
time="2021-08-04T10:13:40-07:00" level=info msg="************** Start Workflow 1 **************" file="logger_test.go:153"
4+
time="2021-08-04T10:13:40-07:00" level=info msg="********** Workflow 1 Line 1 **********" file="logger_test.go:153"
5+
time="2021-08-04T10:13:40-07:00" level=info msg="**************** Start Workflow 2 *****************" file="logger_test.go:153"
6+
time="2021-08-04T10:13:40-07:00" level=info msg="********** Workflow 2 Line 1 ******************" file="logger_test.go:153"
7+
time="2021-08-04T10:13:40-07:00" level=info msg="**************** Start Workflow 2 *****************" file="logger_test.go:153"
8+
time="2021-08-04T10:13:40-07:00" level=info msg="********** Workflow 2 Line 1 ******************" file="logger_test.go:153"
9+
time="2021-08-04T10:13:40-07:00" level=info msg="**************** Start Workflow 3 *****************" file="logger_test.go:153"
10+
time="2021-08-04T10:13:40-07:00" level=info msg="********** Workflow 3 Line 1 ******************" file="logger_test.go:153"

storageprovider/csp/container_storage_provider.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -937,12 +937,12 @@ func getCspClient(credentials *storageprovider.Credentials) (*connectivity.Clien
937937
cspURI := fmt.Sprintf("http://%s:%d", credentials.ServiceName, credentials.ServicePort)
938938

939939
if credentials.CspClientTimeout == 0 {
940-
credentials.CspClientTimeout = storageprovider.DefaultCSPClientTimeout
940+
credentials.CspClientTimeout = storageprovider.DefaultCSPClientTimeout
941941
}
942942
log.Tracef(">>>>> getCspClient (service) using URI %s and username %s with timeout set to %d seconds", cspURI, credentials.Username, credentials.CspClientTimeout)
943943
defer log.Trace("<<<<< getCspClient")
944944

945-
cspHTTPClientTimeout := time.Duration(credentials.CspClientTimeout)*time.Second
945+
cspHTTPClientTimeout := time.Duration(credentials.CspClientTimeout) * time.Second
946946
// Setup HTTP client to the CSP service
947947
cspClient := connectivity.NewHTTPClientWithTimeout(cspURI, cspHTTPClientTimeout)
948948
return cspClient, nil

storageprovider/csp/container_storage_provider_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func getBackend(t *testing.T) string {
4141

4242
// nolint: gocyclo
4343
func _TestPluginSuite(t *testing.T) {
44-
log.InitLogging("container-storage-provider-test.log", nil, false)
44+
log.InitLogging("container-storage-provider-test.log", nil, false, false)
4545

4646
provider := realCsp(t)
4747

0 commit comments

Comments
 (0)