Skip to content

Commit

Permalink
node: Fix field name conflicts
Browse files Browse the repository at this point in the history
`appCfg` may conflict with `applicationConfiguration`. It just reads config,
it is not a storage for read values.

Signed-off-by: Pavel Karpy <[email protected]>
  • Loading branch information
carpawell committed Dec 26, 2023
1 parent 7cef827 commit d5ce304
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 25 deletions.
4 changes: 2 additions & 2 deletions cmd/neofs-node/attributes.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import (
)

func parseAttributes(c *cfg) {
if nodeconfig.Relay(c.appCfg) {
if nodeconfig.Relay(c.cfgReader) {
return
}

fatalOnErr(attributes.ReadNodeAttributes(&c.cfgNodeInfo.localInfo, nodeconfig.Attributes(c.appCfg)))
fatalOnErr(attributes.ReadNodeAttributes(&c.cfgNodeInfo.localInfo, nodeconfig.Attributes(c.cfgReader)))

// expand UN/LOCODE attribute if any found; keep user's attributes
// if any conflicts appear
Expand Down
8 changes: 4 additions & 4 deletions cmd/neofs-node/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ type internals struct {
ctxCancel func()
internalErr chan error // channel for internal application errors at runtime

appCfg *config.Config
cfgReader *config.Config

logLevel zap.AtomicLevel
log *zap.Logger
Expand Down Expand Up @@ -539,7 +539,7 @@ func initCfg(appCfg *config.Config) *cfg {

c.internals = internals{
ctx: context.Background(),
appCfg: appCfg,
cfgReader: appCfg,
internalErr: make(chan error, 10), // We only need one error, but we can have multiple senders.
wg: new(sync.WaitGroup),
apiVersion: version.Current(),
Expand Down Expand Up @@ -616,7 +616,7 @@ func initCfg(appCfg *config.Config) *cfg {

c.ownerIDFromKey = user.ResolveFromECDSAPublicKey(key.PrivateKey.PublicKey)

if metricsconfig.Enabled(c.appCfg) {
if metricsconfig.Enabled(c.cfgReader) {
c.metricsCollector = metrics.NewNodeMetrics(misc.Version)
netState.metrics = c.metricsCollector
}
Expand Down Expand Up @@ -927,7 +927,7 @@ func (c *cfg) configWatcher(ctx context.Context) {
case <-ch:
c.log.Info("SIGHUP has been received, rereading configuration...")

err := c.readConfig(c.appCfg)
err := c.readConfig(c.cfgReader)
if err != nil {
c.log.Error("configuration reading", zap.Error(err))
continue
Expand Down
4 changes: 2 additions & 2 deletions cmd/neofs-node/control.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ func (t treeSynchronizer) Synchronize(ctx context.Context, cnr cid.ID, treeID st
}

func initControlService(c *cfg) {
endpoint := controlconfig.GRPC(c.appCfg).Endpoint()
endpoint := controlconfig.GRPC(c.cfgReader).Endpoint()
if endpoint == controlconfig.GRPCEndpointDefault {
return
}

pubs := controlconfig.AuthorizedKeys(c.appCfg)
pubs := controlconfig.AuthorizedKeys(c.cfgReader)
rawPubs := make([][]byte, 0, len(pubs)+1) // +1 for node key

rawPubs = append(rawPubs, c.key.PublicKey().Bytes())
Expand Down
2 changes: 1 addition & 1 deletion cmd/neofs-node/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (

func initGRPC(c *cfg) {
var successCount int
grpcconfig.IterateEndpoints(c.appCfg, func(sc *grpcconfig.Config) {
grpcconfig.IterateEndpoints(c.cfgReader, func(sc *grpcconfig.Config) {
serverOpts := []grpc.ServerOption{
grpc.MaxSendMsgSize(maxMsgSize),
}
Expand Down
6 changes: 3 additions & 3 deletions cmd/neofs-node/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ import (
)

func initMetrics(c *cfg) *httputil.Server {
if !metricsconfig.Enabled(c.appCfg) {
if !metricsconfig.Enabled(c.cfgReader) {
c.log.Info("prometheus is disabled")
return nil
}

var prm httputil.Prm

prm.Address = metricsconfig.Address(c.appCfg)
prm.Address = metricsconfig.Address(c.cfgReader)
prm.Handler = promhttp.Handler()

srv := httputil.New(prm,
httputil.WithShutdownTimeout(
metricsconfig.ShutdownTimeout(c.appCfg),
metricsconfig.ShutdownTimeout(c.cfgReader),
),
)

Expand Down
14 changes: 7 additions & 7 deletions cmd/neofs-node/notificator.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ func (n notificationWriter) Notify(topic string, address oid.Address) {
}

func initNotifications(c *cfg) {
if nodeconfig.Notification(c.appCfg).Enabled() {
topic := nodeconfig.Notification(c.appCfg).DefaultTopic()
if nodeconfig.Notification(c.cfgReader).Enabled() {
topic := nodeconfig.Notification(c.cfgReader).DefaultTopic()
pubKey := hex.EncodeToString(c.cfgNodeInfo.localInfo.PublicKey())

if topic == "" {
Expand All @@ -117,12 +117,12 @@ func initNotifications(c *cfg) {

natsSvc := nats.New(
nats.WithConnectionName("NeoFS Storage Node: "+pubKey), // connection name is used in the server side logs
nats.WithTimeout(nodeconfig.Notification(c.appCfg).Timeout()),
nats.WithTimeout(nodeconfig.Notification(c.cfgReader).Timeout()),
nats.WithClientCert(
nodeconfig.Notification(c.appCfg).CertPath(),
nodeconfig.Notification(c.appCfg).KeyPath(),
nodeconfig.Notification(c.cfgReader).CertPath(),
nodeconfig.Notification(c.cfgReader).KeyPath(),
),
nats.WithRootCA(nodeconfig.Notification(c.appCfg).CAPath()),
nats.WithRootCA(nodeconfig.Notification(c.cfgReader).CAPath()),
nats.WithLogger(c.log),
)

Expand Down Expand Up @@ -159,7 +159,7 @@ func connectNats(c *cfg) {
return
}

endpoint := nodeconfig.Notification(c.appCfg).Endpoint()
endpoint := nodeconfig.Notification(c.cfgReader).Endpoint()
err := c.cfgNotifications.nw.w.Connect(c.ctx, endpoint)
if err != nil {
panic(fmt.Sprintf("could not connect to a nats endpoint %s: %v", endpoint, err))
Expand Down
2 changes: 1 addition & 1 deletion cmd/neofs-node/object.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ func initObjectService(c *cfg) {
c.replicator = replicator.New(
replicator.WithLogger(c.log),
replicator.WithPutTimeout(
replicatorconfig.PutTimeout(c.appCfg),
replicatorconfig.PutTimeout(c.cfgReader),
),
replicator.WithLocalStorage(ls),
replicator.WithRemoteSender(
Expand Down
6 changes: 3 additions & 3 deletions cmd/neofs-node/pprof.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@ import (
)

func initProfiler(c *cfg) *httputil.Server {
if !profilerconfig.Enabled(c.appCfg) {
if !profilerconfig.Enabled(c.cfgReader) {
c.log.Info("pprof is disabled")
return nil
}

var prm httputil.Prm

prm.Address = profilerconfig.Address(c.appCfg)
prm.Address = profilerconfig.Address(c.cfgReader)
prm.Handler = httputil.Handler()

srv := httputil.New(prm,
httputil.WithShutdownTimeout(
profilerconfig.ShutdownTimeout(c.appCfg),
profilerconfig.ShutdownTimeout(c.cfgReader),
),
)

Expand Down
2 changes: 1 addition & 1 deletion cmd/neofs-node/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ type sessionStorage interface {
}

func initSessionService(c *cfg) {
if persistentSessionPath := nodeconfig.PersistentSessions(c.appCfg).Path(); persistentSessionPath != "" {
if persistentSessionPath := nodeconfig.PersistentSessions(c.cfgReader).Path(); persistentSessionPath != "" {
persisessions, err := persistent.NewTokenStore(persistentSessionPath,
persistent.WithLogger(c.log),
persistent.WithTimeout(time.Second),
Expand Down
2 changes: 1 addition & 1 deletion cmd/neofs-node/tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func (c cnrSource) List() ([]cid.ID, error) {
}

func initTreeService(c *cfg) {
treeConfig := treeconfig.Tree(c.appCfg)
treeConfig := treeconfig.Tree(c.cfgReader)
if !treeConfig.Enabled() {
c.log.Info("tree service is not enabled, skip initialization")
return
Expand Down

0 comments on commit d5ce304

Please sign in to comment.