Skip to content

Commit

Permalink
go/control: Show the debug option statuses in the control output
Browse files Browse the repository at this point in the history
  • Loading branch information
Yawning committed Apr 4, 2022
1 parent 417f861 commit b302a16
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
Empty file added .changelog/4634.feature.md
Empty file.
15 changes: 15 additions & 0 deletions go/control/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ type Status struct {
// SoftwareVersion is the oasis-node software version.
SoftwareVersion string `json:"software_version"`

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

// Identity is the identity of the node.
Identity IdentityStatus `json:"identity"`

Expand All @@ -74,6 +77,18 @@ type Status struct {
PendingUpgrades []*upgrade.PendingUpgrade `json:"pending_upgrades"`
}

// DebugStatus is the current node debug status, listing the various node
// debug options if enabled.
type DebugStatus struct {
// Enabled is true iff the node is running with DebugDontBlameOasis
// set.
Enabled bool `json:"enabled"`

// AllowRoot is true iff the node is running with DebugAllowRoot
// set.
AllowRoot bool `json:"allow_root"`
}

// IdentityStatus is the current node identity status, listing all the public keys that identify
// this node in different contexts.
type IdentityStatus struct {
Expand Down
10 changes: 10 additions & 0 deletions go/control/control.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/oasisprotocol/oasis-core/go/common/version"
consensus "github.com/oasisprotocol/oasis-core/go/consensus/api"
control "github.com/oasisprotocol/oasis-core/go/control/api"
cmdFlags "github.com/oasisprotocol/oasis-core/go/oasis-node/cmd/common/flags"
upgrade "github.com/oasisprotocol/oasis-core/go/upgrade/api"
)

Expand Down Expand Up @@ -104,8 +105,17 @@ func (c *nodeController) GetStatus(ctx context.Context) (*control.Status, error)

ident := c.node.GetIdentity()

var ds *control.DebugStatus
if debugEnabled := cmdFlags.DebugDontBlameOasis(); debugEnabled {
ds = &control.DebugStatus{
Enabled: debugEnabled,
AllowRoot: cmdFlags.DebugAllowRoot(),
}
}

return &control.Status{
SoftwareVersion: version.SoftwareVersion,
Debug: ds,
Identity: control.IdentityStatus{
Node: ident.NodeSigner.Public(),
P2P: ident.P2PSigner.Public(),
Expand Down

0 comments on commit b302a16

Please sign in to comment.