forked from TrueCloudLab/frostfs-node
[#168] node: Refactor node config
Resolve containedctx linter for cfg Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
parent
8426d25f4b
commit
a7c79c773a
20 changed files with 93 additions and 83 deletions
|
@ -303,10 +303,8 @@ func (a *applicationConfiguration) readConfig(c *config.Config) error {
|
|||
// the application life cycle.
|
||||
// It should not contain any read configuration values, component-specific
|
||||
// helpers and fields.
|
||||
// nolint: containedctx
|
||||
type internals struct {
|
||||
ctx context.Context
|
||||
ctxCancel func()
|
||||
done chan struct{}
|
||||
internalErr chan error // channel for internal application errors at runtime
|
||||
|
||||
appCfg *config.Config
|
||||
|
@ -570,7 +568,7 @@ func initCfg(appCfg *config.Config) *cfg {
|
|||
fatalOnErr(err)
|
||||
|
||||
c.internals = internals{
|
||||
ctx: context.Background(),
|
||||
done: make(chan struct{}),
|
||||
appCfg: appCfg,
|
||||
internalErr: make(chan error),
|
||||
log: log,
|
||||
|
@ -940,7 +938,7 @@ type dCmp struct {
|
|||
reloadFunc func() error
|
||||
}
|
||||
|
||||
func (c *cfg) signalWatcher() {
|
||||
func (c *cfg) signalWatcher(ctx context.Context) {
|
||||
ch := make(chan os.Signal, 1)
|
||||
signal.Notify(ch, syscall.SIGHUP, syscall.SIGINT, syscall.SIGTERM)
|
||||
|
||||
|
@ -949,7 +947,7 @@ func (c *cfg) signalWatcher() {
|
|||
case sig := <-ch:
|
||||
switch sig {
|
||||
case syscall.SIGHUP:
|
||||
c.reloadConfig()
|
||||
c.reloadConfig(ctx)
|
||||
case syscall.SIGTERM, syscall.SIGINT:
|
||||
c.log.Info("termination signal has been received, stopping...")
|
||||
// TODO (@acid-ant): #49 need to cover case when stuck at the middle(node health UNDEFINED or STARTING)
|
||||
|
@ -971,7 +969,7 @@ func (c *cfg) signalWatcher() {
|
|||
}
|
||||
}
|
||||
|
||||
func (c *cfg) reloadConfig() {
|
||||
func (c *cfg) reloadConfig(ctx context.Context) {
|
||||
c.log.Info("SIGHUP has been received, rereading configuration...")
|
||||
|
||||
err := c.readConfig(c.appCfg)
|
||||
|
@ -999,10 +997,10 @@ func (c *cfg) reloadConfig() {
|
|||
} else {
|
||||
cmp.preReload = disableMetricsSvc
|
||||
}
|
||||
components = append(components, dCmp{cmp.name, cmp.reload})
|
||||
components = append(components, dCmp{cmp.name, func() error { return cmp.reload(ctx) }})
|
||||
}
|
||||
if cmp, updated := pprofComponent(c); updated {
|
||||
components = append(components, dCmp{cmp.name, cmp.reload})
|
||||
components = append(components, dCmp{cmp.name, func() error { return cmp.reload(ctx) }})
|
||||
}
|
||||
|
||||
// Storage Engine
|
||||
|
@ -1012,7 +1010,7 @@ func (c *cfg) reloadConfig() {
|
|||
rcfg.AddShard(optsWithID.configID, optsWithID.shOpts)
|
||||
}
|
||||
|
||||
err = c.cfgObject.cfgLocalStorage.localStorage.Reload(rcfg)
|
||||
err = c.cfgObject.cfgLocalStorage.localStorage.Reload(ctx, rcfg)
|
||||
if err != nil {
|
||||
c.log.Error("storage engine configuration update", zap.Error(err))
|
||||
return
|
||||
|
@ -1033,7 +1031,7 @@ func (c *cfg) reloadConfig() {
|
|||
func (c *cfg) shutdown() {
|
||||
c.setHealthStatus(control.HealthStatus_SHUTTING_DOWN)
|
||||
|
||||
c.ctxCancel()
|
||||
c.done <- struct{}{}
|
||||
for i := range c.closers {
|
||||
c.closers[len(c.closers)-1-i].fn()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue