Skip to content

Commit

Permalink
morph: support reloading morph endpoints with SIGHUP
Browse files Browse the repository at this point in the history
Add a new function `Client.Reload` that passes the `WithEndpoints` option and
closes the client if there is no endpoint in the config to which the client is
connected.
Add docs.

Closes #1871.

Signed-off-by: Andrey Butusov <[email protected]>
  • Loading branch information
End-rey committed Nov 2, 2024
1 parent 3285f9f commit 9f93904
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ attribute, which is used for container domain name in NNS contracts (#2954)
- `neofs-cli control object revive` command (#2968)
- `--disable-auto-gen-tag` flag for gendoc command (#2983)
- Docs files for cli commands to the `docs/cli-commands` folder (#2983)
- Reloading morph endpoints with SIGHUP (#2998)

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

// Morph

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

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

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-node/config.go#L875-L876

Added lines #L875 - L876 were not covered by tests
c.log.Info("configuration has been reloaded successfully")
case <-ctx.Done():
return
Expand Down
8 changes: 6 additions & 2 deletions docs/sighup.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ Available for reconfiguration fields:

```yml
head_timeout:
cache_size:
cache_time:
replication_cooldown:
object_batch_size:
max_workers:
Expand All @@ -34,3 +32,9 @@ comparing paths from `shard.blobstor` section. After this we have 3 sets:
| Changed section | Actions |
|-----------------|----------------------------------------------------------------------------------------------------------------------|
| `path` | If `path` is different, metabase is closed and opened with a new path. All other configuration will also be updated. |

### Morph

| Changed section | Actions |
|-----------------|--------------------------------------------------------------------------------------------------------------------|
| `endpoints` | If in the `endpoints` there is no endpoint that the client is connected to, try connecting to another endpoint N3. |
25 changes: 25 additions & 0 deletions pkg/morph/client/reload.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package client

import "slices"

// Reload allows runtime reconfiguration for WithEndpoints parameter.
func (c *Client) Reload(opts ...Option) {
cfg := new(cfg)
for _, o := range opts {
o(cfg)
}

Check warning on line 10 in pkg/morph/client/reload.go

View check run for this annotation

Codecov / codecov/patch

pkg/morph/client/reload.go#L6-L10

Added lines #L6 - L10 were not covered by tests

c.cfg.endpoints = cfg.endpoints

c.endpoints = cfg.endpoints

var conn = c.conn.Load()
if conn == nil {
return
}
currentEndpointID := conn.client.Endpoint()

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

Check warning on line 24 in pkg/morph/client/reload.go

View check run for this annotation

Codecov / codecov/patch

pkg/morph/client/reload.go#L12-L24

Added lines #L12 - L24 were not covered by tests
}

0 comments on commit 9f93904

Please sign in to comment.