Skip to content

Commit 070cd89

Browse files
committed
Govet fixes added
1 parent aee0f7f commit 070cd89

File tree

3 files changed

+26
-16
lines changed

3 files changed

+26
-16
lines changed

pkg/driver/controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ func (d *controllerService) ControllerPublishVolume(ctx context.Context, req *cs
216216

217217
pvInfo := map[string]string{WWNKey: disk.WWN}
218218

219-
attached, err := d.cloud.IsAttached(volumeID, nodeID)
219+
attached, _ := d.cloud.IsAttached(volumeID, nodeID)
220220
if attached {
221221
klog.V(5).Infof("ControllerPublishVolume: volume %s already attached to node %s, returning success", volumeID, nodeID)
222222
return &csi.ControllerPublishVolumeResponse{PublishContext: pvInfo}, nil

pkg/driver/driver.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,11 @@ type Driver struct {
5757
}
5858

5959
type Options struct {
60-
endpoint string
61-
extraTags map[string]string
62-
mode Mode
63-
volumeAttachLimit int64
64-
kubernetesClusterID string
65-
debug bool
60+
endpoint string
61+
extraTags map[string]string
62+
mode Mode
63+
volumeAttachLimit int64
64+
debug bool
6665
}
6766

6867
func NewDriver(options ...func(*Options)) (*Driver, error) {

pkg/fibrechannel/fibrechannel.go

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ type Connector struct {
4343
TargetWWNs []string
4444
Lun string
4545
WWIDs []string
46-
io ioHandler
4746
}
4847

4948
//OSioHandler is a wrapper that includes all the necessary io functions used for (Should be used as default io handler)
@@ -108,15 +107,19 @@ func findDeviceForPath(path string, io ioHandler) (string, error) {
108107
return "", errors.New("Illegal path for device " + devicePath)
109108
}
110109

111-
func scsiHostRescan(io ioHandler) {
110+
func scsiHostRescan(io ioHandler) error {
112111
scsiPath := "/sys/class/scsi_host/"
113112
if dirs, err := io.ReadDir(scsiPath); err == nil {
114113
for _, f := range dirs {
115114
name := scsiPath + f.Name() + "/scan"
116115
data := []byte("- - -")
117-
io.WriteFile(name, data, 0666)
116+
err := io.WriteFile(name, data, 0666)
117+
if err != nil {
118+
return fmt.Errorf("scsi host rescan failed : error: %v", err)
119+
}
118120
}
119121
}
122+
return nil
120123
}
121124

122125
//func fcHostIssueLip(io ioHandler) {
@@ -145,7 +148,7 @@ func searchDisk(c Connector, io ioHandler) (string, error) {
145148
// two-phase search:
146149
// first phase, search existing device path, if a multipath dm is found, exit loop
147150
// otherwise, in second phase, rescan scsi bus and search again, return with any findings
148-
for true {
151+
for {
149152

150153
for _, diskID := range diskIds {
151154
if len(c.TargetWWNs) != 0 {
@@ -165,7 +168,11 @@ func searchDisk(c Connector, io ioHandler) (string, error) {
165168
}
166169
// rescan and search again
167170
// rescan scsi bus
168-
scsiHostRescan(io)
171+
172+
err := scsiHostRescan(io)
173+
if err != nil {
174+
return "", err
175+
}
169176
//fcHostIssueLip(io)
170177
rescaned = true
171178
}
@@ -320,16 +327,20 @@ func detachFCDisk(devicePath string, io ioHandler) error {
320327
}
321328
arr := strings.Split(devicePath, "/")
322329
dev := arr[len(arr)-1]
323-
removeFromScsiSubsystem(dev, io)
324-
return nil
330+
err := removeFromScsiSubsystem(dev, io)
331+
return err
325332
}
326333

327334
// Removes a scsi device based upon /dev/sdX name
328-
func removeFromScsiSubsystem(deviceName string, io ioHandler) {
335+
func removeFromScsiSubsystem(deviceName string, io ioHandler) error {
329336
fileName := "/sys/block/" + deviceName + "/device/delete"
330337
glog.Infof("fc: remove device from scsi-subsystem: path: %s", fileName)
331338
data := []byte("1")
332-
io.WriteFile(fileName, data, 0666)
339+
err := io.WriteFile(fileName, data, 0666)
340+
if err != nil {
341+
return fmt.Errorf("failed remove from scsi subsystem : error: %v", err)
342+
}
343+
return nil
333344
}
334345

335346
func RemoveMultipathDevice(device string) error {

0 commit comments

Comments
 (0)