forked from TrueCloudLab/frostfs-node
[#1135] ir: Add healthstatus RECONFIGURING
Signed-off-by: Ekaterina Lebedeva <ekaterina.lebedeva@yadro.com>
This commit is contained in:
parent
4c520be9f1
commit
f82b7e1ae3
6 changed files with 21 additions and 0 deletions
|
@ -7,6 +7,7 @@ import (
|
||||||
|
|
||||||
configViper "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/internal/common/config"
|
configViper "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/internal/common/config"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/internal/logs"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/internal/logs"
|
||||||
|
control "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/control/ir"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
)
|
)
|
||||||
|
@ -81,6 +82,10 @@ func watchForSignal(cancel func()) {
|
||||||
return
|
return
|
||||||
case <-sighupCh:
|
case <-sighupCh:
|
||||||
log.Info(logs.FrostFSNodeSIGHUPHasBeenReceivedRereadingConfiguration)
|
log.Info(logs.FrostFSNodeSIGHUPHasBeenReceivedRereadingConfiguration)
|
||||||
|
if !innerRing.CompareAndSwapHealthStatus(control.HealthStatus_READY, control.HealthStatus_RECONFIGURING) {
|
||||||
|
log.Info(logs.FrostFSNodeSIGHUPSkip)
|
||||||
|
break
|
||||||
|
}
|
||||||
err := reloadConfig()
|
err := reloadConfig()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(logs.FrostFSNodeConfigurationReading, zap.Error(err))
|
log.Error(logs.FrostFSNodeConfigurationReading, zap.Error(err))
|
||||||
|
@ -92,6 +97,7 @@ func watchForSignal(cancel func()) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(logs.FrostFSNodeConfigurationReading, zap.Error(err))
|
log.Error(logs.FrostFSNodeConfigurationReading, zap.Error(err))
|
||||||
}
|
}
|
||||||
|
innerRing.CompareAndSwapHealthStatus(control.HealthStatus_RECONFIGURING, control.HealthStatus_READY)
|
||||||
log.Info(logs.FrostFSNodeConfigurationHasBeenReloadedSuccessfully)
|
log.Info(logs.FrostFSNodeConfigurationHasBeenReloadedSuccessfully)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -161,6 +161,16 @@ func (s *Server) setHealthStatus(hs control.HealthStatus) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *Server) CompareAndSwapHealthStatus(oldSt, newSt control.HealthStatus) (swapped bool) {
|
||||||
|
if swapped = s.healthStatus.CompareAndSwap(int32(oldSt), int32(newSt)); swapped {
|
||||||
|
s.notifySystemd(newSt)
|
||||||
|
if s.irMetrics != nil {
|
||||||
|
s.irMetrics.SetHealth(int32(newSt))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// HealthStatus returns the current health status of the IR application.
|
// HealthStatus returns the current health status of the IR application.
|
||||||
func (s *Server) HealthStatus() control.HealthStatus {
|
func (s *Server) HealthStatus() control.HealthStatus {
|
||||||
return control.HealthStatus(s.healthStatus.Load())
|
return control.HealthStatus(s.healthStatus.Load())
|
||||||
|
@ -186,6 +196,8 @@ func (s *Server) notifySystemd(st control.HealthStatus) {
|
||||||
err = sdnotify.FlagAndStatus(sdnotify.ReadyEnabled)
|
err = sdnotify.FlagAndStatus(sdnotify.ReadyEnabled)
|
||||||
case control.HealthStatus_SHUTTING_DOWN:
|
case control.HealthStatus_SHUTTING_DOWN:
|
||||||
err = sdnotify.FlagAndStatus(sdnotify.StoppingEnabled)
|
err = sdnotify.FlagAndStatus(sdnotify.StoppingEnabled)
|
||||||
|
case control.HealthStatus_RECONFIGURING:
|
||||||
|
err = sdnotify.FlagAndStatus(sdnotify.ReloadingEnabled)
|
||||||
default:
|
default:
|
||||||
err = sdnotify.Status(fmt.Sprintf("%v", st))
|
err = sdnotify.Status(fmt.Sprintf("%v", st))
|
||||||
}
|
}
|
||||||
|
|
BIN
pkg/services/control/ir/service_grpc.pb.go
generated
BIN
pkg/services/control/ir/service_grpc.pb.go
generated
Binary file not shown.
BIN
pkg/services/control/ir/types.pb.go
generated
BIN
pkg/services/control/ir/types.pb.go
generated
Binary file not shown.
|
@ -26,4 +26,7 @@ enum HealthStatus {
|
||||||
|
|
||||||
// IR application is shutting down.
|
// IR application is shutting down.
|
||||||
SHUTTING_DOWN = 3;
|
SHUTTING_DOWN = 3;
|
||||||
|
|
||||||
|
// IR application is reconfiguring.
|
||||||
|
RECONFIGURING = 4;
|
||||||
}
|
}
|
||||||
|
|
BIN
pkg/services/tree/service_grpc.pb.go
generated
BIN
pkg/services/tree/service_grpc.pb.go
generated
Binary file not shown.
Loading…
Reference in a new issue