Skip to content

Commit

Permalink
Include the mode of the node in control status output
Browse files Browse the repository at this point in the history
  • Loading branch information
ptrus committed Jan 23, 2024
1 parent 77ff3ad commit 6012717
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions .changelog/5537.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Include the mode of the node in control status output
4 changes: 4 additions & 0 deletions go/control/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/oasisprotocol/oasis-core/go/common/crypto/signature"
"github.com/oasisprotocol/oasis-core/go/common/errors"
"github.com/oasisprotocol/oasis-core/go/common/node"
"github.com/oasisprotocol/oasis-core/go/config"
consensus "github.com/oasisprotocol/oasis-core/go/consensus/api"
p2p "github.com/oasisprotocol/oasis-core/go/p2p/api"
registry "github.com/oasisprotocol/oasis-core/go/registry/api"
Expand Down Expand Up @@ -66,6 +67,9 @@ type Status struct {
// SoftwareVersion is the oasis-node software version.
SoftwareVersion string `json:"software_version"`

// Mode is the node mode.
Mode config.NodeMode `json:"mode"`

// Debug is the oasis-node debug status.
Debug *DebugStatus `json:"debug,omitempty"`

Expand Down
1 change: 1 addition & 0 deletions go/oasis-node/cmd/node/node_control.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ func (n *Node) GetStatus(ctx context.Context) (*control.Status, error) {

return &control.Status{
SoftwareVersion: version.SoftwareVersion,
Mode: config.GlobalConfig.Mode,
Debug: ds,
Identity: ident,
Consensus: cs,
Expand Down
2 changes: 2 additions & 0 deletions go/oasis-node/cmd/node/seed_control.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"

"github.com/oasisprotocol/oasis-core/go/common/version"
"github.com/oasisprotocol/oasis-core/go/config"
control "github.com/oasisprotocol/oasis-core/go/control/api"
upgrade "github.com/oasisprotocol/oasis-core/go/upgrade/api"
)
Expand Down Expand Up @@ -75,6 +76,7 @@ func (n *SeedNode) GetStatus(_ context.Context) (*control.Status, error) {

return &control.Status{
SoftwareVersion: version.SoftwareVersion,
Mode: config.GlobalConfig.Mode,
Identity: identity,
Seed: &seedStatus,
}, nil
Expand Down
4 changes: 4 additions & 0 deletions go/oasis-test-runner/scenario/e2e/runtime/archive_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

beacon "github.com/oasisprotocol/oasis-core/go/beacon/api"
"github.com/oasisprotocol/oasis-core/go/common/pubsub"
"github.com/oasisprotocol/oasis-core/go/config"
consensusAPI "github.com/oasisprotocol/oasis-core/go/consensus/api"
"github.com/oasisprotocol/oasis-core/go/consensus/api/transaction"
"github.com/oasisprotocol/oasis-core/go/oasis-test-runner/env"
Expand Down Expand Up @@ -86,6 +87,9 @@ func (sc *archiveAPI) testArchiveAPI(ctx context.Context, archiveCtrl *oasis.Con
if err != nil {
return fmt.Errorf("failed to get status for node: %w", err)
}
if status.Mode != config.ModeArchive {
return fmt.Errorf("archive node should report its mode, got: %v", status.Mode)
}
if !status.Consensus.Features.Has(consensusAPI.FeatureArchiveNode) {
return fmt.Errorf("archive node lacks archive feature, got: '%s'", status.Consensus.Features.String())
}
Expand Down
4 changes: 4 additions & 0 deletions go/oasis-test-runner/scenario/e2e/seed_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"reflect"

"github.com/oasisprotocol/oasis-core/go/config"
control "github.com/oasisprotocol/oasis-core/go/control/api"
"github.com/oasisprotocol/oasis-core/go/oasis-test-runner/env"
"github.com/oasisprotocol/oasis-core/go/oasis-test-runner/oasis"
Expand Down Expand Up @@ -118,6 +119,9 @@ func (sc *seedAPI) Run(ctx context.Context, _ *env.Env) error { // nolint: gocyc
if status.SoftwareVersion == "" {
return fmt.Errorf("seed node should report software version")
}
if status.Mode != config.ModeSeed {
return fmt.Errorf("seed node should report its mode, got: %v", status.Mode)
}
if reflect.DeepEqual(status.Identity, control.IdentityStatus{}) {
return fmt.Errorf("seed node should report its identity")
}
Expand Down

0 comments on commit 6012717

Please sign in to comment.