Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cluster-service: add version subcommand and change some startup logging #274

Merged
merged 1 commit into from
Dec 13, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func NewCluster(
return nil, err
}

logger.Infof("IPFS Cluster v%s listening on:", Version)
logger.Infof("IPFS Cluster v%s-%s listening on:", Version, Commit[0:8])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As TestClusterStateSync doesn't hit the cluster service version command this slice dereference seems to be the cause of the slice out of bounds error that Travis catches for these changes.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

for _, addr := range host.Addrs() {
logger.Infof(" %s/ipfs/%s", addr, host.ID().Pretty())
}
Expand Down Expand Up @@ -450,7 +450,7 @@ func (c *Cluster) ready() {
}
close(c.readyCh)
c.readyB = true
logger.Info("IPFS Cluster is ready")
logger.Info("** IPFS Cluster is READY **")
}

func (c *Cluster) bootstrap() bool {
Expand Down
4 changes: 2 additions & 2 deletions consensus/raft/consensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func NewConsensus(clusterPeers []peer.ID, host host.Host, cfg *Config, state sta

baseOp := &LogOp{}

logger.Infof("starting Consensus and waiting for a leader...")
logger.Debug("starting Consensus and waiting for a leader...")
consensus := libp2praft.NewOpLog(state, baseOp)
raft, err := newRaftWrapper(clusterPeers, host, cfg, consensus.FSM())
if err != nil {
Expand Down Expand Up @@ -113,7 +113,7 @@ func (cc *Consensus) finishBootstrap() {
if err != nil {
return
}
logger.Info("Consensus state is up to date")
logger.Debug("Raft state is now up to date")

// While rpc is not ready we cannot perform a sync
if cc.rpcClient == nil {
Expand Down
8 changes: 4 additions & 4 deletions consensus/raft/raft.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,15 @@ func newRaftWrapper(peers []peer.ID, host host.Host, cfg *Config, fsm hraft.FSM)
return nil, err
}
if !hasState {
logger.Info("bootstrapping raft cluster")
logger.Info("initializing raft cluster")
err := hraft.BootstrapCluster(cfg.RaftConfig,
log, stable, snap, transport, srvCfg)
if err != nil {
logger.Error("bootstrapping cluster: ", err)
return nil, err
}
} else {
logger.Info("raft cluster is already bootstrapped")
logger.Debug("raft cluster is already initialized")
}

logger.Debug("creating Raft")
Expand Down Expand Up @@ -261,7 +261,7 @@ func (rw *raftWrapper) WaitForLeader(ctx context.Context) (string, error) {
case <-ticker.C:
if l := rw.raft.Leader(); l != "" {
logger.Debug("waitForleaderTimer")
logger.Infof("Raft Leader elected: %s", l)
logger.Infof("Current Raft Leader: %s", l)
ticker.Stop()
return string(l), nil
}
Expand All @@ -273,7 +273,7 @@ func (rw *raftWrapper) WaitForLeader(ctx context.Context) (string, error) {

// WaitForUpdates holds until Raft has synced to the last index in the log
func (rw *raftWrapper) WaitForUpdates(ctx context.Context) error {
logger.Info("Raft state is catching up")
logger.Debug("Raft state is catching up to the latest known version. Please wait...")
for {
select {
case <-ctx.Done():
Expand Down
12 changes: 11 additions & 1 deletion ipfs-cluster-service/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ using LibP2P. This is a simplified view of the components:
| ipfs-cluster-ctl |
+---------+--------+
|
| HTTP
| HTTP(s)
ipfs-cluster-service | HTTP
+----------+--------+--v--+----------------------+ +-------------+
| RPC/Raft | Peer 1 | API | IPFS Connector/Proxy +------> IPFS daemon |
Expand Down Expand Up @@ -266,6 +266,14 @@ removal, upgrade state using this command, and restart every peer.
},
},
},
{
Name: "version",
Usage: "Print the ipfs-cluster version",
Action: func(c *cli.Context) error {
fmt.Printf("%s-%s\n", ipfscluster.Version, ipfscluster.Commit[0:8])
return nil
},
},
}

app.Before = func(c *cli.Context) error {
Expand Down Expand Up @@ -300,6 +308,8 @@ func run(c *cli.Context) error {
}

func daemon(c *cli.Context) error {
logger.Info("Initializing. For verbose output run with \"-l debug\". Please wait...")

// Load all the configurations
cfg, clusterCfg, apiCfg, ipfshttpCfg, consensusCfg, trackerCfg, monCfg, diskInfCfg, numpinInfCfg := makeConfigs()
// Execution lock
Expand Down
4 changes: 2 additions & 2 deletions version.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ package ipfscluster
// components, apis and tools ensures compatibility among them.
const Version = "0.3.1"

// Commit is the current build commit of cluster. See Makefile
var Commit string
// Commit is the current build commit of cluster. See Makefile.
var Commit = "00000000" // actual commit set during builds.