Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
2df2c546
Commit
2df2c546
authored
May 09, 2023
by
Felipe Andrade
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ban / isbanned
parent
06e42cbd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
7 deletions
+22
-7
consensus_poller.go
proxyd/consensus_poller.go
+22
-7
No files found.
proxyd/consensus_poller.go
View file @
2df2c546
...
@@ -203,23 +203,22 @@ func NewConsensusPoller(bg *BackendGroup, opts ...ConsensusOpt) *ConsensusPoller
...
@@ -203,23 +203,22 @@ func NewConsensusPoller(bg *BackendGroup, opts ...ConsensusOpt) *ConsensusPoller
// UpdateBackend refreshes the consensus state of a single backend
// UpdateBackend refreshes the consensus state of a single backend
func
(
cp
*
ConsensusPoller
)
UpdateBackend
(
ctx
context
.
Context
,
be
*
Backend
)
{
func
(
cp
*
ConsensusPoller
)
UpdateBackend
(
ctx
context
.
Context
,
be
*
Backend
)
{
_
,
_
,
_
,
_
,
bannedUntil
:=
cp
.
getBackendState
(
be
)
if
cp
.
IsBanned
(
be
)
{
if
time
.
Now
()
.
Before
(
bannedUntil
)
{
log
.
Debug
(
"skipping backend banned"
,
"backend"
,
be
.
Name
)
log
.
Debug
(
"skipping backend banned"
,
"backend"
,
be
.
Name
,
"bannedUntil"
,
bannedUntil
)
return
return
}
}
// if backend it not online or not in a health state we'll only resume checkin it after ban
// if backend it not online or not in a health state we'll only resume checkin it after ban
if
!
be
.
Online
()
||
!
be
.
IsHealthy
()
{
if
!
be
.
Online
()
||
!
be
.
IsHealthy
()
{
log
.
Warn
(
"backend banned - not online or not healthy"
,
"backend"
,
be
.
Name
,
"bannedUntil"
,
bannedUntil
)
log
.
Warn
(
"backend banned - not online or not healthy"
,
"backend"
,
be
.
Name
)
bannedUntil
=
time
.
Now
()
.
Add
(
cp
.
banPeriod
)
cp
.
Ban
(
be
)
}
}
// if backend it not in sync we'll check again after ban
// if backend it not in sync we'll check again after ban
inSync
,
err
:=
cp
.
isInSync
(
ctx
,
be
)
inSync
,
err
:=
cp
.
isInSync
(
ctx
,
be
)
if
err
!=
nil
||
!
inSync
{
if
err
!=
nil
||
!
inSync
{
log
.
Warn
(
"backend banned - not in sync"
,
"backend"
,
be
.
Name
,
"bannedUntil"
,
bannedUntil
)
log
.
Warn
(
"backend banned - not in sync"
,
"backend"
,
be
.
Name
)
bannedUntil
=
time
.
Now
()
.
Add
(
cp
.
banPeriod
)
cp
.
Ban
(
be
)
}
}
// if backend exhausted rate limit we'll skip it for now
// if backend exhausted rate limit we'll skip it for now
...
@@ -363,6 +362,22 @@ func (cp *ConsensusPoller) UpdateBackendGroupConsensus(ctx context.Context) {
...
@@ -363,6 +362,22 @@ func (cp *ConsensusPoller) UpdateBackendGroupConsensus(ctx context.Context) {
log
.
Debug
(
"group state"
,
"proposedBlock"
,
proposedBlock
,
"consensusBackends"
,
strings
.
Join
(
consensusBackendsNames
,
", "
),
"filteredBackends"
,
strings
.
Join
(
filteredBackendsNames
,
", "
))
log
.
Debug
(
"group state"
,
"proposedBlock"
,
proposedBlock
,
"consensusBackends"
,
strings
.
Join
(
consensusBackendsNames
,
", "
),
"filteredBackends"
,
strings
.
Join
(
filteredBackendsNames
,
", "
))
}
}
// IsBanned checks if a specific backend is banned
func
(
cp
*
ConsensusPoller
)
IsBanned
(
be
*
Backend
)
bool
{
bs
:=
cp
.
backendState
[
be
]
defer
bs
.
backendStateMux
.
Unlock
()
bs
.
backendStateMux
.
Lock
()
return
time
.
Now
()
.
Before
(
bs
.
bannedUntil
)
}
// Ban bans a specific backend
func
(
cp
*
ConsensusPoller
)
Ban
(
be
*
Backend
)
{
bs
:=
cp
.
backendState
[
be
]
defer
bs
.
backendStateMux
.
Unlock
()
bs
.
backendStateMux
.
Lock
()
bs
.
bannedUntil
=
time
.
Now
()
.
Add
(
cp
.
banPeriod
)
}
// Unban remove any bans from the backends
// Unban remove any bans from the backends
func
(
cp
*
ConsensusPoller
)
Unban
()
{
func
(
cp
*
ConsensusPoller
)
Unban
()
{
for
_
,
be
:=
range
cp
.
backendGroup
.
Backends
{
for
_
,
be
:=
range
cp
.
backendGroup
.
Backends
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment