Skip to content

Commit

Permalink
node: support reloading node attributes with SIGHUP
Browse files Browse the repository at this point in the history
Add a new function `cfg.reloadNodeAttributes` that updates the list of node
attributes.
Add docs.

Closes #1870.

Signed-off-by: Andrey Butusov <[email protected]>
  • Loading branch information
End-rey committed Nov 8, 2024
1 parent 7a40a94 commit b323897
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ attribute, which is used for container domain name in NNS contracts (#2954)
- Docs files for cli commands to the `docs/cli-commands` folder (#2983)
- `logger.encoding` config option (#2999)
- Reloading morph endpoints with SIGHUP (#2998)
- Reloading node attributes with SIGHUP (#3005)

### Fixed
- Do not search for tombstones when handling their expiration, use local indexes instead (#2929)
Expand Down
8 changes: 8 additions & 0 deletions cmd/neofs-node/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -876,6 +876,14 @@ func (c *cfg) configWatcher(ctx context.Context) {

c.cli.Reload(client.WithEndpoints(c.morph.endpoints))

// Node

err = c.reloadNodeAttributes()
if err != nil {
c.log.Error("invalid node attributes configuration", zap.Error(err))
continue

Check warning on line 884 in cmd/neofs-node/config.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-node/config.go#L879-L884

Added lines #L879 - L884 were not covered by tests
}

c.log.Info("configuration has been reloaded successfully")
case <-ctx.Done():
return
Expand Down
29 changes: 29 additions & 0 deletions cmd/neofs-node/netmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"sync/atomic"

netmapV2 "github.com/nspcc-dev/neofs-api-go/v2/netmap"
netmapGRPC "github.com/nspcc-dev/neofs-api-go/v2/netmap/grpc"
"github.com/nspcc-dev/neofs-node/pkg/core/netmap"
"github.com/nspcc-dev/neofs-node/pkg/metrics"
Expand Down Expand Up @@ -445,3 +446,31 @@ func (n *netInfo) Dump(ver version.Version) (*netmapSDK.NetworkInfo, error) {

return &ni, nil
}

func (c *cfg) reloadNodeAttributes() error {
epoch, ni, err := getNetworkState(c)
if err != nil {
return err
}

Check warning on line 454 in cmd/neofs-node/netmap.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-node/netmap.go#L450-L454

Added lines #L450 - L454 were not covered by tests

var ni2 netmapV2.NodeInfo
c.cfgNodeInfo.localInfo.WriteToV2(&ni2)

ni2.SetAttributes([]netmapV2.Attribute{})

err = c.cfgNodeInfo.localInfo.ReadFromV2(ni2)
if err != nil {
return err
}

Check warning on line 464 in cmd/neofs-node/netmap.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-node/netmap.go#L456-L464

Added lines #L456 - L464 were not covered by tests

err = writeSystemAttributes(c)
if err != nil {
return err
}

Check warning on line 469 in cmd/neofs-node/netmap.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-node/netmap.go#L466-L469

Added lines #L466 - L469 were not covered by tests

parseAttributes(c)

updateLocalState(c, epoch, ni)

return nil

Check warning on line 475 in cmd/neofs-node/netmap.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-node/netmap.go#L471-L475

Added lines #L471 - L475 were not covered by tests
}
6 changes: 6 additions & 0 deletions docs/sighup.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,9 @@ comparing paths from `shard.blobstor` section. After this we have 3 sets:
| Changed section | Actions |
|-----------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `endpoints` | Updates N3 endpoints.<br/>If new `endpoints` do not contain the endpoint client is connected to, it will reconnect to another endpoint from the new list. Node service can be interrupted in this case. |

### Node

| Changed section | Actions |
|-----------------|--------------------------|
| `attribute_*` | Updates node attributes. |

0 comments on commit b323897

Please sign in to comment.