mirror of
https://github.com/gluster/glusterd2.git
synced 2026-02-05 12:45:38 +01:00
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 <mrajanna@redhat.com>
This commit is contained in:
committed by
Prashanth Pai
parent
66f967cfe1
commit
3fe0f2b535
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user