Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix redundant error check #29

Merged
merged 1 commit into from
Dec 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,15 @@ func runProbe(ctx context.Context, csiConn connection.CSIConnection) error {
glog.Infof("CSI driver name: %q", csiDriverName)
// Sending Probe request
glog.Infof("Sending probe request to CSI driver.")
if err := csiConn.LivenessProbe(ctx); err != nil {
return err
}
return nil
err = csiConn.LivenessProbe(ctx)
return err
}

func getCSIConnection() (connection.CSIConnection, error) {
// Connect to CSI.
glog.Infof("Attempting to open a gRPC connection with: %s", *csiAddress)
csiConn, err := connection.NewConnection(*csiAddress, *connectionTimeout)
if err != nil {
return nil, err
}
return csiConn, nil
return csiConn, err
}

func checkHealth(w http.ResponseWriter, req *http.Request) {
Expand All @@ -73,7 +68,7 @@ func checkHealth(w http.ResponseWriter, req *http.Request) {
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
w.Write([]byte(err.Error()))
glog.Infof("Failed to get connection to CSI with error: %v.", err)
glog.Errorf("Failed to get connection to CSI with error: %v.", err)
return
}
defer csiConn.Close()
Expand All @@ -82,7 +77,7 @@ func checkHealth(w http.ResponseWriter, req *http.Request) {
if err := runProbe(ctx, csiConn); err != nil {
w.WriteHeader(http.StatusInternalServerError)
w.Write([]byte(err.Error()))
glog.Infof("Health check failed with: %v.", err)
glog.Errorf("Health check failed with: %v.", err)
} else {
w.WriteHeader(http.StatusOK)
w.Write([]byte(`ok`))
Expand Down
5 changes: 1 addition & 4 deletions pkg/connection/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,7 @@ func (c *csiConnection) LivenessProbe(ctx context.Context) error {
req := csi.ProbeRequest{}

_, err := client.Probe(ctx, &req)
if err != nil {
return err
}
return nil
return err
}

func (c *csiConnection) Close() error {
Expand Down