Skip to content

Commit

Permalink
microcloud/cmd/microcloud: Clearer join process comments
Browse files Browse the repository at this point in the history
Signed-off-by: Max Asnaashari <[email protected]>
  • Loading branch information
masnax committed Apr 10, 2024
1 parent 85557f5 commit a33fbc4
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions microcloud/cmd/microcloud/main_init.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,18 +339,23 @@ func waitForJoin(sh *service.Handler, clusterSize map[types.ServiceType]int, sec
clustered[tokenInfo.Service] = false
}

// Iterate over all services until the database is updated with the new node across all of them.
now := time.Now()
for len(clustered) != 0 {
if time.Since(now) >= time.Second*30 {
return fmt.Errorf("Timed out waiting for cluster member %q to appear", peer)
}

// Check the size of the cluster for each service.
for service := range clustered {
systems, err := sh.Services[service].ClusterMembers(context.Background(), nil)
if err != nil {
return err
}

// If the size of the cluster has been incremented by 1 from its initial value,
// then we don't need to check the corresponding service anymore.
// So remove the service from consideration and update the current cluster size for the next node.
if len(systems) == clusterSize[service]+1 {
delete(clustered, service)
clusterSize[service] = clusterSize[service] + 1
Expand Down

0 comments on commit a33fbc4

Please sign in to comment.