forked from TrueCloudLab/frostfs-node
[#1592] Remove debug builds
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
b8508585a5
commit
c4b86cf1f1
8 changed files with 11 additions and 104 deletions
4
Makefile
4
Makefile
|
@ -3,7 +3,6 @@ SHELL = bash
|
||||||
|
|
||||||
REPO ?= $(shell go list -m)
|
REPO ?= $(shell go list -m)
|
||||||
VERSION ?= $(shell git describe --tags --dirty --always 2>/dev/null || cat VERSION 2>/dev/null || echo "develop")
|
VERSION ?= $(shell git describe --tags --dirty --always 2>/dev/null || cat VERSION 2>/dev/null || echo "develop")
|
||||||
DEBUG ?= false
|
|
||||||
|
|
||||||
HUB_IMAGE ?= nspccdev/neofs
|
HUB_IMAGE ?= nspccdev/neofs
|
||||||
HUB_TAG ?= "$(shell echo ${VERSION} | sed 's/^v//')"
|
HUB_TAG ?= "$(shell echo ${VERSION} | sed 's/^v//')"
|
||||||
|
@ -34,8 +33,7 @@ $(BINS): $(DIRS) dep
|
||||||
@echo "⇒ Build $@"
|
@echo "⇒ Build $@"
|
||||||
CGO_ENABLED=0 \
|
CGO_ENABLED=0 \
|
||||||
go build -v -trimpath \
|
go build -v -trimpath \
|
||||||
-ldflags "-X $(REPO)/misc.Version=$(VERSION) \
|
-ldflags "-X $(REPO)/misc.Version=$(VERSION)" \
|
||||||
-X $(REPO)/misc.Debug=$(DEBUG)" \
|
|
||||||
-o $@ ./cmd/$(notdir $@)
|
-o $@ ./cmd/$(notdir $@)
|
||||||
|
|
||||||
$(DIRS):
|
$(DIRS):
|
||||||
|
|
|
@ -80,9 +80,7 @@ func main() {
|
||||||
exitErr(err)
|
exitErr(err)
|
||||||
|
|
||||||
log.Info("application started",
|
log.Info("application started",
|
||||||
zap.String("version", misc.Version),
|
zap.String("version", misc.Version))
|
||||||
zap.String("debug", misc.Debug),
|
|
||||||
)
|
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
|
|
|
@ -1,16 +0,0 @@
|
||||||
package config
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/nspcc-dev/neofs-node/misc"
|
|
||||||
)
|
|
||||||
|
|
||||||
// DebugValue returns debug configuration value.
|
|
||||||
//
|
|
||||||
// Returns nil if misc.Debug is not set to "true".
|
|
||||||
func DebugValue(c *Config, name string) interface{} {
|
|
||||||
if misc.Debug == "true" {
|
|
||||||
return c.Value(name)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
|
@ -110,9 +110,7 @@ func bootUp(c *cfg) {
|
||||||
|
|
||||||
func wait(c *cfg) {
|
func wait(c *cfg) {
|
||||||
c.log.Info("application started",
|
c.log.Info("application started",
|
||||||
zap.String("version", misc.Version),
|
zap.String("version", misc.Version))
|
||||||
zap.String("debug", misc.Debug),
|
|
||||||
)
|
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case <-c.ctx.Done(): // graceful shutdown
|
case <-c.ctx.Done(): // graceful shutdown
|
||||||
|
|
|
@ -9,17 +9,13 @@ import (
|
||||||
var (
|
var (
|
||||||
// Version is an application version.
|
// Version is an application version.
|
||||||
Version = "dev"
|
Version = "dev"
|
||||||
|
|
||||||
// Debug is an application debug mode flag.
|
|
||||||
Debug = "false"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// BuildInfo returns human-readable information about this binary.
|
// BuildInfo returns human-readable information about this binary.
|
||||||
func BuildInfo(component string) string {
|
func BuildInfo(component string) string {
|
||||||
return fmt.Sprintf("%s\nVersion: %s \nGoVersion: %s\nDebug: %s\n",
|
return fmt.Sprintf("%s\nVersion: %s \nGoVersion: %s\n",
|
||||||
component,
|
component,
|
||||||
Version,
|
Version,
|
||||||
runtime.Version(),
|
runtime.Version(),
|
||||||
Debug,
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,57 +0,0 @@
|
||||||
package config
|
|
||||||
|
|
||||||
/*
|
|
||||||
Config package contains GlobalConfig structure that implements config
|
|
||||||
reader from both local and global configurations. Most of the time the inner ring
|
|
||||||
does not need this; as for application, it has static config with timeouts,
|
|
||||||
caches sizes etc. However, there are routines that use global configuration
|
|
||||||
values that can be changed in runtime, e.g. basic income rate. Local
|
|
||||||
configuration value overrides the global one so it is easy to debug and test
|
|
||||||
in different environments.
|
|
||||||
|
|
||||||
Implemented as a part of https://github.com/nspcc-dev/neofs-node/issues/363
|
|
||||||
*/
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/nspcc-dev/neofs-node/misc"
|
|
||||||
netmapClient "github.com/nspcc-dev/neofs-node/pkg/morph/client/netmap"
|
|
||||||
"github.com/spf13/viper"
|
|
||||||
)
|
|
||||||
|
|
||||||
type GlobalConfig struct {
|
|
||||||
cfg *viper.Viper
|
|
||||||
nm *netmapClient.Client
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewGlobalConfigReader(cfg *viper.Viper, nm *netmapClient.Client) *GlobalConfig {
|
|
||||||
return &GlobalConfig{
|
|
||||||
cfg: cfg,
|
|
||||||
nm: nm,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *GlobalConfig) BasicIncomeRate() (uint64, error) {
|
|
||||||
if isDebug() {
|
|
||||||
value := c.cfg.GetUint64("settlement.basic_income_rate")
|
|
||||||
if value != 0 {
|
|
||||||
return value, nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return c.nm.BasicIncomeRate()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *GlobalConfig) AuditFee() (uint64, error) {
|
|
||||||
if isDebug() {
|
|
||||||
value := c.cfg.GetUint64("settlement.audit_fee")
|
|
||||||
if value != 0 {
|
|
||||||
return value, nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return c.nm.AuditFee()
|
|
||||||
}
|
|
||||||
|
|
||||||
func isDebug() bool {
|
|
||||||
return misc.Debug == "true"
|
|
||||||
}
|
|
|
@ -550,9 +550,6 @@ func New(ctx context.Context, log *zap.Logger, cfg *viper.Viper, errChan chan<-
|
||||||
cfg.GetDuration("indexer.cache_timeout"),
|
cfg.GetDuration("indexer.cache_timeout"),
|
||||||
)
|
)
|
||||||
|
|
||||||
// create global runtime config reader
|
|
||||||
globalConfig := config.NewGlobalConfigReader(cfg, server.netmapClient)
|
|
||||||
|
|
||||||
clientCache := newClientCache(&clientCacheParams{
|
clientCache := newClientCache(&clientCacheParams{
|
||||||
Log: log,
|
Log: log,
|
||||||
Key: &server.key.PrivateKey,
|
Key: &server.key.PrivateKey,
|
||||||
|
@ -602,11 +599,10 @@ func New(ctx context.Context, log *zap.Logger, cfg *viper.Viper, errChan chan<-
|
||||||
|
|
||||||
// create settlement processor dependencies
|
// create settlement processor dependencies
|
||||||
settlementDeps := settlementDeps{
|
settlementDeps := settlementDeps{
|
||||||
globalConfig: globalConfig,
|
|
||||||
log: server.log,
|
log: server.log,
|
||||||
cnrSrc: cntClient.AsContainerSource(cnrClient),
|
cnrSrc: cntClient.AsContainerSource(cnrClient),
|
||||||
auditClient: server.auditClient,
|
auditClient: server.auditClient,
|
||||||
nmSrc: server.netmapClient,
|
nmClient: server.netmapClient,
|
||||||
clientCache: clientCache,
|
clientCache: clientCache,
|
||||||
balanceClient: server.balanceClient,
|
balanceClient: server.balanceClient,
|
||||||
}
|
}
|
||||||
|
@ -630,7 +626,7 @@ func New(ctx context.Context, log *zap.Logger, cfg *viper.Viper, errChan chan<-
|
||||||
SGStorage: auditCalcDeps,
|
SGStorage: auditCalcDeps,
|
||||||
AccountStorage: auditCalcDeps,
|
AccountStorage: auditCalcDeps,
|
||||||
Exchanger: auditCalcDeps,
|
Exchanger: auditCalcDeps,
|
||||||
AuditFeeFetcher: auditCalcDeps,
|
AuditFeeFetcher: server.netmapClient,
|
||||||
},
|
},
|
||||||
auditSettlement.WithLogger(server.log),
|
auditSettlement.WithLogger(server.log),
|
||||||
)
|
)
|
||||||
|
|
|
@ -18,6 +18,7 @@ import (
|
||||||
auditClient "github.com/nspcc-dev/neofs-node/pkg/morph/client/audit"
|
auditClient "github.com/nspcc-dev/neofs-node/pkg/morph/client/audit"
|
||||||
balanceClient "github.com/nspcc-dev/neofs-node/pkg/morph/client/balance"
|
balanceClient "github.com/nspcc-dev/neofs-node/pkg/morph/client/balance"
|
||||||
containerClient "github.com/nspcc-dev/neofs-node/pkg/morph/client/container"
|
containerClient "github.com/nspcc-dev/neofs-node/pkg/morph/client/container"
|
||||||
|
netmapClient "github.com/nspcc-dev/neofs-node/pkg/morph/client/netmap"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
|
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
|
||||||
auditAPI "github.com/nspcc-dev/neofs-sdk-go/audit"
|
auditAPI "github.com/nspcc-dev/neofs-sdk-go/audit"
|
||||||
containerAPI "github.com/nspcc-dev/neofs-sdk-go/container"
|
containerAPI "github.com/nspcc-dev/neofs-sdk-go/container"
|
||||||
|
@ -29,26 +30,19 @@ import (
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
)
|
)
|
||||||
|
|
||||||
type globalConfig interface {
|
|
||||||
BasicIncomeRate() (uint64, error)
|
|
||||||
AuditFee() (uint64, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
const (
|
const (
|
||||||
auditSettlementContext = "audit"
|
auditSettlementContext = "audit"
|
||||||
basicIncomeSettlementContext = "basic income"
|
basicIncomeSettlementContext = "basic income"
|
||||||
)
|
)
|
||||||
|
|
||||||
type settlementDeps struct {
|
type settlementDeps struct {
|
||||||
globalConfig
|
|
||||||
|
|
||||||
log *logger.Logger
|
log *logger.Logger
|
||||||
|
|
||||||
cnrSrc container.Source
|
cnrSrc container.Source
|
||||||
|
|
||||||
auditClient *auditClient.Client
|
auditClient *auditClient.Client
|
||||||
|
|
||||||
nmSrc netmap.Source
|
nmClient *netmapClient.Client
|
||||||
|
|
||||||
clientCache *ClientCache
|
clientCache *ClientCache
|
||||||
|
|
||||||
|
@ -132,9 +126,9 @@ func (s settlementDeps) buildContainer(e uint64, cid cid.ID) ([][]netmapAPI.Node
|
||||||
)
|
)
|
||||||
|
|
||||||
if e > 0 {
|
if e > 0 {
|
||||||
nm, err = s.nmSrc.GetNetMapByEpoch(e)
|
nm, err = s.nmClient.GetNetMapByEpoch(e)
|
||||||
} else {
|
} else {
|
||||||
nm, err = netmap.GetLatestNetworkMap(s.nmSrc)
|
nm, err = netmap.GetLatestNetworkMap(s.nmClient)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -254,7 +248,7 @@ func (s settlementDeps) Transfer(sender, recipient user.ID, amount *big.Int, det
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b basicIncomeSettlementDeps) BasicRate() (uint64, error) {
|
func (b basicIncomeSettlementDeps) BasicRate() (uint64, error) {
|
||||||
return b.BasicIncomeRate()
|
return b.nmClient.BasicIncomeRate()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b basicIncomeSettlementDeps) Estimations(epoch uint64) ([]*containerClient.Estimations, error) {
|
func (b basicIncomeSettlementDeps) Estimations(epoch uint64) ([]*containerClient.Estimations, error) {
|
||||||
|
|
Loading…
Reference in a new issue