forked from TrueCloudLab/frostfs-node
[#1770] node: Validate config before apply it
Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
parent
8ebe95747e
commit
1e35c12cc1
1 changed files with 12 additions and 5 deletions
|
@ -152,15 +152,22 @@ type subStorageCfg struct {
|
||||||
// not modifying them.
|
// not modifying them.
|
||||||
func (a *applicationConfiguration) readConfig(c *config.Config) error {
|
func (a *applicationConfiguration) readConfig(c *config.Config) error {
|
||||||
if a._read {
|
if a._read {
|
||||||
// clear if it is rereading
|
|
||||||
*a = applicationConfiguration{}
|
|
||||||
|
|
||||||
err := c.Reload()
|
err := c.Reload()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return fmt.Errorf("could not reload configuration: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err = validateConfig(c)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("configuration's validation: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// clear if it is rereading
|
||||||
|
*a = applicationConfiguration{}
|
||||||
} else {
|
} else {
|
||||||
// update the status
|
// update the status.
|
||||||
|
// initial configuration validation is expected to be
|
||||||
|
// performed on the higher level
|
||||||
a._read = true
|
a._read = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue