Skip to content

bug report(tm-monitor): health need to update when add node or delete node #2693

@WALL-E

Description

@WALL-E

use tools/tm-monitor to monitor a full node, open url http://127.0.0.1:26670/status/network, I find the health is always equal to FullHealth, but I find it is wrong, because the monitored node is not a validator node, the health Should be equal to ModerateHealth.

func (n *Network) updateHealth() {
	// if we are connected to all validators, we're at full health
	// TODO: make sure they're all at the same height (within a block)
	// and all proposing (and possibly validating ) Alternatively, just
	// check there hasn't been a new round in numValidators rounds
	if n.NumValidators != 0 && n.NumNodesMonitoredOnline == n.NumValidators {
		n.Health = FullHealth
	} else if n.NumNodesMonitoredOnline > 0 && n.NumNodesMonitoredOnline <= n.NumNodesMonitored {
		n.Health = ModerateHealth
	} else {
		n.Health = Dead
	}
}

The following two functions modify NumNodesMonitoredOnline, function updateHealth() should be called, am I right?

// NewNode is called when the new node is added to the monitor.
func (n *Network) NewNode(name string) {
	n.NumNodesMonitored++
	n.NumNodesMonitoredOnline++
}

// NodeDeleted is called when the node is deleted from under the monitor.
func (n *Network) NodeDeleted(name string) {
	n.NumNodesMonitored--
	n.NumNodesMonitoredOnline--
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions