Skip to content

Commit

Permalink
IR additional health status (#2934)
Browse files Browse the repository at this point in the history
  • Loading branch information
roman-khimov committed Sep 17, 2024
2 parents 0a6e88a + 5f97a86 commit 4f22042
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 10 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion pkg/innerring/innerring.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions pkg/innerring/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
18 changes: 16 additions & 2 deletions pkg/metrics/innerring.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -23,12 +24,25 @@ 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,
}
}

// SetEpoch updates epoch metrics.
func (m InnerRingServiceMetrics) SetEpoch(epoch uint64) {
m.epoch.Set(float64(epoch))
}

func (m InnerRingServiceMetrics) SetHealthCheck(healthCheck int32) {
m.healthCheck.Set(float64(healthCheck))
}
18 changes: 11 additions & 7 deletions pkg/services/control/ir/types.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions pkg/services/control/ir/types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,7 @@ enum HealthStatus {

// IR application is shutting down.
SHUTTING_DOWN = 3;

// Initializing Neo network
INITIALIZING_NETWORK = 4;
}

0 comments on commit 4f22042

Please sign in to comment.