ipfs-cluster/rpc_policy.go
Hector Sanjuan 809b7fbda5 Pintracker: add IPFS ID to Pin Information
Fixes #1554
Fixes: peer names unset for remote peers

This adds an IPFS field to pin status information (PinInfoShort).

It has not been easy to add this, given that the IPFS ID is something that
comes from outside of cluster (unlike the peer name). After several tries I
have settled in the following things:

- Use the ping metric to send out peer names and IPFS IDs to the peers in the
  cluster.
- Cache the latest known IPFS ID (if IPFS dies we should still be setting
  the ID).
- Provide an RPC method for the Pintracker to obtain IPFS ID from the cache.
- Given we now know information for peernames and IPFS IDs from other peers,
  we can use that information even if the requests to them error or we are not
  contacting (i.e. peers allocated as remote are not queried for status). We can
  use the information from the last received ping metric.
- This means we should keep metrics around even if peers go away, at least for
  a while rather than deleting them as soon as we detect that they have expired.

Puting it all together we now have a system to gossip peer information around on top
of the ping metrics.
2022-01-31 17:53:09 +01:00

70 lines
2.9 KiB
Go

package ipfscluster
// This file can be generated with rpcutil/policygen.
// DefaultRPCPolicy associates all rpc endpoints offered by cluster peers to an
// endpoint type. See rpcutil/policygen.go as a quick way to generate this
// without missing any endpoint.
var DefaultRPCPolicy = map[string]RPCEndpointType{
// Cluster methods
"Cluster.Alerts": RPCClosed,
"Cluster.BlockAllocate": RPCClosed,
"Cluster.ConnectGraph": RPCClosed,
"Cluster.ID": RPCOpen,
"Cluster.IPFSID": RPCClosed,
"Cluster.Join": RPCClosed,
"Cluster.PeerAdd": RPCOpen, // Used by Join()
"Cluster.PeerRemove": RPCTrusted,
"Cluster.Peers": RPCTrusted, // Used by ConnectGraph()
"Cluster.Pin": RPCClosed,
"Cluster.PinGet": RPCClosed,
"Cluster.PinPath": RPCClosed,
"Cluster.Pins": RPCClosed, // Used in stateless tracker, ipfsproxy, restapi
"Cluster.Recover": RPCClosed,
"Cluster.RecoverAll": RPCClosed,
"Cluster.RecoverAllLocal": RPCTrusted,
"Cluster.RecoverLocal": RPCTrusted,
"Cluster.RepoGC": RPCClosed,
"Cluster.RepoGCLocal": RPCTrusted,
"Cluster.SendInformerMetrics": RPCClosed,
"Cluster.SendInformersMetrics": RPCClosed,
"Cluster.Status": RPCClosed,
"Cluster.StatusAll": RPCClosed,
"Cluster.StatusAllLocal": RPCClosed,
"Cluster.StatusLocal": RPCClosed,
"Cluster.Unpin": RPCClosed,
"Cluster.UnpinPath": RPCClosed,
"Cluster.Version": RPCOpen,
// PinTracker methods
"PinTracker.Recover": RPCTrusted, // Called in broadcast from Recover()
"PinTracker.RecoverAll": RPCClosed, // Broadcast in RecoverAll unimplemented
"PinTracker.Status": RPCTrusted,
"PinTracker.StatusAll": RPCTrusted,
"PinTracker.Track": RPCClosed,
"PinTracker.Untrack": RPCClosed,
// IPFSConnector methods
"IPFSConnector.BlockGet": RPCClosed,
"IPFSConnector.BlockPut": RPCTrusted, // Called from Add()
"IPFSConnector.ConfigKey": RPCClosed,
"IPFSConnector.Pin": RPCClosed,
"IPFSConnector.PinLs": RPCClosed,
"IPFSConnector.PinLsCid": RPCClosed,
"IPFSConnector.RepoStat": RPCTrusted, // Called in broadcast from proxy/repo/stat
"IPFSConnector.Resolve": RPCClosed,
"IPFSConnector.SwarmPeers": RPCTrusted, // Called in ConnectGraph
"IPFSConnector.Unpin": RPCClosed,
// Consensus methods
"Consensus.AddPeer": RPCTrusted, // Called by Raft/redirect to leader
"Consensus.LogPin": RPCTrusted, // Called by Raft/redirect to leader
"Consensus.LogUnpin": RPCTrusted, // Called by Raft/redirect to leader
"Consensus.Peers": RPCClosed,
"Consensus.RmPeer": RPCTrusted, // Called by Raft/redirect to leader
// PeerMonitor methods
"PeerMonitor.LatestMetrics": RPCClosed,
"PeerMonitor.MetricNames": RPCClosed,
}