keep-network / prometheus-sd

Prometheus Custom Service Discovery for Keep Network Nodes

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Handle multiple network ports

nkuba opened this issue · comments

When the discovery is getting a network port for a peer it assumes the network port is the same in all multi addresses. Which is a correct assumption:

prometheus-sd/main.go

Lines 219 to 222 in ba82128

// A peer can operate on only one network port, so we're not
// collecting all the ports extracted from the multi addresses
// but just one, as all the extracted ports should match.
peersNetworkPorts[peer.ChainAddress] = peerNetworkPort

But it turned out that the data returned on testnet were not following this assumption in one case💥 :

{
    "chain_address": "0x3FF855895EF4aC833c32Ab6A0d6C7fBfA137E26E",
    "multiaddrs":
    [
        "/ip4/127.0.0.1/tcp/3919",
        "/ip4/104.154.211.185/tcp/3307",
        "/ip4/10.102.1.79/tcp/3919"
    ],
    "network_id": "16Uiu2HAm8KJX32kr3eYUhDuzwTucSfAfspnjnXNf9veVhB12t6Vf"
}

The discovery should be more flexible and let the network port be a set of ports just like we do with the addresses and check one port after another when trying to dial the peer.