mirror of
https://github.com/gluster/glusterd2.git
synced 2026-02-05 12:45:38 +01:00
log errors with log.WithError()
during error logging we should log with WithError() Signed-off-by: Madhu Rajanna <mrajanna@redhat.com>
This commit is contained in:
committed by
Prashanth Pai
parent
f305a55cae
commit
3c9ca8411b
@@ -56,10 +56,7 @@ var bitrotEnableCmd = &cobra.Command{
|
||||
err := client.BitrotEnable(volname)
|
||||
if err != nil {
|
||||
if GlobalFlag.Verbose {
|
||||
log.WithFields(log.Fields{
|
||||
"volume": volname,
|
||||
"error": err.Error(),
|
||||
}).Error("failed to enable bitrot")
|
||||
log.WithError(err).WithField("volume", volname).Error("failed to enable bitrot")
|
||||
}
|
||||
failure(fmt.Sprintf("Failed to enable bitrot for volume %s\n", volname), err, 1)
|
||||
}
|
||||
@@ -77,10 +74,7 @@ var bitrotDisableCmd = &cobra.Command{
|
||||
err := client.BitrotDisable(volname)
|
||||
if err != nil {
|
||||
if GlobalFlag.Verbose {
|
||||
log.WithFields(log.Fields{
|
||||
"volume": volname,
|
||||
"error": err.Error(),
|
||||
}).Error("failed to disable bitrot")
|
||||
log.WithError(err).WithField("volume", volname).Error("failed to disable bitrot")
|
||||
}
|
||||
failure(fmt.Sprintf("Failed to disable bitrot for volume %s\n", volname), err, 1)
|
||||
}
|
||||
@@ -103,10 +97,9 @@ var bitrotScrubThrottleCmd = &cobra.Command{
|
||||
err := volumeOptionJSONHandler(cmd, volname, option)
|
||||
if err != nil {
|
||||
if GlobalFlag.Verbose {
|
||||
log.WithFields(log.Fields{
|
||||
log.WithError(err).WithFields(log.Fields{
|
||||
"volume": volname,
|
||||
"value": args[1],
|
||||
"error": err.Error(),
|
||||
}).Error("failed to set scrub-throttle")
|
||||
}
|
||||
failure(fmt.Sprintf("Failed to set bitrot scrub throttle to %s for volume %s", args[1], volname), err, 1)
|
||||
@@ -130,10 +123,9 @@ var bitrotScrubFrequencyCmd = &cobra.Command{
|
||||
err := volumeOptionJSONHandler(cmd, volname, option)
|
||||
if err != nil {
|
||||
if GlobalFlag.Verbose {
|
||||
log.WithFields(log.Fields{
|
||||
log.WithError(err).WithFields(log.Fields{
|
||||
"volume": volname,
|
||||
"value": args[1],
|
||||
"error": err.Error(),
|
||||
}).Error("failed to set scrub-frequency")
|
||||
}
|
||||
failure(fmt.Sprintf("Failed to set bitrot scrub frequency to %s for volume %s", args[1], volname), err, 1)
|
||||
@@ -160,10 +152,9 @@ var bitrotScrubCmd = &cobra.Command{
|
||||
err := volumeOptionJSONHandler(cmd, volname, option)
|
||||
if err != nil {
|
||||
if GlobalFlag.Verbose {
|
||||
log.WithFields(log.Fields{
|
||||
log.WithError(err).WithFields(log.Fields{
|
||||
"volume": volname,
|
||||
"value": args[1],
|
||||
"error": err.Error(),
|
||||
}).Error("Bitrot scrub", scrubCmd, "command failed")
|
||||
}
|
||||
failure(fmt.Sprintf("Failed to %s bitrot scrub for volume %s", args[1], volname), err, 1)
|
||||
@@ -174,10 +165,8 @@ var bitrotScrubCmd = &cobra.Command{
|
||||
scrubStatus, err := client.BitrotScrubStatus(volname)
|
||||
if err != nil {
|
||||
if GlobalFlag.Verbose {
|
||||
log.WithFields(log.Fields{
|
||||
"volume": volname,
|
||||
"error": err.Error(),
|
||||
}).Error("failed to get bitrot scrub status")
|
||||
log.WithError(err).WithField(
|
||||
"volume", volname).Error("failed to get bitrot scrub status")
|
||||
}
|
||||
failure(fmt.Sprintf("Failed to get bitrot scrub status for volume %s\n", volname), err, 1)
|
||||
}
|
||||
@@ -221,10 +210,8 @@ var bitrotScrubCmd = &cobra.Command{
|
||||
err := client.BitrotScrubOndemand(volname)
|
||||
if err != nil {
|
||||
if GlobalFlag.Verbose {
|
||||
log.WithFields(log.Fields{
|
||||
"volume": volname,
|
||||
"error": err.Error(),
|
||||
}).Error("failed to start bitrot scrub on demand")
|
||||
log.WithError(err).WithField(
|
||||
"volume", volname).Error("failed to start bitrot scrub on demand")
|
||||
}
|
||||
failure(fmt.Sprintf("Failed to start bitrot scrub on demand for volume %s\n", volname), err, 1)
|
||||
}
|
||||
|
||||
@@ -33,10 +33,9 @@ var deviceAddCmd = &cobra.Command{
|
||||
|
||||
if err != nil {
|
||||
if GlobalFlag.Verbose {
|
||||
log.WithFields(log.Fields{
|
||||
log.WithError(err).WithFields(log.Fields{
|
||||
"device": devname,
|
||||
"peerid": peerid,
|
||||
"error": err.Error(),
|
||||
}).Error("device add failed")
|
||||
}
|
||||
failure("Device add failed", err, 1)
|
||||
|
||||
@@ -46,10 +46,7 @@ var eventsWebhookAddCmd = &cobra.Command{
|
||||
err := client.WebhookAdd(url, flagWebhookAddCmdToken, flagWebhookAddCmdSecret)
|
||||
if err != nil {
|
||||
if GlobalFlag.Verbose {
|
||||
log.WithFields(log.Fields{
|
||||
"url": url,
|
||||
"error": err.Error(),
|
||||
}).Error("failed to add webhook")
|
||||
log.WithError(err).WithField("url", url).Error("failed to add webhook")
|
||||
}
|
||||
failure("Failed to add Webhook", err, 1)
|
||||
}
|
||||
@@ -66,10 +63,7 @@ var eventsWebhookDeleteCmd = &cobra.Command{
|
||||
err := client.WebhookDelete(url)
|
||||
if err != nil {
|
||||
if GlobalFlag.Verbose {
|
||||
log.WithFields(log.Fields{
|
||||
"url": url,
|
||||
"error": err.Error(),
|
||||
}).Error("failed to delete webhook")
|
||||
log.WithError(err).WithField("url", url).Error("failed to delete webhook")
|
||||
}
|
||||
failure("Failed to delete Webhook", err, 1)
|
||||
}
|
||||
@@ -85,9 +79,7 @@ var eventsWebhookListCmd = &cobra.Command{
|
||||
webhooks, err := client.Webhooks()
|
||||
if err != nil {
|
||||
if GlobalFlag.Verbose {
|
||||
log.WithFields(log.Fields{
|
||||
"error": err.Error(),
|
||||
}).Error("failed to get list of Webhooks")
|
||||
log.WithError(err).Error("failed to list webhooks")
|
||||
}
|
||||
failure("Failed to get list of registered Webhooks", err, 1)
|
||||
}
|
||||
|
||||
@@ -124,10 +124,7 @@ func getVolumeDetails(volname string, rclient *restclient.Client) (*volumeDetail
|
||||
emsg = errGeorepRemoteInfoNotAvailable
|
||||
}
|
||||
if GlobalFlag.Verbose {
|
||||
log.WithFields(log.Fields{
|
||||
"volume": volname,
|
||||
"error": err.Error(),
|
||||
}).Error("failed to get Volume details")
|
||||
log.WithError(err).WithField("volume", volname).Error("failed to get Volume details")
|
||||
}
|
||||
return nil, errors.New(emsg)
|
||||
}
|
||||
@@ -204,10 +201,7 @@ var georepCreateCmd = &cobra.Command{
|
||||
sshkeys, err := client.GeorepSSHKeysGenerate(volname)
|
||||
if err != nil {
|
||||
if GlobalFlag.Verbose {
|
||||
log.WithFields(log.Fields{
|
||||
"volume": volname,
|
||||
"error": err.Error(),
|
||||
}).Error("failed to generate SSH Keys")
|
||||
log.WithError(err).WithField("volume", volname).Error("failed to generate SSH Keys")
|
||||
}
|
||||
failure(errGeorepSessionCreationFailed+errGeorepSSHKeysGenerate, err, 1)
|
||||
}
|
||||
@@ -222,7 +216,7 @@ var georepCreateCmd = &cobra.Command{
|
||||
|
||||
if err != nil {
|
||||
if GlobalFlag.Verbose {
|
||||
log.WithField("volume", volname).Println("georep session creation failed")
|
||||
log.WithError(err).WithField("volume", volname).Error("georep session creation failed")
|
||||
}
|
||||
failure(errGeorepSessionCreationFailed, err, 1)
|
||||
}
|
||||
@@ -230,10 +224,7 @@ var georepCreateCmd = &cobra.Command{
|
||||
err = rclient.GeorepSSHKeysPush(remotevol, sshkeys)
|
||||
if err != nil {
|
||||
if GlobalFlag.Verbose {
|
||||
log.WithFields(log.Fields{
|
||||
"volume": remotevol,
|
||||
"error": err.Error(),
|
||||
}).Error("failed to push SSH Keys to Remote Cluster")
|
||||
log.WithError(err).WithField("volume", volname).Error("failed to push SSH Keys to Remote Cluster")
|
||||
}
|
||||
handleGlusterdConnectFailure(errGeorepSessionCreationFailed, remoteEndpoint, err, 1)
|
||||
|
||||
@@ -291,10 +282,7 @@ func handleGeorepAction(args []string, action georepAction) {
|
||||
|
||||
if err != nil {
|
||||
if GlobalFlag.Verbose {
|
||||
log.WithFields(log.Fields{
|
||||
"volume": args[0],
|
||||
"error": err.Error(),
|
||||
}).Error("geo-replication", action.String(), "failed")
|
||||
log.WithError(err).WithField("volume", args[0]).Error("geo-replication", action.String(), "failed")
|
||||
}
|
||||
failure(fmt.Sprintf("Geo-replication %s failed", action.String()), err, 1)
|
||||
}
|
||||
|
||||
@@ -49,10 +49,7 @@ var selfHealInfoCmd = &cobra.Command{
|
||||
}
|
||||
if err != nil {
|
||||
if GlobalFlag.Verbose {
|
||||
log.WithFields(log.Fields{
|
||||
"volume": volname,
|
||||
"error": err.Error(),
|
||||
}).Error("failed to get heal info")
|
||||
log.WithError(err).WithField("volume", volname).Error("failed to get heal info")
|
||||
}
|
||||
failure(fmt.Sprintf("Failed to get heal info for volume %s\n", volname), err, 1)
|
||||
}
|
||||
|
||||
@@ -58,10 +58,7 @@ var peerAddCmd = &cobra.Command{
|
||||
peer, err := client.PeerAdd(peerAddReq)
|
||||
if err != nil {
|
||||
if GlobalFlag.Verbose {
|
||||
log.WithFields(log.Fields{
|
||||
"host": hostname,
|
||||
"error": err.Error(),
|
||||
}).Error("peer add failed")
|
||||
log.WithError(err).WithField("host", hostname).Error("peer add failed")
|
||||
}
|
||||
failure("Peer add failed", err, 1)
|
||||
}
|
||||
@@ -88,10 +85,7 @@ var peerRemoveCmd = &cobra.Command{
|
||||
}
|
||||
if err != nil {
|
||||
if GlobalFlag.Verbose {
|
||||
log.WithFields(log.Fields{
|
||||
"peerID": peerID,
|
||||
"error": err.Error(),
|
||||
}).Error("peer remove failed")
|
||||
log.WithError(err).WithField("peerID", peerID).Error("peer remove failed")
|
||||
}
|
||||
failure("Peer remove failed", err, 1)
|
||||
}
|
||||
@@ -115,9 +109,7 @@ func peerStatusHandler(cmd *cobra.Command) {
|
||||
}
|
||||
if err != nil {
|
||||
if GlobalFlag.Verbose {
|
||||
log.WithFields(log.Fields{
|
||||
"error": err.Error(),
|
||||
}).Error("peer status failed")
|
||||
log.WithError(err).Error("peer status failed")
|
||||
}
|
||||
failure("Failed to get Peers list", err, 1)
|
||||
}
|
||||
|
||||
@@ -39,10 +39,7 @@ func snapshotActivateCmdRun(cmd *cobra.Command, args []string) {
|
||||
err := client.SnapshotActivate(req, snapname)
|
||||
if err != nil {
|
||||
if GlobalFlag.Verbose {
|
||||
log.WithFields(log.Fields{
|
||||
"snapshot": snapname,
|
||||
"error": err.Error(),
|
||||
}).Error("snapshot activation failed")
|
||||
log.WithError(err).WithField("snapshot", snapname).Error("snapshot activation failed")
|
||||
}
|
||||
failure("snapshot activation failed", err, 1)
|
||||
}
|
||||
|
||||
@@ -39,11 +39,11 @@ func snapshotCloneCmdRun(cmd *cobra.Command, args []string) {
|
||||
vol, err := client.SnapshotClone(snapname, req)
|
||||
if err != nil {
|
||||
if GlobalFlag.Verbose {
|
||||
log.WithFields(log.Fields{
|
||||
"clonename": clonename,
|
||||
"snapshot": snapname,
|
||||
"error": err.Error(),
|
||||
}).Error("snapshot clone failed")
|
||||
log.WithError(err).WithFields(
|
||||
log.Fields{
|
||||
"clonename": clonename,
|
||||
"snapshot": snapname,
|
||||
}).Error("snapshot clone failed")
|
||||
}
|
||||
failure("Failed to clone Snapshot", err, 1)
|
||||
}
|
||||
|
||||
@@ -51,11 +51,11 @@ func snapshotCreateCmdRun(cmd *cobra.Command, args []string) {
|
||||
snap, err := client.SnapshotCreate(req)
|
||||
if err != nil {
|
||||
if GlobalFlag.Verbose {
|
||||
log.WithFields(log.Fields{
|
||||
"volume": volname,
|
||||
"snapshot": snapname,
|
||||
"error": err.Error(),
|
||||
}).Error("snapshot creation failed")
|
||||
log.WithError(err).WithFields(
|
||||
log.Fields{
|
||||
"volume": volname,
|
||||
"snapshot": snapname,
|
||||
}).Error("snapshot creation failed")
|
||||
}
|
||||
failure("Snapshot creation failed", err, 1)
|
||||
}
|
||||
|
||||
@@ -29,10 +29,7 @@ func snapshotDeactivateCmdRun(cmd *cobra.Command, args []string) {
|
||||
err := client.SnapshotDeactivate(snapname)
|
||||
if err != nil {
|
||||
if GlobalFlag.Verbose {
|
||||
log.WithFields(log.Fields{
|
||||
"snapshot": snapname,
|
||||
"error": err.Error(),
|
||||
}).Error("snapshot deactivation failed")
|
||||
log.WithError(err).WithField("snapshot", snapname).Error("snapshot deactivation failed")
|
||||
}
|
||||
failure("snapshot deactivation failed", err, 1)
|
||||
}
|
||||
|
||||
@@ -32,10 +32,8 @@ func snapshotDeleteCmdRun(cmd *cobra.Command, args []string) {
|
||||
err := client.SnapshotDelete(snapname)
|
||||
if err != nil {
|
||||
if GlobalFlag.Verbose {
|
||||
log.WithFields(log.Fields{
|
||||
"snapshot": snapname,
|
||||
"error": err.Error(),
|
||||
}).Error("snapshot delete failed")
|
||||
log.WithError(err).WithField(
|
||||
"snapshot", snapname).Error("snapshot delete failed")
|
||||
}
|
||||
failure("Snapshot delete failed", err, 1)
|
||||
}
|
||||
|
||||
@@ -72,9 +72,7 @@ func snapshotInfoCmdRun(cmd *cobra.Command, args []string) {
|
||||
err := snapshotInfoHandler(cmd)
|
||||
if err != nil {
|
||||
if GlobalFlag.Verbose {
|
||||
log.WithFields(log.Fields{
|
||||
"error": err.Error(),
|
||||
}).Error("error getting snapshot info")
|
||||
log.WithError(err).Error("error getting snapshot info")
|
||||
}
|
||||
failure("Error getting Snapshot info", err, 1)
|
||||
}
|
||||
|
||||
@@ -64,9 +64,7 @@ func snapshotListCmdRun(cmd *cobra.Command, args []string) {
|
||||
err := snapshotListHandler(cmd)
|
||||
if err != nil {
|
||||
if GlobalFlag.Verbose {
|
||||
log.WithFields(log.Fields{
|
||||
"error": err.Error(),
|
||||
}).Error("error getting snapshot list")
|
||||
log.WithError(err).Error("error getting snapshot list")
|
||||
}
|
||||
failure("Error getting Snapshot list", err, 1)
|
||||
}
|
||||
|
||||
@@ -31,10 +31,9 @@ func snapshotRestoreCmdRun(cmd *cobra.Command, args []string) {
|
||||
vol, err := client.SnapshotRestore(snapname)
|
||||
if err != nil {
|
||||
if GlobalFlag.Verbose {
|
||||
log.WithFields(log.Fields{
|
||||
log.WithError(err).WithFields(log.Fields{
|
||||
"snapshot": snapname,
|
||||
"volume": vol.Name,
|
||||
"error": err.Error(),
|
||||
}).Error("snapshot restore failed")
|
||||
}
|
||||
failure("snapshot activation failed", err, 1)
|
||||
|
||||
@@ -73,9 +73,7 @@ func snapshotStatusCmdRun(cmd *cobra.Command, args []string) {
|
||||
err := snapshotStatusHandler(cmd)
|
||||
if err != nil {
|
||||
if GlobalFlag.Verbose {
|
||||
log.WithFields(log.Fields{
|
||||
"error": err.Error(),
|
||||
}).Error("error getting snapshot status")
|
||||
log.WithError(err).Error("error getting snapshot status")
|
||||
}
|
||||
failure("Error getting Snapshot status", err, 1)
|
||||
}
|
||||
|
||||
@@ -115,10 +115,8 @@ func smartVolumeCreate(cmd *cobra.Command, args []string) {
|
||||
vol, err := client.VolumeCreate(req)
|
||||
if err != nil {
|
||||
if GlobalFlag.Verbose {
|
||||
log.WithFields(log.Fields{
|
||||
"volume": flagCreateVolumeName,
|
||||
"error": err.Error(),
|
||||
}).Error("volume creation failed")
|
||||
log.WithError(err).WithField(
|
||||
"volume", flagCreateVolumeName).Error("volume creation failed")
|
||||
}
|
||||
failure("Volume creation failed", err, 1)
|
||||
}
|
||||
@@ -153,10 +151,8 @@ func volumeCreateCmdRun(cmd *cobra.Command, args []string) {
|
||||
bricks, err := bricksAsUUID(brickArgs)
|
||||
if err != nil {
|
||||
if GlobalFlag.Verbose {
|
||||
log.WithFields(log.Fields{
|
||||
"error": err.Error(),
|
||||
"volume": volname,
|
||||
}).Error("error getting brick UUIDs")
|
||||
log.WithError(err).WithField(
|
||||
"volume", volname).Error("error getting brick UUIDs")
|
||||
}
|
||||
failure("Error getting brick UUIDs", err, 1)
|
||||
}
|
||||
@@ -297,10 +293,7 @@ func volumeCreateCmdRun(cmd *cobra.Command, args []string) {
|
||||
vol, err := client.VolumeCreate(req)
|
||||
if err != nil {
|
||||
if GlobalFlag.Verbose {
|
||||
log.WithFields(log.Fields{
|
||||
"volume": volname,
|
||||
"error": err.Error(),
|
||||
}).Error("volume creation failed")
|
||||
log.WithError(err).WithField("volume", volname).Error("volume creation failed")
|
||||
}
|
||||
failure("Volume creation failed", err, 1)
|
||||
}
|
||||
|
||||
@@ -43,10 +43,7 @@ var volumeResetCmd = &cobra.Command{
|
||||
err := client.VolumeReset(volname, req)
|
||||
if err != nil {
|
||||
if GlobalFlag.Verbose {
|
||||
log.WithFields(log.Fields{
|
||||
"volume": volname,
|
||||
"error": err.Error(),
|
||||
}).Error("volume reset failed")
|
||||
log.WithError(err).WithField("volume", volname).Error("volume reset failed")
|
||||
}
|
||||
failure("Volume reset failed", err, 1)
|
||||
}
|
||||
|
||||
@@ -53,10 +53,8 @@ func volumeSetCmdRun(cmd *cobra.Command, args []string) {
|
||||
options := args[1:]
|
||||
if err := volumeOptionJSONHandler(cmd, volname, options); err != nil {
|
||||
if GlobalFlag.Verbose {
|
||||
log.WithFields(log.Fields{
|
||||
"volume": volname,
|
||||
"error": err.Error(),
|
||||
}).Error("volume option set failed")
|
||||
log.WithError(err).WithField(
|
||||
"volume", volname).Error("volume option set failed")
|
||||
}
|
||||
failure("Volume option set failed", err, 1)
|
||||
} else {
|
||||
|
||||
@@ -236,10 +236,10 @@ func (b Brickinfo) TerminateBrick() error {
|
||||
}
|
||||
|
||||
if err := daemon.DelDaemon(brickDaemon); err != nil {
|
||||
log.WithFields(log.Fields{
|
||||
log.WithError(err).WithFields(log.Fields{
|
||||
"name": brickDaemon.Name(),
|
||||
"id": brickDaemon.ID(),
|
||||
}).WithError(err).Warn("failed to delete brick entry from store, it may be restarted on GlusterD restart")
|
||||
}).Warn("failed to delete brick entry from store, it may be restarted on GlusterD restart")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import (
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/pborman/uuid"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func editPeer(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -34,7 +35,7 @@ func editPeer(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
for key := range req.Metadata {
|
||||
if strings.HasPrefix(key, "_") {
|
||||
logger.WithField("metadata-key", key).Error(gderrors.ErrRestrictedKeyFound)
|
||||
logger.WithError(gderrors.ErrRestrictedKeyFound).WithField("metadata-key", key)
|
||||
restutils.SendHTTPError(ctx, w, http.StatusBadRequest, gderrors.ErrRestrictedKeyFound)
|
||||
return
|
||||
}
|
||||
@@ -56,7 +57,8 @@ func editPeer(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
err = txn.Ctx.Set("peerid", peerID)
|
||||
if err != nil {
|
||||
logger.WithError(err).WithField("key", "peerid").WithField("value", peerID).Error("Failed to set key in transaction context")
|
||||
logger.WithError(err).WithFields(
|
||||
log.Fields{"key": "peerid", "value": peerID}).Error("Failed to set key in transaction context")
|
||||
restutils.SendHTTPError(ctx, w, http.StatusInternalServerError, err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -204,10 +204,8 @@ func snapshotActivateHandler(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
err = txn.Do()
|
||||
if err != nil {
|
||||
log.WithFields(log.Fields{
|
||||
"error": err.Error(),
|
||||
"snapshot": snapname,
|
||||
}).Error("failed to start snapshot")
|
||||
log.WithError(err).WithField(
|
||||
"snapshot", snapname).Error("failed to start snapshot")
|
||||
restutils.SendHTTPError(ctx, w, http.StatusInternalServerError, err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -244,7 +244,7 @@ func createCloneVolinfo(c transaction.TxnCtx) error {
|
||||
|
||||
err = createSnapSubvols(newVol, volinfo, nodeData)
|
||||
if err != nil {
|
||||
log.WithFields(log.Fields{
|
||||
log.WithError(err).WithFields(log.Fields{
|
||||
"snapshot": snapname,
|
||||
"volume name": clonename,
|
||||
}).Error("Failed to create clone volinfo")
|
||||
|
||||
@@ -431,7 +431,7 @@ func brickSnapshot(errCh chan error, wg *sync.WaitGroup, snapBrick, b brick.Bric
|
||||
}).Debug("Running snapshot create command")
|
||||
|
||||
if err := lvm.LVSnapshot(mntInfo.FsName, mountData.DevicePath); err != nil {
|
||||
log.WithFields(log.Fields{
|
||||
log.WithError(err).WithFields(log.Fields{
|
||||
"mountDevice": mntInfo.FsName,
|
||||
"devicePath": mountData.DevicePath,
|
||||
"Path": b.Path,
|
||||
@@ -441,7 +441,7 @@ func brickSnapshot(errCh chan error, wg *sync.WaitGroup, snapBrick, b brick.Bric
|
||||
}
|
||||
|
||||
if err = lvm.UpdateFsLabel(mountData.DevicePath, mountData.FsType); err != nil {
|
||||
log.WithFields(log.Fields{
|
||||
log.WithError(err).WithFields(log.Fields{
|
||||
"FsType": mountData.FsType,
|
||||
"Path": b.Path,
|
||||
}).Error("Failed to update the label")
|
||||
@@ -577,7 +577,7 @@ func createSnapinfo(c transaction.TxnCtx) error {
|
||||
|
||||
err = createSnapSubvols(snapVolinfo, volinfo, nodeData)
|
||||
if err != nil {
|
||||
log.WithFields(log.Fields{
|
||||
log.WithError(err).WithFields(log.Fields{
|
||||
"snapshot": snapVolinfo.Name,
|
||||
"volumeName": volinfo.Name,
|
||||
}).Error("Failed to create snap volinfo")
|
||||
|
||||
@@ -191,10 +191,7 @@ func snapshotDeactivateHandler(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
err = txn.Do()
|
||||
if err != nil {
|
||||
log.WithFields(log.Fields{
|
||||
"error": err.Error(),
|
||||
"snapshot": snapname,
|
||||
}).Error("failed to de-activate snap")
|
||||
log.WithError(err).WithField("snapshot", snapname).Error("failed to de-activate snap")
|
||||
restutils.SendHTTPError(ctx, w, http.StatusInternalServerError, err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ func volumeBricksStatusHandler(w http.ResponseWriter, r *http.Request) {
|
||||
result, err := createBricksStatusResp(txn.Ctx, vol)
|
||||
if err != nil {
|
||||
errMsg := "Failed to aggregate brick status results from multiple nodes."
|
||||
logger.WithField("error", err.Error()).Error("volumeStatusHandler:" + errMsg)
|
||||
logger.WithError(err).Error("volumeStatusHandler:" + errMsg)
|
||||
restutils.SendHTTPError(ctx, w, http.StatusInternalServerError, errMsg)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -140,8 +140,7 @@ func undoStartBricksOnExpand(c transaction.TxnCtx) error {
|
||||
}).Info("volume expand failed, stopping brick")
|
||||
|
||||
if err := b.StopBrick(c.Logger()); err != nil {
|
||||
c.Logger().WithFields(log.Fields{
|
||||
"error": err,
|
||||
c.Logger().WithError(err).WithFields(log.Fields{
|
||||
"volume": b.VolumeName,
|
||||
"brick": b.String(),
|
||||
}).Debug("stopping brick failed")
|
||||
|
||||
@@ -14,10 +14,7 @@ import (
|
||||
func txnPrepareBricks(c transaction.TxnCtx) error {
|
||||
var req api.VolCreateReq
|
||||
if err := c.Get("req", &req); err != nil {
|
||||
c.Logger().WithFields(log.Fields{
|
||||
"error": err,
|
||||
"key": "req",
|
||||
}).Error("failed to get key from store")
|
||||
c.Logger().WithError(err).WithField("key", "req").Error("failed to get key from store")
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -30,18 +27,14 @@ func txnPrepareBricks(c transaction.TxnCtx) error {
|
||||
// Create Mount directory
|
||||
err := os.MkdirAll(b.Mountdir, os.ModeDir|os.ModePerm)
|
||||
if err != nil {
|
||||
c.Logger().WithFields(log.Fields{
|
||||
"error": err,
|
||||
"path": b.Mountdir,
|
||||
}).Error("failed to create brick mount directory")
|
||||
c.Logger().WithError(err).WithField("path", b.Mountdir).Error("failed to create brick mount directory")
|
||||
return err
|
||||
}
|
||||
|
||||
// Thin Pool Creation
|
||||
err = deviceutils.CreateTP(b.VgName, b.TpName, b.TpSize, b.TpMetadataSize)
|
||||
if err != nil {
|
||||
c.Logger().WithFields(log.Fields{
|
||||
"error": err,
|
||||
c.Logger().WithError(err).WithFields(log.Fields{
|
||||
"vg-name": b.VgName,
|
||||
"tp-name": b.TpName,
|
||||
"tp-size": b.TpSize,
|
||||
@@ -53,8 +46,7 @@ func txnPrepareBricks(c transaction.TxnCtx) error {
|
||||
// LV Creation
|
||||
err = deviceutils.CreateLV(b.VgName, b.TpName, b.LvName, b.Size)
|
||||
if err != nil {
|
||||
c.Logger().WithFields(log.Fields{
|
||||
"error": err,
|
||||
c.Logger().WithError(err).WithFields(log.Fields{
|
||||
"vg-name": b.VgName,
|
||||
"tp-name": b.TpName,
|
||||
"lv-name": b.LvName,
|
||||
@@ -73,10 +65,9 @@ func txnPrepareBricks(c transaction.TxnCtx) error {
|
||||
// Mount the Created FS
|
||||
err = deviceutils.BrickMount(b.DevicePath, b.Mountdir)
|
||||
if err != nil {
|
||||
c.Logger().WithFields(log.Fields{
|
||||
"error": err,
|
||||
"dev": b.DevicePath,
|
||||
"path": b.Mountdir,
|
||||
c.Logger().WithError(err).WithFields(log.Fields{
|
||||
"dev": b.DevicePath,
|
||||
"path": b.Mountdir,
|
||||
}).Error("brick mount failed")
|
||||
return err
|
||||
}
|
||||
@@ -84,10 +75,8 @@ func txnPrepareBricks(c transaction.TxnCtx) error {
|
||||
// Create a directory in Brick Mount
|
||||
err = os.MkdirAll(b.Path, os.ModeDir|os.ModePerm)
|
||||
if err != nil {
|
||||
c.Logger().WithFields(log.Fields{
|
||||
"error": err,
|
||||
"path": b.Path,
|
||||
}).Error("failed to create brick directory in mount")
|
||||
c.Logger().WithError(err).WithField(
|
||||
"path", b.Path).Error("failed to create brick directory in mount")
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -102,10 +91,7 @@ func txnPrepareBricks(c transaction.TxnCtx) error {
|
||||
func txnUndoPrepareBricks(c transaction.TxnCtx) error {
|
||||
var req api.VolCreateReq
|
||||
if err := c.Get("req", &req); err != nil {
|
||||
c.Logger().WithFields(log.Fields{
|
||||
"error": err,
|
||||
"key": "req",
|
||||
}).Error("failed to get key from store")
|
||||
c.Logger().WithError(err).WithField("key", "req").Error("failed to get key from store")
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -119,17 +105,13 @@ func txnUndoPrepareBricks(c transaction.TxnCtx) error {
|
||||
// UnMount the Brick
|
||||
err := deviceutils.BrickUnmount(b.Mountdir)
|
||||
if err != nil {
|
||||
c.Logger().WithFields(log.Fields{
|
||||
"error": err,
|
||||
"path": b.Mountdir,
|
||||
}).Error("brick unmount failed")
|
||||
c.Logger().WithError(err).WithField("path", b.Mountdir).Error("brick unmount failed")
|
||||
}
|
||||
|
||||
// Remove LV
|
||||
err = deviceutils.RemoveLV(b.VgName, b.LvName)
|
||||
if err != nil {
|
||||
c.Logger().WithFields(log.Fields{
|
||||
"error": err,
|
||||
c.Logger().WithError(err).WithFields(log.Fields{
|
||||
"vg-name": b.VgName,
|
||||
"lv-name": b.LvName,
|
||||
}).Error("lv remove failed")
|
||||
@@ -138,8 +120,7 @@ func txnUndoPrepareBricks(c transaction.TxnCtx) error {
|
||||
// Remove Thin Pool
|
||||
err = deviceutils.RemoveLV(b.VgName, b.TpName)
|
||||
if err != nil {
|
||||
c.Logger().WithFields(log.Fields{
|
||||
"error": err,
|
||||
c.Logger().WithError(err).WithFields(log.Fields{
|
||||
"vg-name": b.VgName,
|
||||
"tp-name": b.TpName,
|
||||
}).Error("thinpool remove failed")
|
||||
|
||||
@@ -57,10 +57,10 @@ func stopBricks(c transaction.TxnCtx) error {
|
||||
|
||||
// On graceful shutdown of brick, daemon.Stop() isn't called.
|
||||
if err := daemon.DelDaemon(brickDaemon); err != nil {
|
||||
log.WithFields(log.Fields{
|
||||
log.WithError(err).WithFields(log.Fields{
|
||||
"name": brickDaemon.Name(),
|
||||
"id": brickDaemon.ID(),
|
||||
}).WithError(err).Warn("failed to delete brick entry from store, it may be restarted on GlusterD restart")
|
||||
}).Warn("failed to delete brick entry from store, it may be restarted on GlusterD restart")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ func GetRPCClient(d Daemon) (*rpc.Client, error) {
|
||||
&net.UnixAddr{Name: d.SocketFile(), Net: "unix"},
|
||||
)
|
||||
if err != nil {
|
||||
log.WithFields(log.Fields{
|
||||
log.WithError(err).WithFields(log.Fields{
|
||||
"socket": d.SocketFile(), "name": d.Name(),
|
||||
}).Error("failed connecting to daemon")
|
||||
return nil, err
|
||||
|
||||
@@ -97,10 +97,7 @@ func Start(d Daemon, wait bool, logger log.FieldLogger) error {
|
||||
// daemon tell glusterd2 that it's up and ready.
|
||||
pid, err = ReadPidFromFile(d.PidFile())
|
||||
if err != nil {
|
||||
logger.WithFields(log.Fields{
|
||||
"pidfile": d.PidFile(),
|
||||
"error": err.Error(),
|
||||
}).Error("Could not read pidfile")
|
||||
logger.WithError(err).WithField("pidfile", d.PidFile()).Error("Could not read pidfile")
|
||||
events.Broadcast(newEvent(d, daemonStartFailed, 0))
|
||||
return err
|
||||
}
|
||||
@@ -126,7 +123,7 @@ func Start(d Daemon, wait bool, logger log.FieldLogger) error {
|
||||
|
||||
// Save daemon information in the store so it can be restarted
|
||||
if err := saveDaemon(d); err != nil {
|
||||
logger.WithField("name", d.Name()).WithError(err).Warn("failed to save daemon information into store, daemon may not be restarted on GlusterD restart")
|
||||
logger.WithError(err).WithField("name", d.Name()).Warn("failed to save daemon information into store, daemon may not be restarted on GlusterD restart")
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -175,7 +172,7 @@ func Stop(d Daemon, force bool, logger log.FieldLogger) error {
|
||||
_ = os.Remove(d.PidFile())
|
||||
|
||||
if err != nil {
|
||||
logger.WithFields(log.Fields{
|
||||
logger.WithError(err).WithFields(log.Fields{
|
||||
"name": d.Name(),
|
||||
"pid": pid,
|
||||
}).Error("Stopping daemon failed.")
|
||||
@@ -185,10 +182,10 @@ func Stop(d Daemon, force bool, logger log.FieldLogger) error {
|
||||
}
|
||||
|
||||
if err := DelDaemon(d); err != nil {
|
||||
logger.WithFields(log.Fields{
|
||||
logger.WithError(err).WithFields(log.Fields{
|
||||
"name": d.Name(),
|
||||
"pid": pid,
|
||||
}).WithError(err).Warn("failed to delete daemon from store, it may be restarted on GlusterD restart")
|
||||
}).Warn("failed to delete daemon from store, it may be restarted on GlusterD restart")
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -208,7 +205,7 @@ func StartAllDaemons() {
|
||||
|
||||
for _, d := range ds {
|
||||
if err := Start(d, true, log.StandardLogger()); err != nil {
|
||||
log.WithField("name", d.Name()).WithError(err).Warn("failed to start daemon")
|
||||
log.WithError(err).WithField("name", d.Name()).Warn("failed to start daemon")
|
||||
}
|
||||
}
|
||||
events.Broadcast(events.New(daemonStartedAll, nil, false))
|
||||
@@ -237,7 +234,7 @@ func Signal(d Daemon, sig syscall.Signal, logger log.FieldLogger) error {
|
||||
|
||||
err = process.Signal(sig)
|
||||
if err != nil {
|
||||
logger.WithFields(log.Fields{
|
||||
logger.WithError(err).WithFields(log.Fields{
|
||||
"name": d.Name(),
|
||||
"pid": pid,
|
||||
"signal": sig,
|
||||
|
||||
@@ -182,10 +182,7 @@ func getJWTToken(eventtype, secret string) string {
|
||||
func WebhookPublish(webhook *eventsapi.Webhook, e *api.Event) error {
|
||||
message, err := json.Marshal(e)
|
||||
if err != nil {
|
||||
log.WithFields(log.Fields{
|
||||
"name": e.Name,
|
||||
"error": err.Error(),
|
||||
}).Error("failed to marshal event")
|
||||
log.WithError(err).WithField("name", e.Name).Error("failed to marshal event")
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
@@ -37,10 +37,10 @@ func globalHandler(ev *api.Event) {
|
||||
ev.Origin = gdctx.MyUUID
|
||||
v, err := json.Marshal(ev)
|
||||
if err != nil {
|
||||
log.WithFields(log.Fields{
|
||||
log.WithError(err).WithFields(log.Fields{
|
||||
"event.id": ev.ID.String(),
|
||||
"event.name": ev.Name,
|
||||
}).WithError(err).Error("failed global broadcast, failed to marshal event")
|
||||
}).Error("failed global broadcast, failed to marshal event")
|
||||
}
|
||||
|
||||
// Putting event with a TTL so that we don't have stale events lingering in store
|
||||
@@ -52,17 +52,17 @@ func globalHandler(ev *api.Event) {
|
||||
}
|
||||
l, err := store.Store.Grant(store.Store.Ctx(), eventsttl)
|
||||
if err != nil {
|
||||
log.WithFields(log.Fields{
|
||||
log.WithError(err).WithFields(log.Fields{
|
||||
"event.id": ev.ID.String(),
|
||||
"event.name": ev.Name,
|
||||
}).WithError(err).Error("failed global broadcast, failed to get lease")
|
||||
}).Error("failed global broadcast, failed to get lease")
|
||||
}
|
||||
|
||||
if _, err := store.Put(store.Store.Ctx(), k, string(v), clientv3.WithLease(l.ID)); err != nil {
|
||||
log.WithFields(log.Fields{
|
||||
log.WithError(err).WithFields(log.Fields{
|
||||
"event.id": ev.ID.String(),
|
||||
"event.name": ev.Name,
|
||||
}).WithError(err).Error("failed global broadcast, failed to write event to store")
|
||||
}).Error("failed global broadcast, failed to write event to store")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ func globalListener(glStop chan struct{}) {
|
||||
for _, sev := range resp.Events {
|
||||
var ev api.Event
|
||||
if err := json.Unmarshal(sev.Kv.Value, &ev); err != nil {
|
||||
log.WithField("event.id", string(sev.Kv.Key)).WithError(err).Error("could not unmarshal global event")
|
||||
log.WithError(err).WithField("event.id", string(sev.Kv.Key)).Error("could not unmarshal global event")
|
||||
continue
|
||||
}
|
||||
if !uuid.Equal(ev.Origin, gdctx.MyUUID) {
|
||||
|
||||
@@ -130,10 +130,7 @@ func GetPeers(filterParams ...map[string]string) ([]*Peer, error) {
|
||||
var p Peer
|
||||
|
||||
if err := json.Unmarshal(kv.Value, &p); err != nil {
|
||||
log.WithFields(log.Fields{
|
||||
"peer": string(kv.Key),
|
||||
"error": err,
|
||||
}).Error("Failed to unmarshal peer")
|
||||
log.WithError(err).WithField("peer", string(kv.Key)).Error("Failed to unmarshal peer")
|
||||
continue
|
||||
}
|
||||
switch filterType {
|
||||
@@ -173,10 +170,7 @@ func GetPeerIDs() ([]uuid.UUID, error) {
|
||||
for i, kv := range resp.Kvs {
|
||||
var p Peer
|
||||
if err := json.Unmarshal(kv.Value, &p); err != nil {
|
||||
log.WithFields(log.Fields{
|
||||
"peer": string(kv.Key),
|
||||
"error": err,
|
||||
}).Error("Failed to unmarshal peer")
|
||||
log.WithError(err).WithField("peer", string(kv.Key)).Error("Failed to unmarshal peer")
|
||||
continue
|
||||
}
|
||||
uuids[i] = p.ID
|
||||
|
||||
@@ -37,7 +37,7 @@ func (s *Server) Serve() {
|
||||
|
||||
l, e := net.Listen("tcp", listenAddr)
|
||||
if e != nil {
|
||||
log.WithField("error", e).Error("net.Listen() error")
|
||||
log.WithError(e).Error("net.Listen() error")
|
||||
return
|
||||
}
|
||||
log.WithField("ip:port", listenAddr).Info("Registered RPC Listener")
|
||||
|
||||
@@ -72,10 +72,10 @@ func NewMuxed(m cmux.CMux) *GDRest {
|
||||
if l, err := tlsListener(m.Match(tlsmatcher.TLS12), certfile, keyfile); err != nil {
|
||||
// TODO: Don't use Fatal(), bubble up error till main()
|
||||
// NOTE: Methods of suture.Service interface do not return error
|
||||
log.WithFields(log.Fields{
|
||||
log.WithError(err).WithFields(log.Fields{
|
||||
"cert-file": certfile,
|
||||
"key-file": keyfile,
|
||||
}).WithError(err).Fatal("Failed to create SSL/TLS listener")
|
||||
}).Fatal("Failed to create SSL/TLS listener")
|
||||
} else {
|
||||
rest.listener = l
|
||||
}
|
||||
|
||||
@@ -113,13 +113,13 @@ func (p *GfHandshake) ServerGetspec(args *GfGetspecReq, reply *GfGetspecRsp) err
|
||||
volfileID := strings.TrimPrefix(args.Key, "/")
|
||||
resp, err := store.Get(context.TODO(), volfilePrefix+volfileID)
|
||||
if err != nil {
|
||||
log.WithField("volfile", args.Key).WithError(err).Error("ServerGetspec(): failed to retrive volfile from store")
|
||||
log.WithError(err).WithField("volfile", args.Key).Error("ServerGetspec(): failed to retrive volfile from store")
|
||||
goto Out
|
||||
}
|
||||
|
||||
if resp.Count != 1 {
|
||||
err = errors.New("volfile not found in store")
|
||||
log.WithField("volfile", args.Key).Error(err.Error())
|
||||
log.WithError(err).WithField("volfile", args.Key)
|
||||
goto Out
|
||||
}
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ func MountSnapBrickDirectory(vol *volume.Volinfo, brickinfo *brick.Brickinfo) er
|
||||
*/
|
||||
|
||||
if err := lvm.MountSnapshotDirectory(mountRoot, brickinfo.MountInfo); err != nil {
|
||||
log.WithFields(log.Fields{"error": err.Error(),
|
||||
log.WithError(err).WithFields(log.Fields{
|
||||
"brickPath": brickinfo.String(),
|
||||
"mountRoot": mountRoot}).Error("Failed to mount snapshot directory")
|
||||
|
||||
@@ -97,7 +97,7 @@ func MountSnapBrickDirectory(vol *volume.Volinfo, brickinfo *brick.Brickinfo) er
|
||||
|
||||
err := unix.Setxattr(brickinfo.Path, volumeIDXattrKey, vol.ID, 0)
|
||||
if err != nil {
|
||||
log.WithFields(log.Fields{"error": err.Error(),
|
||||
log.WithError(err).WithFields(log.Fields{
|
||||
"brickPath": brickinfo.Path,
|
||||
"xattr": volumeIDXattrKey}).Error("setxattr failed")
|
||||
return err
|
||||
|
||||
@@ -48,10 +48,7 @@ func GetSnapshots() ([]*Snapinfo, error) {
|
||||
var snap Snapinfo
|
||||
|
||||
if err := json.Unmarshal(kv.Value, &snap); err != nil {
|
||||
log.WithFields(log.Fields{
|
||||
"snapshot": string(kv.Key),
|
||||
"error": err,
|
||||
}).Error("Failed to unmarshal snapshot")
|
||||
log.WithError(err).WithField("snapshot", string(kv.Key)).Error("Failed to unmarshal snapshot")
|
||||
continue
|
||||
}
|
||||
|
||||
|
||||
@@ -21,10 +21,7 @@ func runStepOn(origCtx netctx.Context, step string, node uuid.UUID, c TxnCtx) er
|
||||
// we have long term connections.
|
||||
p, err := peer.GetPeerF(node.String())
|
||||
if err != nil {
|
||||
c.Logger().WithFields(log.Fields{
|
||||
"peerid": node.String(),
|
||||
"error": err,
|
||||
}).Error("peer not found")
|
||||
c.Logger().WithError(err).WithField("peerid", node.String()).Error("peer not found")
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -51,10 +48,7 @@ func runStepOn(origCtx netctx.Context, step string, node uuid.UUID, c TxnCtx) er
|
||||
}
|
||||
|
||||
if conn == nil {
|
||||
logger.WithFields(log.Fields{
|
||||
"error": err,
|
||||
"remote": p.PeerAddresses[0],
|
||||
}).Error("failed to grpc.Dial remote")
|
||||
logger.WithError(err).WithField("remote", p.PeerAddresses[0]).Error("failed to grpc.Dial remote")
|
||||
return err
|
||||
}
|
||||
defer conn.Close()
|
||||
@@ -75,10 +69,7 @@ func runStepOn(origCtx netctx.Context, step string, node uuid.UUID, c TxnCtx) er
|
||||
|
||||
rsp, err = client.RunStep(origCtx, req)
|
||||
if err != nil {
|
||||
logger.WithFields(log.Fields{
|
||||
"error": err,
|
||||
"rpc": "TxnSvc.RunStep",
|
||||
}).Error("failed RPC call")
|
||||
logger.WithError(err).WithField("rpc", "TxnSvc.RunStep").Error("failed RPC call")
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
@@ -114,9 +114,9 @@ func runStepFuncOnNodes(origCtx context.Context, stepName string, ctx TxnCtx, no
|
||||
peerResp = <-respCh
|
||||
if peerResp.Error != nil {
|
||||
resp.errCount++
|
||||
ctx.Logger().WithFields(log.Fields{
|
||||
ctx.Logger().WithError(peerResp.Error).WithFields(log.Fields{
|
||||
"step": stepName, "node": peerResp.PeerID,
|
||||
}).WithError(peerResp.Error).Error("Step failed on node.")
|
||||
}).Error("Step failed on node.")
|
||||
}
|
||||
resp.Resps = append(resp.Resps, peerResp)
|
||||
}
|
||||
|
||||
@@ -43,8 +43,7 @@ func MountLocalBricks() error {
|
||||
|
||||
err := utils.ExecuteCommandRun("mount", "-o", b.MountInfo.MntOpts, b.MountInfo.DevicePath, b.MountInfo.Mountdir)
|
||||
if err != nil {
|
||||
log.WithFields(log.Fields{
|
||||
"error": err,
|
||||
log.WithError(err).WithFields(log.Fields{
|
||||
"volume": v.Name,
|
||||
"dev": b.MountInfo.DevicePath,
|
||||
"path": b.MountInfo.Mountdir,
|
||||
|
||||
@@ -90,10 +90,7 @@ func GetVolumesList() (map[string]uuid.UUID, error) {
|
||||
var vol Volinfo
|
||||
|
||||
if err := json.Unmarshal(kv.Value, &vol); err != nil {
|
||||
log.WithFields(log.Fields{
|
||||
"volume": string(kv.Key),
|
||||
"error": err,
|
||||
}).Error("Failed to unmarshal volume")
|
||||
log.WithError(err).WithField("volume", string(kv.Key)).Error("Failed to unmarshal volume")
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -138,10 +135,7 @@ func GetVolumes(filterParams ...map[string]string) ([]*Volinfo, error) {
|
||||
var vol Volinfo
|
||||
|
||||
if err := json.Unmarshal(kv.Value, &vol); err != nil {
|
||||
log.WithFields(log.Fields{
|
||||
"volume": string(kv.Key),
|
||||
"error": err,
|
||||
}).Error("Failed to unmarshal volume")
|
||||
log.WithError(err).WithField("volume", string(kv.Key)).Error("Failed to unmarshal volume")
|
||||
continue
|
||||
}
|
||||
switch filterType {
|
||||
|
||||
@@ -70,7 +70,7 @@ func IsLocalAddress(address string) (bool, error) {
|
||||
func ParseHostAndBrickPath(brickPath string) (string, string, error) {
|
||||
i := strings.LastIndex(brickPath, ":")
|
||||
if i == -1 {
|
||||
log.WithField("brick", brickPath).Error(errors.ErrInvalidBrickPath.Error())
|
||||
log.WithError(errors.ErrInvalidBrickPath).WithField("brick", brickPath)
|
||||
return "", "", errors.ErrInvalidBrickPath
|
||||
}
|
||||
hostname := brickPath[0:i]
|
||||
|
||||
@@ -117,7 +117,8 @@ func deviceListHandler(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
devices, err := deviceutils.GetDevices(peerID)
|
||||
if err != nil {
|
||||
logger.WithError(err).WithField("peerid", peerID).Error("Failed to get devices for peer")
|
||||
logger.WithError(err).WithField("peerid", peerID).Error(
|
||||
"Failed to get devices for peer")
|
||||
status, err := restutils.ErrToStatusCode(err)
|
||||
restutils.SendHTTPError(ctx, w, status, err)
|
||||
return
|
||||
|
||||
@@ -44,10 +44,7 @@ func GetWebhookList() ([]*eventsapi.Webhook, error) {
|
||||
var wh eventsapi.Webhook
|
||||
|
||||
if err := json.Unmarshal(kv.Value, &wh); err != nil {
|
||||
log.WithFields(log.Fields{
|
||||
"webhook": string(kv.Key),
|
||||
"error": err,
|
||||
}).Error("Failed to unmarshal webhook")
|
||||
log.WithError(err).WithField("webhook", string(kv.Key)).Error("Failed to unmarshal webhook")
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -90,10 +87,8 @@ func GetEventsList() ([]*api.Event, error) {
|
||||
var ev api.Event
|
||||
|
||||
if err := json.Unmarshal(kv.Value, &ev); err != nil {
|
||||
log.WithFields(log.Fields{
|
||||
"event": string(kv.Key),
|
||||
"error": err,
|
||||
}).Error("Failed to unmarshal event")
|
||||
log.WithError(err).WithField(
|
||||
"event", string(kv.Key)).Error("Failed to unmarshal event")
|
||||
continue
|
||||
}
|
||||
|
||||
|
||||
@@ -118,20 +118,15 @@ func rebalanceStartHandler(w http.ResponseWriter, r *http.Request) {
|
||||
* rebalance process is one per node per volume.
|
||||
* Need to handle scenarios where process is started in
|
||||
* few nodes and failed in few others */
|
||||
logger.WithFields(log.Fields{
|
||||
"error": err.Error(),
|
||||
"volname": volname,
|
||||
}).Error("failed to start rebalance on volume")
|
||||
logger.WithError(err).WithField("volname", volname).Error("failed to start rebalance on volume")
|
||||
restutils.SendHTTPError(ctx, w, http.StatusInternalServerError, err)
|
||||
return
|
||||
}
|
||||
|
||||
rebalinfo, err = GetRebalanceInfo(volname)
|
||||
if err != nil {
|
||||
logger.WithFields(log.Fields{
|
||||
"error": err.Error(),
|
||||
"volname": volname,
|
||||
}).Error("failed to get the rebalance info for volume")
|
||||
logger.WithError(err).WithField(
|
||||
"volname", volname).Error("failed to get the rebalance info for volume")
|
||||
}
|
||||
|
||||
logger.WithField("volname", rebalinfo.Volname).Info("rebalance started")
|
||||
@@ -206,10 +201,7 @@ func rebalanceStopHandler(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
err = txn.Do()
|
||||
if err != nil {
|
||||
logger.WithFields(log.Fields{
|
||||
"error": err.Error(),
|
||||
"volname": volname,
|
||||
}).Error("failed to stop rebalance on volume")
|
||||
logger.WithError(err).WithField("volname", volname).Error("failed to stop rebalance on volume")
|
||||
restutils.SendHTTPError(r.Context(), w, http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
}
|
||||
@@ -275,16 +267,13 @@ func rebalanceStatusHandler(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
err = txn.Do()
|
||||
if err != nil {
|
||||
logger.WithFields(log.Fields{
|
||||
"error": err.Error(),
|
||||
"volname": volname,
|
||||
}).Error("failed to query rebalance status for volume")
|
||||
logger.WithError(err).WithField("volname", volname).Error("failed to query rebalance status for volume")
|
||||
}
|
||||
|
||||
response, err := createRebalanceStatusResp(txn.Ctx, vol)
|
||||
if err != nil {
|
||||
errMsg := "Failed to create rebalance status response"
|
||||
logger.WithField("error", err.Error()).Error("rebalanceStatusHandler:" + errMsg)
|
||||
logger.WithError(err).Error("rebalanceStatusHandler:" + errMsg)
|
||||
restutils.SendHTTPError(ctx, w, http.StatusInternalServerError,
|
||||
errMsg)
|
||||
return
|
||||
|
||||
@@ -79,7 +79,7 @@ func GetRebalanceInfo(volname string) (*rebalanceapi.RebalInfo, error) {
|
||||
func StoreRebalanceInfo(rinfo *rebalanceapi.RebalInfo) error {
|
||||
json, err := json.Marshal(&rinfo)
|
||||
if err != nil {
|
||||
log.WithField("error", err).Error("Failed to marshal the rebalance info object")
|
||||
log.WithError(err).Error("Failed to marshal the rebalance info object")
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user