cluster: safeguard consensus not set when calling ID
SwarmConnect on the ipfs connector calls rpc Peers() which requests IDs for every peer member. If that peer member is booting, it might get the request after RPC is setup but before consensus is initialized. In which case a panic happens. Probability that this happens is small, but still. Also increase the connect swarms delay to 30 seconds, which should be a bit longer than the default wait_for_leader timeout, otherwise we might connect swarms while there's not even a leader. License: MIT Signed-off-by: Hector Sanjuan <hector@protocol.ai>
This commit is contained in:
parent
a1f1ef15d8
commit
a656e45375
|
@ -586,7 +586,12 @@ func (c *Cluster) ID() api.ID {
|
|||
addrs = append(addrs, multiaddrJoin(addr, c.id))
|
||||
}
|
||||
|
||||
peers, _ := c.consensus.Peers()
|
||||
peers := []peer.ID{}
|
||||
// This method might get called very early by a remote peer
|
||||
// and might catch us when consensus is not set
|
||||
if c.consensus != nil {
|
||||
peers, _ = c.consensus.Peers()
|
||||
}
|
||||
|
||||
return api.ID{
|
||||
ID: c.id,
|
||||
|
|
|
@ -17,7 +17,7 @@ const configKey = "ipfshttp"
|
|||
const (
|
||||
DefaultProxyAddr = "/ip4/127.0.0.1/tcp/9095"
|
||||
DefaultNodeAddr = "/ip4/127.0.0.1/tcp/5001"
|
||||
DefaultConnectSwarmsDelay = 7 * time.Second
|
||||
DefaultConnectSwarmsDelay = 30 * time.Second
|
||||
DefaultProxyReadTimeout = 10 * time.Minute
|
||||
DefaultProxyReadHeaderTimeout = 5 * time.Second
|
||||
DefaultProxyWriteTimeout = 10 * time.Minute
|
||||
|
|
Loading…
Reference in New Issue
Block a user