Skip to content

Commit

Permalink
client: register before restoring
Browse files Browse the repository at this point in the history
Registration and restoring allocs don't share state or depend on each
other in any way (syncing allocs with servers is done outside of
registration).

Since restoring is synchronous, start the registration goroutine first.

For nodes with lots of allocs to restore or close to their heartbeat
deadline, this could be the difference between becoming "lost" or not.
  • Loading branch information
schmichael committed May 10, 2019
1 parent aced24f commit 9707a9d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,9 @@ func NewClient(cfg *config.Config, consulCatalog consul.CatalogAPI, consulServic
logger.Warn("batch fingerprint operation timed out; proceeding to register with fingerprinted plugins so far")
}

// Register and then start heartbeating to the servers.
c.shutdownGroup.Go(c.registerAndHeartbeat)

// Restore the state
if err := c.restoreState(); err != nil {
logger.Error("failed to restore state", "error", err)
Expand All @@ -456,9 +459,6 @@ func NewClient(cfg *config.Config, consulCatalog consul.CatalogAPI, consulServic
return nil, fmt.Errorf("failed to restore state")
}

// Register and then start heartbeating to the servers.
c.shutdownGroup.Go(c.registerAndHeartbeat)

// Begin periodic snapshotting of state.
c.shutdownGroup.Go(c.periodicSnapshot)

Expand Down

0 comments on commit 9707a9d

Please sign in to comment.