-
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
node: support reloading node attributes with SIGHUP #3005
base: master
Are you sure you want to change the base?
node: support reloading node attributes with SIGHUP #3005
Conversation
Codecov ReportAttention: Patch coverage is
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. |
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.
- You can compare old/new and avoid updates if nothing changed.
- You're likely to have concurrency problems here when updating
c
. - 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.
b323897
to
59a00ed
Compare
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.
Maybe an atomic pointer would be easier to handle here, but locks can be used too.
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>
59a00ed
to
7a367b0
Compare
@@ -4,6 +4,7 @@ import ( | |||
"fmt" | |||
|
|||
"github.com/nspcc-dev/locode-db/pkg/locodedb" | |||
"github.com/nspcc-dev/neofs-api-go/v2/netmap" |
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.
try to avoid importing neofs-api-go. If u need to extend the type interface in sdk - do it
https://pkg.go.dev/github.com/nspcc-dev/neofs-sdk-go/netmap#NodeInfo.NumberOfAttributes + https://pkg.go.dev/github.com/nspcc-dev/neofs-sdk-go/netmap#NodeInfo.IterateAttributes seems enough
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.
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?
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.
feel free to add. Recent similar addition. U may add SetAttributes
or ResetAttributes
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.
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?
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.
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 { |
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.
nodeAttrs actually, we have various attrs
if value, exists := elements[item.GetKey()]; !exists || value != item.GetValue() { | ||
return false | ||
} | ||
delete(elements, item.GetKey()) |
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.
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 |
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.
no need for a pointer
} | ||
|
||
err = c.bootstrap() | ||
if err != nil { |
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.
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() |
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.
enough to rlock?
Closes #1870.
Also fix bug from #2998, that incorrectly checked when to reconnect.