forked from TrueCloudLab/frostfs-node
[#1072] node, ir: Add new config option kludge_compatibility_mode
Signed-off-by: Anton Nikiforov <an.nikiforov@yadro.com>
This commit is contained in:
parent
d614f04a0a
commit
9aa533e59a
6 changed files with 28 additions and 3 deletions
|
@ -34,6 +34,7 @@ func reloadConfig() error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
cmode.Store(cfg.GetBool("node.kludge_compatibility_mode"))
|
||||||
err = logPrm.SetLevelString(cfg.GetString("logger.level"))
|
err = logPrm.SetLevelString(cfg.GetString("logger.level"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -43,6 +43,8 @@ func defaultConfiguration(cfg *viper.Viper) {
|
||||||
setControlDefaults(cfg)
|
setControlDefaults(cfg)
|
||||||
|
|
||||||
cfg.SetDefault("governance.disable", false)
|
cfg.SetDefault("governance.disable", false)
|
||||||
|
|
||||||
|
cfg.SetDefault("node.kludge_compatibility_mode", false)
|
||||||
}
|
}
|
||||||
|
|
||||||
func setControlDefaults(cfg *viper.Viper) {
|
func setControlDefaults(cfg *viper.Viper) {
|
||||||
|
|
|
@ -6,6 +6,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"sync"
|
"sync"
|
||||||
|
"sync/atomic"
|
||||||
|
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/internal/logs"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/internal/logs"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/misc"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/misc"
|
||||||
|
@ -37,6 +38,7 @@ var (
|
||||||
cfg *viper.Viper
|
cfg *viper.Viper
|
||||||
configFile *string
|
configFile *string
|
||||||
configDir *string
|
configDir *string
|
||||||
|
cmode = &atomic.Bool{}
|
||||||
)
|
)
|
||||||
|
|
||||||
func exitErr(err error) {
|
func exitErr(err error) {
|
||||||
|
@ -62,6 +64,8 @@ func main() {
|
||||||
cfg, err = newConfig()
|
cfg, err = newConfig()
|
||||||
exitErr(err)
|
exitErr(err)
|
||||||
|
|
||||||
|
cmode.Store(cfg.GetBool("node.kludge_compatibility_mode"))
|
||||||
|
|
||||||
metrics := irMetrics.NewInnerRingMetrics()
|
metrics := irMetrics.NewInnerRingMetrics()
|
||||||
|
|
||||||
err = logPrm.SetLevelString(
|
err = logPrm.SetLevelString(
|
||||||
|
@ -84,7 +88,7 @@ func main() {
|
||||||
metricsCmp = newMetricsComponent()
|
metricsCmp = newMetricsComponent()
|
||||||
metricsCmp.init()
|
metricsCmp.init()
|
||||||
|
|
||||||
innerRing, err = innerring.New(ctx, log, cfg, intErr, metrics)
|
innerRing, err = innerring.New(ctx, log, cfg, intErr, metrics, cmode)
|
||||||
exitErr(err)
|
exitErr(err)
|
||||||
|
|
||||||
pprofCmp.start()
|
pprofCmp.start()
|
||||||
|
|
|
@ -109,6 +109,9 @@ type applicationConfiguration struct {
|
||||||
lowMem bool
|
lowMem bool
|
||||||
rebuildWorkers uint32
|
rebuildWorkers uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if need to run node in compatibility with other versions mode
|
||||||
|
cmode *atomic.Bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type shardCfg struct {
|
type shardCfg struct {
|
||||||
|
@ -204,10 +207,13 @@ func (a *applicationConfiguration) readConfig(c *config.Config) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// clear if it is rereading
|
// clear if it is rereading
|
||||||
|
cmode := a.cmode
|
||||||
*a = applicationConfiguration{}
|
*a = applicationConfiguration{}
|
||||||
|
a.cmode = cmode
|
||||||
}
|
}
|
||||||
|
|
||||||
a._read = true
|
a._read = true
|
||||||
|
a.cmode.Store(nodeconfig.CompatibilityMode(c))
|
||||||
|
|
||||||
// Logger
|
// Logger
|
||||||
|
|
||||||
|
@ -648,7 +654,11 @@ type cfgControlService struct {
|
||||||
var persistateSideChainLastBlockKey = []byte("side_chain_last_processed_block")
|
var persistateSideChainLastBlockKey = []byte("side_chain_last_processed_block")
|
||||||
|
|
||||||
func initCfg(appCfg *config.Config) *cfg {
|
func initCfg(appCfg *config.Config) *cfg {
|
||||||
c := &cfg{}
|
c := &cfg{
|
||||||
|
applicationConfiguration: applicationConfiguration{
|
||||||
|
cmode: &atomic.Bool{},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
err := c.readConfig(appCfg)
|
err := c.readConfig(appCfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -292,3 +292,8 @@ func (l PersistentPolicyRulesConfig) Perm() fs.FileMode {
|
||||||
func (l PersistentPolicyRulesConfig) NoSync() bool {
|
func (l PersistentPolicyRulesConfig) NoSync() bool {
|
||||||
return config.BoolSafe((*config.Config)(l.cfg), "no_sync")
|
return config.BoolSafe((*config.Config)(l.cfg), "no_sync")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CompatibilityMode returns true if need to run node in compatibility with previous versions mode.
|
||||||
|
func CompatibilityMode(c *config.Config) bool {
|
||||||
|
return config.BoolSafe(c.Sub(subsection), "kludge_compatibility_mode")
|
||||||
|
}
|
||||||
|
|
|
@ -103,6 +103,8 @@ type (
|
||||||
// should report start errors
|
// should report start errors
|
||||||
// to the application.
|
// to the application.
|
||||||
runners []func(chan<- error) error
|
runners []func(chan<- error) error
|
||||||
|
|
||||||
|
cmode *atomic.Bool
|
||||||
}
|
}
|
||||||
|
|
||||||
chainParams struct {
|
chainParams struct {
|
||||||
|
@ -330,12 +332,13 @@ func (s *Server) registerStarter(f func() error) {
|
||||||
|
|
||||||
// New creates instance of inner ring sever structure.
|
// New creates instance of inner ring sever structure.
|
||||||
func New(ctx context.Context, log *logger.Logger, cfg *viper.Viper, errChan chan<- error,
|
func New(ctx context.Context, log *logger.Logger, cfg *viper.Viper, errChan chan<- error,
|
||||||
metrics *metrics.InnerRingServiceMetrics,
|
metrics *metrics.InnerRingServiceMetrics, cmode *atomic.Bool,
|
||||||
) (*Server, error) {
|
) (*Server, error) {
|
||||||
var err error
|
var err error
|
||||||
server := &Server{
|
server := &Server{
|
||||||
log: log,
|
log: log,
|
||||||
irMetrics: metrics,
|
irMetrics: metrics,
|
||||||
|
cmode: cmode,
|
||||||
}
|
}
|
||||||
|
|
||||||
server.sdNotify, err = server.initSdNotify(cfg)
|
server.sdNotify, err = server.initSdNotify(cfg)
|
||||||
|
|
Loading…
Reference in a new issue