Skip to content
This repository has been archived by the owner on Mar 26, 2020. It is now read-only.

Commit

Permalink
Merge pull request #581 from prashanthpai/minor-cleanup-1
Browse files Browse the repository at this point in the history
Fix minor lint and logging issues
  • Loading branch information
aravindavk authored Feb 22, 2018
2 parents df57630 + 1e3e4a9 commit ddadad7
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 20 deletions.
2 changes: 1 addition & 1 deletion glustercli/cmd/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ var eventsWebhookListCmd = &cobra.Command{
log.WithFields(log.Fields{
"error": err.Error(),
}).Error("failed to get list of Webhooks")
failure("Failed to get list of registerd Webhooks", err, 1)
failure("Failed to get list of registered Webhooks", err, 1)
}

if len(webhooks) > 0 {
Expand Down
3 changes: 2 additions & 1 deletion glusterd2/commands/global/setglobaloptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ func setGlobalOptionsHandler(w http.ResponseWriter, r *http.Request) {
}

if err := cluster.UpdateCluster(c); err != nil {
restutils.SendHTTPError(ctx, w, http.StatusInternalServerError, fmt.Sprint("Failed to update store with cluster attributes %s: %s", err.Error()), api.ErrCodeDefault)
restutils.SendHTTPError(ctx, w, http.StatusInternalServerError,
fmt.Sprint("Failed to update store with cluster attributes %s", err.Error()), api.ErrCodeDefault)
return
}

Expand Down
5 changes: 1 addition & 4 deletions glusterd2/commands/volumes/optiongroup-create.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ func validateOptionSet(req api.OptionGroupReq) error {
if err := validateOptions(o1); err != nil {
return err
}
if err := validateOptions(o2); err != nil {
return err
}
return nil
return validateOptions(o2)
}

func optionGroupCreateHandler(w http.ResponseWriter, r *http.Request) {
Expand Down
2 changes: 1 addition & 1 deletion glusterd2/events/global.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func globalHandler(ev *Event) {
}

// Putting event with a TTL so that we don't have stale events lingering in store
// Using a TTL of 10 seconds should allow all members in the cluster to recieve event
// Using a TTL of 10 seconds should allow all members in the cluster to receive event
// TODO: Allow timeout to be customizable
l, err := store.Store.Grant(store.Store.Ctx(), 10)
if err != nil {
Expand Down
15 changes: 11 additions & 4 deletions glusterd2/events/nfs-ganesha.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package events

import (
"fmt"
"os"
"os/exec"

log "github.com/sirupsen/logrus"
Expand All @@ -12,6 +13,8 @@ const (
eventVolumeStopped = "volume.stopped"
)

const dbusScript = "/usr/libexec/ganesha/dbus-send.sh"

type ganesha struct{}

func (g *ganesha) Handle(e *Event) {
Expand All @@ -21,11 +24,15 @@ func (g *ganesha) Handle(e *Event) {
} else if e.Name == eventVolumeStopped {
option = "off"
}
dbuscmdStr := fmt.Sprintf("/usr/libexec/ganesha/dbus-send.sh /etc/ganesha/ %s %s", option, e.Data["volume.name"])

if _, err := os.Stat(dbusScript); os.IsNotExist(err) {
return
}
// TODO: Check if ganesha is running
dbuscmdStr := fmt.Sprintf("%s /etc/ganesha/ %s %s", dbusScript, option, e.Data["volume.name"])
ganeshaCmd := exec.Command("/bin/sh", "-c", dbuscmdStr)
err := ganeshaCmd.Run()
if err != nil {
log.WithError(err).WithField("command", dbuscmdStr).Error("Failed to execute command")
if err := ganeshaCmd.Run(); err != nil {
log.WithError(err).WithField("command", dbuscmdStr).Warn("Failed to execute command")
} else {
log.WithField("command", dbuscmdStr).Debug("Command succeeded")
}
Expand Down
5 changes: 1 addition & 4 deletions glusterd2/xlator/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,5 @@ func registerAllValidations() error {
if err := registerValidation("afr", validateReplica); err != nil {
return err
}
if err := registerValidation("bit-rot", validateBitrot); err != nil {
return err
}
return nil
return registerValidation("bit-rot", validateBitrot)
}
6 changes: 1 addition & 5 deletions pkg/sunrpc/clientcodec.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,7 @@ func (c *clientCodec) ReadResponseHeader(resp *rpc.Response) error {
delete(c.pending, resp.Seq)
c.mutex.Unlock()

if err := c.checkReplyForErr(&reply); err != nil {
return err
}

return nil
return c.checkReplyForErr(&reply)
}

func (c *clientCodec) ReadResponseBody(result interface{}) error {
Expand Down

0 comments on commit ddadad7

Please sign in to comment.