Skip to content
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

morph: support reloading morph endpoints with sighup #2998

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

End-rey
Copy link
Contributor

@End-rey End-rey commented Nov 2, 2024

Closes #1871.

Copy link

codecov bot commented Nov 2, 2024

Codecov Report

Attention: Patch coverage is 0% with 17 lines in your changes missing coverage. Please review.

Project coverage is 23.15%. Comparing base (2e583e5) to head (ac18957).

Files with missing lines Patch % Lines
pkg/morph/client/reload.go 0.00% 10 Missing ⚠️
pkg/morph/client/multi.go 0.00% 4 Missing ⚠️
cmd/neofs-node/config.go 0.00% 2 Missing ⚠️
pkg/morph/client/constructor.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2998      +/-   ##
==========================================
- Coverage   23.15%   23.15%   -0.01%     
==========================================
  Files         789      790       +1     
  Lines       58815    58830      +15     
==========================================
+ Hits        13619    13622       +3     
- Misses      44312    44325      +13     
+ Partials      884      883       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

currentEndpointID := conn.client.Endpoint()

if slices.Index(c.endpoints, currentEndpointID) == -1 {
conn.client.Close()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Brutal. I'd rather document that we're keeping current connection.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added to a Reload function description.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean dropping this code, RPC reconnections are costly for node, so we can avoid them and use current node while it's alive.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, I documented in the comment why we're keeping current connection.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@roman-khimov, this happens only if we are connected to a node that should not be used anymore according to the updated nodes list

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.

Copy link
Member

@carpawell carpawell Nov 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you were connected to node X, and then you updated (successfully) to a list that does not have node X, what is your expectation as an admin?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Depends on documentation.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, i am for switching in that case

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm also for switching, it seems logical to me. But if this behavior is documented, then fine.

@End-rey End-rey force-pushed the 1871-support-reloading-morph-endpoints-with-sighup branch from 9f93904 to 85609dc Compare November 5, 2024 07:35

c.cfg.endpoints = cfg.endpoints

c.endpoints = cfg.endpoints
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be protected wrt other threads, btw.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here switchLock *sync.RWMutex has been deleted. Do I need to add it again or is there some other way?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was created for a different purpose. You can introduce som endpoints RWLock now.

@End-rey End-rey force-pushed the 1871-support-reloading-morph-endpoints-with-sighup branch 2 times, most recently from d205b84 to f92c1b7 Compare November 5, 2024 15:19
@End-rey End-rey self-assigned this Nov 5, 2024
@@ -10,8 +10,6 @@ Available for reconfiguration fields:

```yml
head_timeout:
cache_size:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a little bit confused why this happened in this PR. you just noted that it is outdated? a separate commit then?


c.endpointsLock.Lock()

c.cfg.endpoints = cfg.endpoints
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm, maybe not this PR's zone but why we need two field updates?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I wanted to fix this immediately as well. But would be nice if @End-rey untangles it.

currentEndpointID := conn.client.Endpoint()

if slices.Index(c.endpoints, currentEndpointID) == -1 {
conn.client.Close()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@roman-khimov, this happens only if we are connected to a node that should not be used anymore according to the updated nodes list

Signed-off-by: Andrey Butusov <andrey@nspcc.io>
Signed-off-by: Andrey Butusov <andrey@nspcc.io>
Signed-off-by: Andrey Butusov <andrey@nspcc.io>
@End-rey End-rey force-pushed the 1871-support-reloading-morph-endpoints-with-sighup branch 2 times, most recently from e05904f to 19aff22 Compare November 6, 2024 11:24
Add a new function `Client.Reload` that passes the `WithEndpoints` option and
updates the `Client` endpoints.
Add docs.

Closes #1871.

Signed-off-by: Andrey Butusov <andrey@nspcc.io>
@End-rey End-rey force-pushed the 1871-support-reloading-morph-endpoints-with-sighup branch from 19aff22 to ac18957 Compare November 6, 2024 13:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support reloading morph endpoints with SIGHUP
3 participants