Skip to content

Commit

Permalink
rm/Deprecated 0.37.0 config and metrics (#2400)
Browse files Browse the repository at this point in the history
Closes #2347.
  • Loading branch information
roman-khimov committed Jun 21, 2023
2 parents fc8dd84 + 10eb098 commit 85a31ff
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 80 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ Changelog for NeoFS Node
### Fixed

### Removed
- Deprecated `morph.rpc_endpoint` SN and `morph.endpoint.client` IR config sections (#2400)
- `neofs_node_object_epoch` metric for IR and SN (#2347)

### Changed
- CLI `--timeout` flag configures whole execution timeout from now (#2124)
Expand All @@ -23,6 +25,11 @@ on timeout, try increasing the value, for example, twice. Also note that the
execution of commands with the `--await` flag and without an explicitly
specified time period is now limited to 1 minute. This value can be changed with
`--timeout` flag.
Deprecated `morph.rpc_endpoint` SN and `morph.endpoint.client` IR configurations
have been removed. Use `morph.endpoints` for both instead.
Deprecated `neofs_node_object_epoch` metric for IR and SN (the same for both)
has been removed. Use `neofs_node_state_epoch` for SN and `neofs_ir_state_epoch`
for IR instead.

## [0.37.0] - 2023-06-15 - Sogado

Expand Down
4 changes: 2 additions & 2 deletions cmd/neofs-adm/internal/modules/storagecfg/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ control:
morph:
dial_timeout: 20s # timeout for side chain NEO RPC client connection
cache_ttl: 15s # use TTL cache for side chain GET operations
rpc_endpoint: # side chain N3 RPC endpoints
endpoints: # side chain N3 RPC endpoints
{{- range .MorphRPC }}
- address: wss://{{.}}/ws{{end}}
- wss://{{.}}/ws{{end}}
{{if not .Relay }}
storage:
shard_pool_size: 15 # size of per-shard worker pools used for PUT operations
Expand Down
18 changes: 1 addition & 17 deletions cmd/neofs-node/config/morph/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package morphconfig

import (
"fmt"
"strconv"
"time"

"github.com/nspcc-dev/neofs-node/cmd/neofs-node/config"
Expand Down Expand Up @@ -30,24 +29,9 @@ const (
//
// Throws panic if list is empty.
func Endpoints(c *config.Config) []string {
var endpointsDeprecated []string

sub := c.Sub(subsection).Sub("rpc_endpoint")
for i := 0; ; i++ {
s := sub.Sub(strconv.FormatInt(int64(i), 10))
addr := config.StringSafe(s, "address")
if addr == "" {
break
}

endpointsDeprecated = append(endpointsDeprecated, addr)
}

endpoints := config.StringSliceSafe(c.Sub(subsection), "endpoints")
endpoints = append(endpoints, endpointsDeprecated...)

if len(endpoints) == 0 {
panic(fmt.Errorf("no morph chain RPC endpoints, see `morph.rpc_endpoint` section"))
panic(fmt.Errorf("no morph chain RPC endpoints, see `morph.endpoints` section"))
}
return endpoints
}
Expand Down
6 changes: 3 additions & 3 deletions docs/storage-node-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,9 @@ contracts:
morph:
dial_timeout: 30s
cache_ttl: 15s
rpc_endpoint:
- address: wss://rpc1.morph.fs.neo.org:40341/ws
- address: wss://rpc2.morph.fs.neo.org:40341/ws
endpoints:
- wss://rpc1.morph.fs.neo.org:40341/ws
- wss://rpc2.morph.fs.neo.org:40341/ws
```

| Parameter | Type | Default value | Description |
Expand Down
7 changes: 1 addition & 6 deletions pkg/innerring/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,7 @@ import (
// checks if Inner Ring app is configured to be launched in local consensus
// mode.
func isLocalConsensusMode(cfg *viper.Viper) bool {
const morphRPCSectionDeprecated = "morph.endpoint.client"
// first expression required for ENVs in which nesting breaks
deprecatedNotSet := !cfg.IsSet(morphRPCSectionDeprecated+".0.address") && !cfg.IsSet(morphRPCSectionDeprecated)
actualNotSet := !cfg.IsSet("morph.endpoints")

return deprecatedNotSet && actualNotSet
return !cfg.IsSet("morph.endpoints")
}

func parseBlockchainConfig(v *viper.Viper, _logger *logger.Logger) (c blockchain.Config, err error) {
Expand Down
9 changes: 4 additions & 5 deletions pkg/innerring/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ func TestIsLocalConsensusMode(t *testing.T) {
v.SetEnvPrefix("neofs_ir")
v.SetEnvKeyReplacer(strings.NewReplacer(".", "_"))

const envKey = "NEOFS_IR_MORPH_ENDPOINT_CLIENT_0_ADDRESS"
const envKey = "NEOFS_IR_MORPH_ENDPOINTS"

err := os.Unsetenv(envKey)
require.NoError(t, err)
Expand All @@ -419,15 +419,14 @@ func TestIsLocalConsensusMode(t *testing.T) {
v.SetConfigType("yaml")
err := v.ReadConfig(strings.NewReader(`
morph:
endpoint:
client:
- address: ws://morph-chain:30333/ws
endpoints:
- ws://morph-chain:30333/ws
`))
require.NoError(t, err)

require.False(t, isLocalConsensusMode(v))

resetConfig(t, v, "morph.endpoint.client")
resetConfig(t, v, "morph.endpoints")

require.True(t, isLocalConsensusMode(v))
})
Expand Down
12 changes: 0 additions & 12 deletions pkg/innerring/innerring.go
Original file line number Diff line number Diff line change
Expand Up @@ -1019,18 +1019,6 @@ func createListener(ctx context.Context, cli *client.Client, p *chainParams) (ev

func createClient(ctx context.Context, p *chainParams, errChan chan<- error) (*client.Client, error) {
endpoints := p.cfg.GetStringSlice(p.name + ".endpoints")

// deprecated endpoints with priorities
section := p.name + ".endpoint.client"
for i := 0; ; i++ {
addr := p.cfg.GetString(fmt.Sprintf("%s.%d.%s", section, i, "address"))
if addr == "" {
break
}

endpoints = append(endpoints, addr)
}

if len(endpoints) == 0 {
return nil, fmt.Errorf("%s chain client endpoints not provided", p.name)
}
Expand Down
21 changes: 2 additions & 19 deletions pkg/metrics/innerring.go
Original file line number Diff line number Diff line change
@@ -1,21 +1,14 @@
package metrics

import (
"fmt"

"github.com/prometheus/client_golang/prometheus"
)

const innerRingNameSpace = "neofs_ir"

// FIXME: drop after v0.38.0 release: #2347.
const innerRingNameSpaceDeprecated = storageNodeNameSpace
const innerRingSubsystemDeprecated = objectSubsystem

// InnerRingServiceMetrics contains metrics collected by inner ring.
type InnerRingServiceMetrics struct {
epoch prometheus.Gauge
epochDeprecated prometheus.Gauge
epoch prometheus.Gauge
}

// NewInnerRingMetrics returns new instance of metrics collectors for inner ring.
Expand All @@ -30,22 +23,12 @@ func NewInnerRingMetrics(version string) InnerRingServiceMetrics {
})
prometheus.MustRegister(epoch)

epochDeprecated := prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: innerRingNameSpaceDeprecated,
Subsystem: innerRingSubsystemDeprecated,
Name: "epoch",
Help: fmt.Sprintf("Current epoch as seen by inner-ring node. DEPRECATED: use [%s_%s_epoch] instead.", innerRingNameSpace, stateSubsystem),
})
prometheus.MustRegister(epochDeprecated)

return InnerRingServiceMetrics{
epoch: epoch,
epochDeprecated: epochDeprecated,
epoch: epoch,
}
}

// SetEpoch updates epoch metrics.
func (m InnerRingServiceMetrics) SetEpoch(epoch uint64) {
m.epoch.Set(float64(epoch))
m.epochDeprecated.Set(float64(epoch))
}
17 changes: 1 addition & 16 deletions pkg/metrics/metrics.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package metrics

import (
"fmt"

"github.com/prometheus/client_golang/prometheus"
)

Expand All @@ -12,8 +10,7 @@ type NodeMetrics struct {
objectServiceMetrics
engineMetrics
stateMetrics
epoch prometheus.Gauge
epochDeprecated prometheus.Gauge
epoch prometheus.Gauge
}

func NewNodeMetrics(version string) *NodeMetrics {
Expand All @@ -36,27 +33,15 @@ func NewNodeMetrics(version string) *NodeMetrics {
})
prometheus.MustRegister(epoch)

// FIXME: drop after v0.38.0 release: #2347.
const stateSubsystemDeprecated = objectSubsystem
epochDeprecated := prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: storageNodeNameSpace,
Subsystem: stateSubsystemDeprecated,
Name: "epoch",
Help: fmt.Sprintf("Current epoch as seen by inner-ring node. DEPRECATED: use [%s_%s_epoch] instead.", storageNodeNameSpace, stateSubsystem),
})
prometheus.MustRegister(epochDeprecated)

return &NodeMetrics{
objectServiceMetrics: objectService,
engineMetrics: engine,
stateMetrics: state,
epoch: epoch,
epochDeprecated: epochDeprecated,
}
}

// SetEpoch updates epoch metric.
func (m *NodeMetrics) SetEpoch(epoch uint64) {
m.epoch.Set(float64(epoch))
m.epochDeprecated.Set(float64(epoch))
}

0 comments on commit 85a31ff

Please sign in to comment.