Allow running peers with different cluster versions in the same cluster
This patch modifies the RPC protocol tag to use Major and Minor parts of the version and not all of it. This means all peers on the 0.5.x can run in the same cluster. As cluster has become more mature and I see less risks in letting peers from similar versions run together. This is useful when upgrading too. License: MIT Signed-off-by: Hector Sanjuan <code@hector.link>
This commit is contained in:
parent
638128d6a0
commit
59714f69d4
11
cluster.go
11
cluster.go
|
@ -99,11 +99,7 @@ func NewCluster(
|
||||||
listenAddrs += fmt.Sprintf(" %s/ipfs/%s\n", addr, host.ID().Pretty())
|
listenAddrs += fmt.Sprintf(" %s/ipfs/%s\n", addr, host.ID().Pretty())
|
||||||
}
|
}
|
||||||
|
|
||||||
if c := Commit; len(c) >= 8 {
|
logger.Infof("IPFS Cluster v%s listening on:\n%s\n", Version, listenAddrs)
|
||||||
logger.Infof("IPFS Cluster v%s-%s listening on:\n%s\n", Version, Commit[0:8], listenAddrs)
|
|
||||||
} else {
|
|
||||||
logger.Infof("IPFS Cluster v%s listening on:\n%s\n", Version, listenAddrs)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Note, we already loaded peers from peerstore into the host
|
// Note, we already loaded peers from peerstore into the host
|
||||||
// in daemon.go.
|
// in daemon.go.
|
||||||
|
@ -529,8 +525,7 @@ func (c *Cluster) ID() api.ID {
|
||||||
Addresses: addrs,
|
Addresses: addrs,
|
||||||
ClusterPeers: peers,
|
ClusterPeers: peers,
|
||||||
ClusterPeersAddresses: c.peerManager.PeersAddresses(peers),
|
ClusterPeersAddresses: c.peerManager.PeersAddresses(peers),
|
||||||
Version: Version,
|
Version: Version.String(),
|
||||||
Commit: Commit,
|
|
||||||
RPCProtocolVersion: RPCProtocol,
|
RPCProtocolVersion: RPCProtocol,
|
||||||
IPFS: ipfsID,
|
IPFS: ipfsID,
|
||||||
Peername: c.config.Peername,
|
Peername: c.config.Peername,
|
||||||
|
@ -1082,7 +1077,7 @@ func (c *Cluster) AddFile(reader *multipart.Reader, params *api.AddParams) (cid.
|
||||||
|
|
||||||
// Version returns the current IPFS Cluster version.
|
// Version returns the current IPFS Cluster version.
|
||||||
func (c *Cluster) Version() string {
|
func (c *Cluster) Version() string {
|
||||||
return Version
|
return Version.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Peers returns the IDs of the members of this Cluster.
|
// Peers returns the IDs of the members of this Cluster.
|
||||||
|
|
|
@ -225,7 +225,7 @@ func TestClusterID(t *testing.T) {
|
||||||
if id.ID == "" {
|
if id.ID == "" {
|
||||||
t.Error("expected a cluster ID")
|
t.Error("expected a cluster ID")
|
||||||
}
|
}
|
||||||
if id.Version != Version {
|
if id.Version != Version.String() {
|
||||||
t.Error("version should match current version")
|
t.Error("version should match current version")
|
||||||
}
|
}
|
||||||
//if id.PublicKey == nil {
|
//if id.PublicKey == nil {
|
||||||
|
@ -771,7 +771,7 @@ func TestVersion(t *testing.T) {
|
||||||
cl, _, _, _, _ := testingCluster(t)
|
cl, _, _, _, _ := testingCluster(t)
|
||||||
defer cleanRaft()
|
defer cleanRaft()
|
||||||
defer cl.Shutdown()
|
defer cl.Shutdown()
|
||||||
if cl.Version() != Version {
|
if cl.Version() != Version.String() {
|
||||||
t.Error("bad Version()")
|
t.Error("bad Version()")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,11 +11,12 @@ import (
|
||||||
|
|
||||||
// _ "net/http/pprof"
|
// _ "net/http/pprof"
|
||||||
|
|
||||||
logging "github.com/ipfs/go-log"
|
|
||||||
cli "github.com/urfave/cli"
|
|
||||||
|
|
||||||
ipfscluster "github.com/ipfs/ipfs-cluster"
|
ipfscluster "github.com/ipfs/ipfs-cluster"
|
||||||
"github.com/ipfs/ipfs-cluster/state/mapstate"
|
"github.com/ipfs/ipfs-cluster/state/mapstate"
|
||||||
|
|
||||||
|
semver "github.com/blang/semver"
|
||||||
|
logging "github.com/ipfs/go-log"
|
||||||
|
cli "github.com/urfave/cli"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ProgramName of this application
|
// ProgramName of this application
|
||||||
|
@ -109,8 +110,10 @@ var (
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
// Set the right commit. The only way I could make this work
|
// Set build information.
|
||||||
ipfscluster.Commit = commit
|
if build, err := semver.NewBuildVersion(commit); err == nil {
|
||||||
|
ipfscluster.Version.Build = []string{"git" + build}
|
||||||
|
}
|
||||||
|
|
||||||
// We try guessing user's home from the HOME variable. This
|
// We try guessing user's home from the HOME variable. This
|
||||||
// allows HOME hacks for things like Snapcraft builds. HOME
|
// allows HOME hacks for things like Snapcraft builds. HOME
|
||||||
|
@ -156,7 +159,7 @@ func main() {
|
||||||
app.Usage = "IPFS Cluster node"
|
app.Usage = "IPFS Cluster node"
|
||||||
app.Description = Description
|
app.Description = Description
|
||||||
//app.Copyright = "© Protocol Labs, Inc."
|
//app.Copyright = "© Protocol Labs, Inc."
|
||||||
app.Version = ipfscluster.Version
|
app.Version = ipfscluster.Version.String()
|
||||||
app.Flags = []cli.Flag{
|
app.Flags = []cli.Flag{
|
||||||
cli.StringFlag{
|
cli.StringFlag{
|
||||||
Name: "config, c",
|
Name: "config, c",
|
||||||
|
@ -405,11 +408,6 @@ the mth data folder (m currently defaults to 5)
|
||||||
Name: "version",
|
Name: "version",
|
||||||
Usage: "Print the ipfs-cluster version",
|
Usage: "Print the ipfs-cluster version",
|
||||||
Action: func(c *cli.Context) error {
|
Action: func(c *cli.Context) error {
|
||||||
if c := ipfscluster.Commit; len(c) >= 8 {
|
|
||||||
fmt.Printf("%s-%s\n", ipfscluster.Version, c)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
fmt.Printf("%s\n", ipfscluster.Version)
|
fmt.Printf("%s\n", ipfscluster.Version)
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
|
|
|
@ -17,12 +17,8 @@ import (
|
||||||
rpc "github.com/hsanjuan/go-libp2p-gorpc"
|
rpc "github.com/hsanjuan/go-libp2p-gorpc"
|
||||||
cid "github.com/ipfs/go-cid"
|
cid "github.com/ipfs/go-cid"
|
||||||
peer "github.com/libp2p/go-libp2p-peer"
|
peer "github.com/libp2p/go-libp2p-peer"
|
||||||
protocol "github.com/libp2p/go-libp2p-protocol"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// RPCProtocol is used to send libp2p messages between cluster peers
|
|
||||||
var RPCProtocol = protocol.ID("/ipfscluster/" + Version + "/rpc")
|
|
||||||
|
|
||||||
// Component represents a piece of ipfscluster. Cluster components
|
// Component represents a piece of ipfscluster. Cluster components
|
||||||
// usually run their own goroutines (a http server for example). They
|
// usually run their own goroutines (a http server for example). They
|
||||||
// communicate with the main Cluster component and other components
|
// communicate with the main Cluster component and other components
|
||||||
|
|
|
@ -385,7 +385,7 @@ func TestClustersVersion(t *testing.T) {
|
||||||
defer shutdownClusters(t, clusters, mock)
|
defer shutdownClusters(t, clusters, mock)
|
||||||
f := func(t *testing.T, c *Cluster) {
|
f := func(t *testing.T, c *Cluster) {
|
||||||
v := c.Version()
|
v := c.Version()
|
||||||
if v != Version {
|
if v != Version.String() {
|
||||||
t.Error("Bad version")
|
t.Error("Bad version")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -147,6 +147,12 @@
|
||||||
"hash": "QmRkrpnhZqDxTxwGCsDbuZMr7uCFZHH6SGfrcjgEQwxF3t",
|
"hash": "QmRkrpnhZqDxTxwGCsDbuZMr7uCFZHH6SGfrcjgEQwxF3t",
|
||||||
"name": "go-mfs",
|
"name": "go-mfs",
|
||||||
"version": "0.1.1"
|
"version": "0.1.1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"author": "blang",
|
||||||
|
"hash": "QmYRGECuvQnRX73fcvPnGbYijBcGN2HbKZQ7jh26qmLiHG",
|
||||||
|
"name": "semver",
|
||||||
|
"version": "3.5.1"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"gxVersion": "0.11.0",
|
"gxVersion": "0.11.0",
|
||||||
|
|
|
@ -13,7 +13,7 @@ if [ -z $version ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
make gx-clean
|
make gx-clean
|
||||||
sed -i "s/const Version.*$/const Version = \"$version\"/" version.go
|
sed -i "s/Version = semver\.MustParse.*$/Version = semver.MustParse(\"$version\")/" version.go
|
||||||
sed -i "s/const Version.*$/const Version = \"$version\"/" ipfs-cluster-ctl/main.go
|
sed -i "s/const Version.*$/const Version = \"$version\"/" ipfs-cluster-ctl/main.go
|
||||||
git commit -S -a -m "Release $version"
|
git commit -S -a -m "Release $version"
|
||||||
lastver=`git tag -l | grep -E 'v[0-9]+\.[0-9]+\.[0-9]+$' | tail -n 1`
|
lastver=`git tag -l | grep -E 'v[0-9]+\.[0-9]+\.[0-9]+$' | tail -n 1`
|
||||||
|
|
15
version.go
15
version.go
|
@ -1,8 +1,17 @@
|
||||||
package ipfscluster
|
package ipfscluster
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
semver "github.com/blang/semver"
|
||||||
|
protocol "github.com/libp2p/go-libp2p-protocol"
|
||||||
|
)
|
||||||
|
|
||||||
// Version is the current cluster version. Version alignment between
|
// Version is the current cluster version. Version alignment between
|
||||||
// components, apis and tools ensures compatibility among them.
|
// components, apis and tools ensures compatibility among them.
|
||||||
const Version = "0.5.0"
|
var Version = semver.MustParse("0.5.0")
|
||||||
|
|
||||||
// Commit is the current build commit of cluster. See Makefile.
|
// RPCProtocol is used to send libp2p messages between cluster peers
|
||||||
var Commit = "00000000" // actual commit set during builds.
|
var RPCProtocol = protocol.ID(
|
||||||
|
fmt.Sprintf("/ipfscluster/%d.%d/rpc", Version.Major, Version.Minor),
|
||||||
|
)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user