Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IR additional health status #2934

Merged
merged 3 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
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 @@

setNetworkSettingsDefaults(&deployPrm.NetmapContract.Config)

server.setHealthStatus(control.HealthStatus_INITIALIZING_NETWORK)

Check warning on line 553 in pkg/innerring/innerring.go

View check run for this annotation

Codecov / codecov/patch

pkg/innerring/innerring.go#L553

Added line #L553 was not covered by tests
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) setHealthStatus(hs control.HealthStatus) {
s.healthStatus.Store(hs)
if s.metrics != nil {
s.metrics.SetHealthCheck(int32(hs))

Check warning on line 205 in pkg/innerring/state.go

View check run for this annotation

Codecov / codecov/patch

pkg/innerring/state.go#L204-L205

Added lines #L204 - L205 were not covered by tests
}
}

// 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 @@

// 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 @@
})
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))

Check warning on line 47 in pkg/metrics/innerring.go

View check run for this annotation

Codecov / codecov/patch

pkg/metrics/innerring.go#L46-L47

Added lines #L46 - L47 were not covered by tests
}
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;
}
Loading