Skip to content

Commit

Permalink
dev: wait for all nodes in cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
sunsingerus committed Nov 28, 2024
1 parent 7ae82ad commit f97edd2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
11 changes: 11 additions & 0 deletions pkg/apis/clickhouse.altinity.com/v1/type_host.go
Original file line number Diff line number Diff line change
Expand Up @@ -603,3 +603,14 @@ func (host *Host) IsZero() bool {
func (host *Host) IsNonZero() bool {
return host != nil
}

func (host *Host) ShouldIncludeIntoCluster() bool {
switch {
case host.IsStopped():
return false
case host.GetCluster().HostsCount() < 2:
return false
default:
return true
}
}
9 changes: 9 additions & 0 deletions pkg/controller/chi/worker-chi-reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,15 @@ func (w *worker) reconcileCRAuxObjectsFinal(ctx context.Context, cr *api.ClickHo
cr.GetRuntime().LockCommonConfig()
err = w.reconcileConfigMapCommon(ctx, cr)
cr.GetRuntime().UnlockCommonConfig()

// Wait for all hosts to be included into cluster
cr.WalkHosts(func(host *api.Host) error {
if host.ShouldIncludeIntoCluster() {
_ = w.waitHostInCluster(ctx, host)
}
return nil
})

return err
}

Expand Down

0 comments on commit f97edd2

Please sign in to comment.