[#1592] Remove debug builds

Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
Evgenii Stratonikov 2022-07-13 17:45:33 +03:00 committed by fyrchik
parent b8508585a5
commit c4b86cf1f1
8 changed files with 11 additions and 104 deletions

View file

@ -3,7 +3,6 @@ SHELL = bash
REPO ?= $(shell go list -m)
VERSION ?= $(shell git describe --tags --dirty --always 2>/dev/null || cat VERSION 2>/dev/null || echo "develop")
DEBUG ?= false
HUB_IMAGE ?= nspccdev/neofs
HUB_TAG ?= "$(shell echo ${VERSION} | sed 's/^v//')"
@ -34,8 +33,7 @@ $(BINS): $(DIRS) dep
@echo "⇒ Build $@"
CGO_ENABLED=0 \
go build -v -trimpath \
-ldflags "-X $(REPO)/misc.Version=$(VERSION) \
-X $(REPO)/misc.Debug=$(DEBUG)" \
-ldflags "-X $(REPO)/misc.Version=$(VERSION)" \
-o $@ ./cmd/$(notdir $@)
$(DIRS):

View file

@ -80,9 +80,7 @@ func main() {
exitErr(err)
log.Info("application started",
zap.String("version", misc.Version),
zap.String("debug", misc.Debug),
)
zap.String("version", misc.Version))
select {
case <-ctx.Done():

View file

@ -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
}

View file

@ -110,9 +110,7 @@ func bootUp(c *cfg) {
func wait(c *cfg) {
c.log.Info("application started",
zap.String("version", misc.Version),
zap.String("debug", misc.Debug),
)
zap.String("version", misc.Version))
select {
case <-c.ctx.Done(): // graceful shutdown

View file

@ -9,17 +9,13 @@ import (
var (
// Version is an application version.
Version = "dev"
// Debug is an application debug mode flag.
Debug = "false"
)
// BuildInfo returns human-readable information about this binary.
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,
Version,
runtime.Version(),
Debug,
)
}

View file

@ -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"
}

View file

@ -550,9 +550,6 @@ func New(ctx context.Context, log *zap.Logger, cfg *viper.Viper, errChan chan<-
cfg.GetDuration("indexer.cache_timeout"),
)
// create global runtime config reader
globalConfig := config.NewGlobalConfigReader(cfg, server.netmapClient)
clientCache := newClientCache(&clientCacheParams{
Log: log,
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
settlementDeps := settlementDeps{
globalConfig: globalConfig,
log: server.log,
cnrSrc: cntClient.AsContainerSource(cnrClient),
auditClient: server.auditClient,
nmSrc: server.netmapClient,
nmClient: server.netmapClient,
clientCache: clientCache,
balanceClient: server.balanceClient,
}
@ -630,7 +626,7 @@ func New(ctx context.Context, log *zap.Logger, cfg *viper.Viper, errChan chan<-
SGStorage: auditCalcDeps,
AccountStorage: auditCalcDeps,
Exchanger: auditCalcDeps,
AuditFeeFetcher: auditCalcDeps,
AuditFeeFetcher: server.netmapClient,
},
auditSettlement.WithLogger(server.log),
)

View file

@ -18,6 +18,7 @@ import (
auditClient "github.com/nspcc-dev/neofs-node/pkg/morph/client/audit"
balanceClient "github.com/nspcc-dev/neofs-node/pkg/morph/client/balance"
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"
auditAPI "github.com/nspcc-dev/neofs-sdk-go/audit"
containerAPI "github.com/nspcc-dev/neofs-sdk-go/container"
@ -29,26 +30,19 @@ import (
"go.uber.org/zap"
)
type globalConfig interface {
BasicIncomeRate() (uint64, error)
AuditFee() (uint64, error)
}
const (
auditSettlementContext = "audit"
basicIncomeSettlementContext = "basic income"
)
type settlementDeps struct {
globalConfig
log *logger.Logger
cnrSrc container.Source
auditClient *auditClient.Client
nmSrc netmap.Source
nmClient *netmapClient.Client
clientCache *ClientCache
@ -132,9 +126,9 @@ func (s settlementDeps) buildContainer(e uint64, cid cid.ID) ([][]netmapAPI.Node
)
if e > 0 {
nm, err = s.nmSrc.GetNetMapByEpoch(e)
nm, err = s.nmClient.GetNetMapByEpoch(e)
} else {
nm, err = netmap.GetLatestNetworkMap(s.nmSrc)
nm, err = netmap.GetLatestNetworkMap(s.nmClient)
}
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) {
return b.BasicIncomeRate()
return b.nmClient.BasicIncomeRate()
}
func (b basicIncomeSettlementDeps) Estimations(epoch uint64) ([]*containerClient.Estimations, error) {