Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
client
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
elixxir
client
Commits
4469f724
Commit
4469f724
authored
Mar 4, 2022
by
Benjamin Wenger
Browse files
Options
Downloads
Patches
Plain Diff
added a system to retry node registrations
parent
8c9598bb
No related branches found
No related tags found
1 merge request
!231
Revert "Update store to print changes to the partners list"
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
network/node/register.go
+28
-2
28 additions, 2 deletions
network/node/register.go
with
28 additions
and
2 deletions
network/node/register.go
+
28
−
2
View file @
4469f724
...
...
@@ -39,6 +39,10 @@ import (
"time"
)
const
maxAttempts
=
5
var
delayTable
=
[
5
]
time
.
Duration
{
0
,
5
*
time
.
Second
,
30
*
time
.
Second
,
60
*
time
.
Second
,
120
*
time
.
Second
}
type
RegisterNodeCommsInterface
interface
{
SendRequestClientKeyMessage
(
host
*
connect
.
Host
,
message
*
pb
.
SignedClientKeyRequest
)
(
*
pb
.
SignedKeyResponse
,
error
)
...
...
@@ -49,12 +53,16 @@ func StartRegistration(sender *gateway.Sender, session *storage.Session, rngGen
multi
:=
stoppable
.
NewMulti
(
"NodeRegistrations"
)
inProgess
:=
&
sync
.
Map
{}
// we are relying on the in progress check to
// ensure there is only a single operator at a time, as a result this is a map of ID -> int
attempts
:=
&
sync
.
Map
{}
for
i
:=
uint
(
0
);
i
<
numParallel
;
i
++
{
stop
:=
stoppable
.
NewSingle
(
fmt
.
Sprintf
(
"NodeRegistration %d"
,
i
))
go
registerNodes
(
sender
,
session
,
rngGen
,
comms
,
stop
,
c
,
inProgess
)
go
registerNodes
(
sender
,
session
,
rngGen
,
comms
,
stop
,
c
,
inProgess
,
attempts
)
multi
.
Add
(
stop
)
}
...
...
@@ -63,7 +71,7 @@ func StartRegistration(sender *gateway.Sender, session *storage.Session, rngGen
func
registerNodes
(
sender
*
gateway
.
Sender
,
session
*
storage
.
Session
,
rngGen
*
fastRNG
.
StreamGenerator
,
comms
RegisterNodeCommsInterface
,
stop
*
stoppable
.
Single
,
c
chan
network
.
NodeGateway
,
inProgress
*
sync
.
Map
)
{
stop
*
stoppable
.
Single
,
c
chan
network
.
NodeGateway
,
inProgress
,
attempts
*
sync
.
Map
)
{
u
:=
session
.
User
()
regSignature
:=
u
.
GetTransmissionRegistrationValidationSignature
()
// Timestamp in which user has registered with registration
...
...
@@ -85,6 +93,14 @@ func registerNodes(sender *gateway.Sender, session *storage.Session,
if
_
,
operating
:=
inProgress
.
LoadOrStore
(
nidStr
,
struct
{}{});
operating
{
continue
}
//keep track of how many times this has been attempted
numAttempts
:=
uint
(
1
)
if
nunAttemptsInterface
,
hasValue
:=
attempts
.
LoadOrStore
(
nidStr
,
numAttempts
);
hasValue
{
numAttempts
=
nunAttemptsInterface
.
(
uint
)
attempts
.
Store
(
nidStr
,
numAttempts
+
1
)
}
// No need to register with stale nodes
if
isStale
:=
gw
.
Node
.
Status
==
ndf
.
Stale
;
isStale
{
jww
.
DEBUG
.
Printf
(
"Skipping registration with stale node %s"
,
nidStr
)
...
...
@@ -95,12 +111,22 @@ func registerNodes(sender *gateway.Sender, session *storage.Session,
inProgress
.
Delete
(
nidStr
)
if
err
!=
nil
{
jww
.
ERROR
.
Printf
(
"Failed to register node: %+v"
,
err
)
//if we have not reached the attempt limit for this gateway, send it back into the channel to retry
if
numAttempts
<
maxAttempts
{
go
func
(){
//delay the send for a backoff
time
.
Sleep
(
delayTable
[
numAttempts
-
1
])
c
<-
gw
}()
}
}
case
<-
t
.
C
:
}
}
}
//registerWithNode serves as a helper for RegisterWithNodes
// It registers a user with a specific in the client's ndf.
func
registerWithNode
(
sender
*
gateway
.
Sender
,
comms
RegisterNodeCommsInterface
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment