[#552] Add sysd notifications to storage service
Signed-off-by: Ekaterina Lebedeva <ekaterina.lebedeva@yadro.com>
This commit is contained in:
parent
eca7ac9f0d
commit
ef07c1a3c9
3 changed files with 29 additions and 5 deletions
|
@ -62,6 +62,7 @@ import (
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/util/response"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/util/response"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/logger"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/logger"
|
||||||
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/sdnotify"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/state"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/state"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-observability/logging/lokicore"
|
"git.frostfs.info/TrueCloudLab/frostfs-observability/logging/lokicore"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-observability/tracing"
|
"git.frostfs.info/TrueCloudLab/frostfs-observability/tracing"
|
||||||
|
@ -361,6 +362,8 @@ type internals struct {
|
||||||
healthStatus *atomic.Int32
|
healthStatus *atomic.Int32
|
||||||
// is node under maintenance
|
// is node under maintenance
|
||||||
isMaintenance atomic.Bool
|
isMaintenance atomic.Bool
|
||||||
|
|
||||||
|
sdNotify bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// starts node's maintenance.
|
// starts node's maintenance.
|
||||||
|
@ -632,9 +635,18 @@ func initInternals(appCfg *config.Config, log *logger.Logger) internals {
|
||||||
log: log,
|
log: log,
|
||||||
apiVersion: version.Current(),
|
apiVersion: version.Current(),
|
||||||
healthStatus: &healthStatus,
|
healthStatus: &healthStatus,
|
||||||
|
sdNotify: initSdNotify(appCfg),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func initSdNotify(appCfg *config.Config) bool {
|
||||||
|
if config.BoolSafe(appCfg.Sub("systemdnotify"), "enabled") {
|
||||||
|
fatalOnErr(sdnotify.InitSocket())
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
func initShared(appCfg *config.Config, key *keys.PrivateKey, netState *networkState, relayOnly bool) shared {
|
func initShared(appCfg *config.Config, key *keys.PrivateKey, netState *networkState, relayOnly bool) shared {
|
||||||
var netAddr network.AddressGroup
|
var netAddr network.AddressGroup
|
||||||
|
|
||||||
|
|
|
@ -110,12 +110,21 @@ func (c *cfg) HealthStatus() control.HealthStatus {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *cfg) notifySystemd(st control.HealthStatus) {
|
func (c *cfg) notifySystemd(st control.HealthStatus) {
|
||||||
status := fmt.Sprintf("%v, %v", st.Number(), st)
|
if !c.sdNotify {
|
||||||
err := sdnotify.Status(status)
|
return
|
||||||
if err == nil {
|
}
|
||||||
c.log.Info(fmt.Sprintf("reported STATUS=\"%v\" to systemd", status))
|
var err error
|
||||||
|
switch st {
|
||||||
|
case control.HealthStatus_READY:
|
||||||
|
err = sdnotify.FlagAndStatus(sdnotify.ReadyEnabled)
|
||||||
|
case control.HealthStatus_SHUTTING_DOWN:
|
||||||
|
err = sdnotify.FlagAndStatus(sdnotify.StoppingEnabled)
|
||||||
|
case control.HealthStatus_RECONFIGURING:
|
||||||
|
err = sdnotify.FlagAndStatus(sdnotify.ReloadingEnabled)
|
||||||
|
default:
|
||||||
|
err = sdnotify.Status(fmt.Sprintf("%v", st))
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.log.Error(logs.FailedToReportStatusToSystemd, zap.String("error", err.Error()))
|
c.log.Error(logs.FailedToReportStatusToSystemd, zap.Error(err))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
logger:
|
logger:
|
||||||
level: debug # logger level: one of "debug", "info" (default), "warn", "error", "dpanic", "panic", "fatal"
|
level: debug # logger level: one of "debug", "info" (default), "warn", "error", "dpanic", "panic", "fatal"
|
||||||
|
|
||||||
|
systemdnotify:
|
||||||
|
enabled: true
|
||||||
|
|
||||||
pprof:
|
pprof:
|
||||||
enabled: true
|
enabled: true
|
||||||
address: localhost:6060 # endpoint for Node profiling
|
address: localhost:6060 # endpoint for Node profiling
|
||||||
|
|
Loading…
Reference in a new issue