Commit 8a85fe44 authored by Michael de Hoog's avatar Michael de Hoog Committed by GitHub

proxyd: avoid banning a backend that is a forced candidate (#7275)

* Add consensus configuration option to never ban a backend

* Fix panic

* Remove additional flag, use `consensus_forced_candidate` instead
parent 61871cf4
...@@ -261,7 +261,7 @@ func (cp *ConsensusPoller) UpdateBackend(ctx context.Context, be *Backend) { ...@@ -261,7 +261,7 @@ func (cp *ConsensusPoller) UpdateBackend(ctx context.Context, be *Backend) {
} }
// if backend is not healthy state we'll only resume checking it after ban // if backend is not healthy state we'll only resume checking it after ban
if !be.IsHealthy() { if !be.IsHealthy() && !be.forcedCandidate {
log.Warn("backend banned - not healthy", "backend", be.Name) log.Warn("backend banned - not healthy", "backend", be.Name)
cp.Ban(be) cp.Ban(be)
return return
...@@ -327,7 +327,7 @@ func (cp *ConsensusPoller) UpdateBackend(ctx context.Context, be *Backend) { ...@@ -327,7 +327,7 @@ func (cp *ConsensusPoller) UpdateBackend(ctx context.Context, be *Backend) {
RecordBackendUnexpectedBlockTags(be, !expectedBlockTags) RecordBackendUnexpectedBlockTags(be, !expectedBlockTags)
if !expectedBlockTags { if !expectedBlockTags && !be.forcedCandidate {
log.Warn("backend banned - unexpected block tags", log.Warn("backend banned - unexpected block tags",
"backend", be.Name, "backend", be.Name,
"oldFinalized", bs.finalizedBlockNumber, "oldFinalized", bs.finalizedBlockNumber,
...@@ -490,6 +490,10 @@ func (cp *ConsensusPoller) IsBanned(be *Backend) bool { ...@@ -490,6 +490,10 @@ func (cp *ConsensusPoller) IsBanned(be *Backend) bool {
// Ban bans a specific backend // Ban bans a specific backend
func (cp *ConsensusPoller) Ban(be *Backend) { func (cp *ConsensusPoller) Ban(be *Backend) {
if be.forcedCandidate {
return
}
bs := cp.backendState[be] bs := cp.backendState[be]
defer bs.backendStateMux.Unlock() defer bs.backendStateMux.Unlock()
bs.backendStateMux.Lock() bs.backendStateMux.Lock()
......
...@@ -99,7 +99,11 @@ func rewriteParam(rctx RewriteContext, req *RPCReq, res *RPCRes, pos int, requir ...@@ -99,7 +99,11 @@ func rewriteParam(rctx RewriteContext, req *RPCReq, res *RPCRes, pos int, requir
return RewriteNone, nil return RewriteNone, nil
} }
val, rw, err := rewriteTag(rctx, p[pos].(string)) s, ok := p[pos].(string)
if !ok {
return RewriteOverrideError, errors.New("expected string")
}
val, rw, err := rewriteTag(rctx, s)
if err != nil { if err != nil {
return RewriteOverrideError, err return RewriteOverrideError, err
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment