Skip to content

Commit

Permalink
(bugbash) Fix G104 gosec warnings (#570)
Browse files Browse the repository at this point in the history

Signed-off-by: Sahil Raja <[email protected]>
  • Loading branch information
rajaSahil authored and kmova committed May 6, 2021
1 parent 76542d9 commit b376137
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 8 deletions.
6 changes: 5 additions & 1 deletion cmd/manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,11 @@ func main() {
}

// Become the leader before proceeding
leader.Become(context.TODO(), "node-disk-manager-lock")
err = leader.Become(context.TODO(), "node-disk-manager-lock")
if err != nil {
klog.Errorf("Failed to become leader, Error: %v", err)
os.Exit(1)
}

r := ready.NewFileReady()
err = r.Set()
Expand Down
5 changes: 4 additions & 1 deletion cmd/ndm_daemonset/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,10 @@ func (c *Controller) WaitForBlockDeviceCRD() {
if err != nil {
klog.Errorf("BlockDevice CRD is not available yet. Retrying after %v, error: %v", CRDRetryInterval, err)
time.Sleep(CRDRetryInterval)
c.newClientSet()
_, err := c.newClientSet()
if err != nil {
klog.Errorf("unable to set clientset field in controller struct, Error: %v",err)
}
continue
}
klog.Info("BlockDevice CRD is available")
Expand Down
5 changes: 4 additions & 1 deletion cmd/ndm_daemonset/controller/sparsefilegenerator.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,5 +220,8 @@ func (c *Controller) MarkSparseBlockDeviceStateActive(sparseFile string, sparseF

//If a BlockDevice CR already exits, update it. If not create a new one.
klog.Info("Updating the BlockDevice CR for Sparse file: ", BlockDeviceDetails.UUID)
c.CreateBlockDevice(BlockDeviceDetails.ToDevice())
err = c.CreateBlockDevice(BlockDeviceDetails.ToDevice())
if err != nil {
klog.Error("Failed to create a block device resource in etcd, Error: ", err)
}
}
5 changes: 4 additions & 1 deletion cmd/ndm_daemonset/grpc/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@ func Start() {

// Listen for requests
klog.Infof("Starting server at : %v ", Address)
grpcServer.Serve(l)
err = grpcServer.Serve(l)
if err != nil {
klog.Errorf("Unable to Serve %v", err)
}

}
}
5 changes: 4 additions & 1 deletion cmd/ndm_daemonset/probe/udevprobe.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,10 @@ func (up *udevProbe) Start() {
go up.listen()
go udevevent.Monitor()
probeEvent := newUdevProbe(up.controller)
probeEvent.scan()
err := probeEvent.scan()
if err != nil {
klog.Errorf("error while scanning system for block devices, Error: %v", err)
}
}

// Rescan syncs etcd and NDM
Expand Down
5 changes: 4 additions & 1 deletion pkg/logs/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ var logFlushFreq = pflag.Duration("log-flush-frequency", 5*time.Second, "Maximum

// TODO(thockin): This is temporary until we agree on log dirs and put those into each cmd.
func init() {
flag.Set("logtostderr", "true")
err := flag.Set("logtostderr", "true")
if err != nil {
klog.Errorf("unable to set flag, Error: %v",err)
}
}

// KlogWriter serves as a bridge between the standard log package and the klog package.
Expand Down
5 changes: 4 additions & 1 deletion pkg/smart/satadevice.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ func (d *SATA) ataIdentify() (ATACSPage, error) {
if err := d.sendSCSICDB(cdb16[:], &responseBuf); err != nil {
return identifyBuf, fmt.Errorf("error in sending SCSICDB 16 for ATA device, Error: %+v", err)
}
binary.Read(bytes.NewBuffer(responseBuf), NativeEndian, &identifyBuf)
err := binary.Read(bytes.NewBuffer(responseBuf), NativeEndian, &identifyBuf)
if err != nil {
return identifyBuf, fmt.Errorf("error in reading data, Error: %+v", err)
}
return identifyBuf, nil
}

Expand Down
5 changes: 4 additions & 1 deletion pkg/smart/scsiinquirypage.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ func (d *SCSIDev) scsiInquiry() (InquiryResponse, error) {
return response, err
}

binary.Read(bytes.NewBuffer(respBuf), NativeEndian, &response)
err := binary.Read(bytes.NewBuffer(respBuf), NativeEndian, &response)
if err != nil {
return response, fmt.Errorf("error in reading data, Error: %+v", err)
}

return response, nil
}
Expand Down

0 comments on commit b376137

Please sign in to comment.