From a7f03d155b5d7b0c2c9ccabd31f2b95c71b5967a Mon Sep 17 00:00:00 2001 From: Andrey Butusov Date: Wed, 11 Sep 2024 20:24:52 +0300 Subject: [PATCH 1/3] ir: fix a typo Signed-off-by: Andrey Butusov --- pkg/innerring/innerring.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/innerring/innerring.go b/pkg/innerring/innerring.go index 001cc70cb0..dcfbfd5637 100644 --- a/pkg/innerring/innerring.go +++ b/pkg/innerring/innerring.go @@ -308,7 +308,7 @@ func (s *Server) registerCloser(f func() error) { s.closers = append(s.closers, f) } -// New creates instance of inner ring sever structure. +// New creates instance of inner ring server structure. func New(ctx context.Context, log *zap.Logger, cfg *viper.Viper, errChan chan<- error) (*Server, error) { var err error server := &Server{log: log} From 3149d62d073dd7cc667be068d80fe1627e2e2dfc Mon Sep 17 00:00:00 2001 From: Andrey Butusov Date: Wed, 11 Sep 2024 20:32:28 +0300 Subject: [PATCH 2/3] ir: add new health status `INITIALIZING_NETWORK` in ir `New` func New health status for time-spending process - initializing Neo network by blockchain: `INITIALIZING_NETWORK`. Closes #2923. Signed-off-by: Andrey Butusov --- pkg/innerring/innerring.go | 1 + pkg/services/control/ir/types.pb.go | 18 +++++++++++------- pkg/services/control/ir/types.proto | 3 +++ 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/pkg/innerring/innerring.go b/pkg/innerring/innerring.go index dcfbfd5637..8f30cf300c 100644 --- a/pkg/innerring/innerring.go +++ b/pkg/innerring/innerring.go @@ -550,6 +550,7 @@ func New(ctx context.Context, log *zap.Logger, cfg *viper.Viper, errChan chan<- setNetworkSettingsDefaults(&deployPrm.NetmapContract.Config) + server.setHealthStatus(control.HealthStatus_INITIALIZING_NETWORK) err = deploy.Deploy(ctx, deployPrm) if err != nil { return nil, fmt.Errorf("deploy Sidechain: %w", err) diff --git a/pkg/services/control/ir/types.pb.go b/pkg/services/control/ir/types.pb.go index 453d28e4cd..7ac65414df 100644 --- a/pkg/services/control/ir/types.pb.go +++ b/pkg/services/control/ir/types.pb.go @@ -31,7 +31,8 @@ const ( // IR application is started and serves all services. HealthStatus_READY HealthStatus = 2 // IR application is shutting down. - HealthStatus_SHUTTING_DOWN HealthStatus = 3 + HealthStatus_SHUTTING_DOWN HealthStatus = 3 + HealthStatus_INITIALIZING_NETWORK HealthStatus = 5 ) // Enum value maps for HealthStatus. @@ -41,12 +42,14 @@ var ( 1: "STARTING", 2: "READY", 3: "SHUTTING_DOWN", + 5: "INITIALIZING_NETWORK", } HealthStatus_value = map[string]int32{ "HEALTH_STATUS_UNDEFINED": 0, "STARTING": 1, "READY": 2, "SHUTTING_DOWN": 3, + "INITIALIZING_NETWORK": 5, } ) @@ -144,17 +147,18 @@ var file_pkg_services_control_ir_types_proto_rawDesc = []byte{ 0x22, 0x36, 0x0a, 0x09, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x17, 0x0a, 0x04, 0x73, 0x69, 0x67, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x73, - 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x2a, 0x57, 0x0a, 0x0c, 0x48, 0x65, 0x61, 0x6c, + 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x2a, 0x71, 0x0a, 0x0c, 0x48, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x1b, 0x0a, 0x17, 0x48, 0x45, 0x41, 0x4c, 0x54, 0x48, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x55, 0x4e, 0x44, 0x45, 0x46, 0x49, 0x4e, 0x45, 0x44, 0x10, 0x00, 0x12, 0x0c, 0x0a, 0x08, 0x53, 0x54, 0x41, 0x52, 0x54, 0x49, 0x4e, 0x47, 0x10, 0x01, 0x12, 0x09, 0x0a, 0x05, 0x52, 0x45, 0x41, 0x44, 0x59, 0x10, 0x02, 0x12, 0x11, 0x0a, 0x0d, 0x53, 0x48, 0x55, 0x54, 0x54, 0x49, 0x4e, 0x47, 0x5f, 0x44, 0x4f, 0x57, 0x4e, 0x10, - 0x03, 0x42, 0x39, 0x5a, 0x37, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, - 0x6e, 0x73, 0x70, 0x63, 0x63, 0x2d, 0x64, 0x65, 0x76, 0x2f, 0x6e, 0x65, 0x6f, 0x66, 0x73, 0x2d, - 0x6e, 0x6f, 0x64, 0x65, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, - 0x73, 0x2f, 0x69, 0x72, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x62, 0x06, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x33, + 0x03, 0x12, 0x18, 0x0a, 0x14, 0x49, 0x4e, 0x49, 0x54, 0x49, 0x41, 0x4c, 0x49, 0x5a, 0x49, 0x4e, + 0x47, 0x5f, 0x4e, 0x45, 0x54, 0x57, 0x4f, 0x52, 0x4b, 0x10, 0x05, 0x42, 0x39, 0x5a, 0x37, 0x67, + 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6e, 0x73, 0x70, 0x63, 0x63, 0x2d, + 0x64, 0x65, 0x76, 0x2f, 0x6e, 0x65, 0x6f, 0x66, 0x73, 0x2d, 0x6e, 0x6f, 0x64, 0x65, 0x2f, 0x70, + 0x6b, 0x67, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2f, 0x69, 0x72, 0x2f, 0x63, + 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/pkg/services/control/ir/types.proto b/pkg/services/control/ir/types.proto index 3a77918741..91983663ab 100644 --- a/pkg/services/control/ir/types.proto +++ b/pkg/services/control/ir/types.proto @@ -26,4 +26,7 @@ enum HealthStatus { // IR application is shutting down. SHUTTING_DOWN = 3; + + // Initializing Neo network + INITIALIZING_NETWORK = 4; } From 5f97a86e31be0dab10b3b5a0500b27c1aef38a0c Mon Sep 17 00:00:00 2001 From: Andrey Butusov Date: Wed, 11 Sep 2024 20:34:32 +0300 Subject: [PATCH 3/3] metrics/ir: add `neofs_ir_state_health` metric Expose health status of ir via Prometheus. Signed-off-by: Andrey Butusov --- CHANGELOG.md | 2 ++ pkg/innerring/state.go | 3 +++ pkg/metrics/innerring.go | 18 ++++++++++++++++-- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 16f95c8924..82244af573 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ Changelog for NeoFS Node ### Added - More effective FSTree writer for HDDs, new configuration options for it (#2814) +- New health status `INITIALIZING_NETWORK` in inner ring (#2934) +- Expose health status of inner ring via Prometheus (#2934) ### Fixed diff --git a/pkg/innerring/state.go b/pkg/innerring/state.go index 68be14d00a..c65ece2c12 100644 --- a/pkg/innerring/state.go +++ b/pkg/innerring/state.go @@ -201,6 +201,9 @@ func (s *Server) ResetEpochTimer(h uint32) error { func (s *Server) setHealthStatus(hs control.HealthStatus) { s.healthStatus.Store(hs) + if s.metrics != nil { + s.metrics.SetHealthCheck(int32(hs)) + } } // HealthStatus returns the current health status of the IR application. diff --git a/pkg/metrics/innerring.go b/pkg/metrics/innerring.go index 9492c29170..9e7204531a 100644 --- a/pkg/metrics/innerring.go +++ b/pkg/metrics/innerring.go @@ -8,7 +8,8 @@ const innerRingNameSpace = "neofs_ir" // InnerRingServiceMetrics contains metrics collected by inner ring. type InnerRingServiceMetrics struct { - epoch prometheus.Gauge + epoch prometheus.Gauge + healthCheck prometheus.Gauge } // NewInnerRingMetrics returns new instance of metrics collectors for inner ring. @@ -23,8 +24,17 @@ func NewInnerRingMetrics(version string) InnerRingServiceMetrics { }) prometheus.MustRegister(epoch) + healthCheck := prometheus.NewGauge(prometheus.GaugeOpts{ + Namespace: innerRingNameSpace, + Subsystem: stateSubsystem, + Name: "health", + Help: "Current ir state", + }) + prometheus.MustRegister(healthCheck) + return InnerRingServiceMetrics{ - epoch: epoch, + epoch: epoch, + healthCheck: healthCheck, } } @@ -32,3 +42,7 @@ func NewInnerRingMetrics(version string) InnerRingServiceMetrics { func (m InnerRingServiceMetrics) SetEpoch(epoch uint64) { m.epoch.Set(float64(epoch)) } + +func (m InnerRingServiceMetrics) SetHealthCheck(healthCheck int32) { + m.healthCheck.Set(float64(healthCheck)) +}