-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix/Change morph priority order #1648
Fix/Change morph priority order #1648
Conversation
Sort the endpoint by their priority before the first WS client creation to start the morph client with the highest priority endpoint. Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
Codecov Report
@@ Coverage Diff @@
## master #1648 +/- ##
==========================================
+ Coverage 33.18% 33.21% +0.02%
==========================================
Files 332 332
Lines 22706 22717 +11
==========================================
+ Hits 7536 7545 +9
- Misses 14552 14554 +2
Partials 618 618
📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more |
Changed: |
@@ -41,9 +44,14 @@ func RPCEndpoint(c *config.Config) []client.Endpoint { | |||
break | |||
} | |||
|
|||
priority := int(config.IntSafe(s, "priority")) | |||
if priority == 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we use if priority <= 0
?
NEOFS_MORPH_RPC_ENDPOINT_1_ADDRESS="wss://rpc2.morph.fs.neo.org:40341/ws" | ||
NEOFS_MORPH_RPC_ENDPOINT_1_PRIORITY=1 | ||
NEOFS_MORPH_RPC_ENDPOINT_1_PRIORITY=2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add priority to the ENDPOINT_0
explicitly too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added zero priority to the 0
endpoint
docs/storage-node-configuration.md
Outdated
| Parameter | Type | Default value | Description | | ||
|------------|----------|---------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ||
| `address` | `string` | | _WebSocket_ N3 endpoint. | | ||
| `priority` | `int` | `1` | Priority of an endpoint. Endpoint with a higher priority (lower configuration value) has more chance of being used. Endpoints with equal priority are iterated over randomly. | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I understand priority - "Endpoint with a higher priority must be / will be
used until it's healthy" rather than has more chance
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that sentence means that it is possible to have more than one endpoint with the same priority; they are shuffled so it is not guaranteed that the first gonna be used. also, if the most prioritized endpoint failed but then returned, we would still use the less prioritized endpoint after the switch
however, we are planning to have some mechanism that would try to return to the most prioritized endpoint but it is not implemented yet. so it is all about the probability
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Weighted probability
pkg/innerring/innerring.go
Outdated
section := p.name + ".endpoint.client" | ||
for i := 0; ; i++ { | ||
addr := p.cfg.GetString(fmt.Sprintf("%s.%d.%s", section, i, "address")) | ||
if addr == "" { | ||
break | ||
} | ||
|
||
priority := p.cfg.GetInt(section + ".priority") | ||
if priority == 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if priority == 0 { | |
if priority <= 0 { |
The lowest value means the highest priority. Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
Sort the endpoint by their priority before the first WS client creation to start the morph client with the highest priority endpoint. Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
Sort the endpoint by their priority before the first WS client creation to start the morph client with the highest priority endpoint. Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
The lowest value means the highest priority. Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
To mirror the behaviour of the gateways.