From 3fe0f2b535a9d37ff9cddfda05bce88daef57296 Mon Sep 17 00:00:00 2001 From: Madhu Rajanna Date: Thu, 9 Aug 2018 12:14:24 +0530 Subject: [PATCH] discard error message if node is unreachable and DontCheckAlive flag is set if nodes are unreachable and DontCheckAlive flag is set, we need to discard the error message and return nil Signed-off-by: Madhu Rajanna --- glusterd2/transaction/transaction.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/glusterd2/transaction/transaction.go b/glusterd2/transaction/transaction.go index 3feab740..3cb5c3ba 100644 --- a/glusterd2/transaction/transaction.go +++ b/glusterd2/transaction/transaction.go @@ -13,6 +13,8 @@ import ( "github.com/coreos/etcd/clientv3/concurrency" "github.com/pborman/uuid" log "github.com/sirupsen/logrus" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" ) const ( @@ -133,6 +135,9 @@ func (t *Txn) Do() error { } if err := s.do(t.OrigCtx, t.Ctx); err != nil { + if t.DontCheckAlive && isNodeUnreachable(err) { + continue + } expTxn.Add("initiated_txn_failure", 1) if !t.DisableRollback { t.Ctx.Logger().WithError(err).Error("Transaction failed, rolling back changes") @@ -146,6 +151,18 @@ func (t *Txn) Do() error { return nil } +func isNodeUnreachable(err error) bool { + unreachable := true + if s, ok := err.(*stepResp); ok { + for _, e := range s.Resps { + if grpc.Code(e.Error) != codes.Unavailable { + unreachable = false + } + } + } + return unreachable +} + // undo undoes a transaction and will be automatically called by Perform if any step fails. // The Steps are undone in the reverse order, from the failed step. func (t *Txn) undo(n int) {