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

node: support reloading node attributes with SIGHUP #3005

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

Conversation

End-rey
Copy link
Contributor

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

Closes #1870.

Also fix bug from #2998, that incorrectly checked when to reconnect.

Copy link

codecov bot commented Nov 8, 2024

Codecov Report

Attention: Patch coverage is 20.27027% with 59 lines in your changes missing coverage. Please review.

Project coverage is 22.83%. Comparing base (b7714ae) to head (7a367b0).

Files with missing lines Patch % Lines
cmd/neofs-node/netmap.go 0.00% 41 Missing ⚠️
cmd/neofs-node/config.go 0.00% 14 Missing ⚠️
cmd/neofs-node/container.go 0.00% 3 Missing ⚠️
pkg/morph/client/reload.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3005      +/-   ##
==========================================
- Coverage   22.84%   22.83%   -0.01%     
==========================================
  Files         790      790              
  Lines       58344    58420      +76     
==========================================
+ Hits        13328    13340      +12     
- Misses      44136    44199      +63     
- Partials      880      881       +1     

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

Copy link
Member

@roman-khimov roman-khimov left a comment

Choose a reason for hiding this comment

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

  1. You can compare old/new and avoid updates if nothing changed.
  2. You're likely to have concurrency problems here when updating c.
  3. Not sure what updateLocalState gives us, we want to force node netmap update mostly (send an appropriate tx) and it works the other way around.

@End-rey End-rey force-pushed the 1870-support-reloading-node-attributes-with-sighup branch from b323897 to 59a00ed Compare November 11, 2024 17:05
Copy link
Member

@roman-khimov roman-khimov left a comment

Choose a reason for hiding this comment

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

Maybe an atomic pointer would be easier to handle here, but locks can be used too.

cmd/neofs-node/config.go Outdated Show resolved Hide resolved
cmd/neofs-node/attributes.go Show resolved Hide resolved
cmd/neofs-node/netmap.go Show resolved Hide resolved
cmd/neofs-node/netmap.go Show resolved Hide resolved
Incorrect expression to check for reconnection. Before that, it worked the other
way around, now is fixed.

Signed-off-by: Andrey Butusov <andrey@nspcc.io>
Add a new function `cfg.reloadNodeAttributes` that updates the list of node
attributes.
Add RWMutex for `cfg.cfgNodeInfo.localInfo`.
Add docs.

Closes #1870.

Signed-off-by: Andrey Butusov <andrey@nspcc.io>
@End-rey End-rey force-pushed the 1870-support-reloading-node-attributes-with-sighup branch from 59a00ed to 7a367b0 Compare November 13, 2024 15:20
@@ -4,6 +4,7 @@ import (
"fmt"

"github.com/nspcc-dev/locode-db/pkg/locodedb"
"github.com/nspcc-dev/neofs-api-go/v2/netmap"
Copy link
Contributor

Choose a reason for hiding this comment

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

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 need SetAttributes, to clear all the attributes, and GetAttributes, so that I don't have to write a lot of code. I thought if they weren't there, then there was a reason for that. So I can add them?

Copy link
Contributor

Choose a reason for hiding this comment

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

feel free to add. Recent similar addition. U may add SetAttributes or ResetAttributes

Copy link
Contributor Author

Choose a reason for hiding this comment

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

And now, how do I use what I've extended? Or will it need to be fixed later, after updating the SDK version? Meanwhile, should I make an issue?

Copy link
Member

Choose a reason for hiding this comment

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

go get github.com/nspcc-dev/neofs-sdk-go@master

@@ -97,3 +98,24 @@ func setIfNotEmpty(setter func(string), value string) {
setter(value)
}
}

func attrsEqual(arr1, arr2 []netmap.Attribute) bool {
Copy link
Contributor

Choose a reason for hiding this comment

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

nodeAttrs actually, we have various attrs

if value, exists := elements[item.GetKey()]; !exists || value != item.GetValue() {
return false
}
delete(elements, item.GetKey())
Copy link
Contributor

Choose a reason for hiding this comment

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

i dont think this is needed: elements will always be empty after the loop, wont it?

// values from config; NOT MODIFY AFTER APP INITIALIZATION
localInfo netmap.NodeInfo
// values from config; NOT MODIFY AFTER APP INITIALIZATION OR CONFIG RELOAD
localInfoLock *sync.RWMutex
Copy link
Contributor

Choose a reason for hiding this comment

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

no need for a pointer

}

err = c.bootstrap()
if err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

just return c.bootstrap() if u dont add err context

@@ -497,6 +497,9 @@ func (c *cfg) NumberOfAddresses() int {
}

func (c *cfg) ExternalAddresses() []string {
c.cfgNodeInfo.localInfoLock.Lock()
Copy link
Contributor

Choose a reason for hiding this comment

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

enough to rlock?

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 node attributes with SIGHUP
3 participants