Skip to content

Commit ca500a0

Browse files
committed
dev: append extra notifications upon ZP path verification
1 parent 24f644f commit ca500a0

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

pkg/controller/chi/worker-reconciler-chi.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ func (w *worker) reconcileCluster(ctx context.Context, cluster *api.Cluster) err
537537
if err := w.reconcileClusterPodDisruptionBudget(ctx, cluster); err != nil {
538538
return err
539539
}
540-
if err := reconcileClusterZookeeperRootPath(cluster); err != nil {
540+
if err := w.reconcileClusterZookeeperRootPath(cluster); err != nil {
541541
return err
542542
}
543543
if err := w.reconcileClusterShardsAndHosts(ctx, cluster); err != nil {

pkg/controller/chi/worker-zk-integration.go

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,41 @@ package chi
1616

1717
import (
1818
api "github.com/altinity/clickhouse-operator/pkg/apis/clickhouse.altinity.com/v1"
19+
a "github.com/altinity/clickhouse-operator/pkg/controller/common/announcer"
1920
"github.com/altinity/clickhouse-operator/pkg/model/zookeeper"
2021
)
2122

22-
func reconcileClusterZookeeperRootPath(cluster *api.Cluster) error {
23+
func (w *worker) reconcileClusterZookeeperRootPath(cluster *api.Cluster) error {
24+
// Cluster ZK path reconciliation is optional
2325
if !shouldReconcileClusterZookeeperPath(cluster) {
2426
// Nothing to reconcile
2527
return nil
2628
}
29+
30+
// Yes, we are expected to reconcile ZK path
31+
32+
w.a.V(1).
33+
WithEvent(cluster.GetCR(), a.EventActionCreate, a.EventReasonCreateStarted).
34+
WithAction(cluster.GetCR()).
35+
M(cluster.GetCR()).F().
36+
Info("Verify ZK path for cluster %s/%s/%s", cluster.GetCR().GetNamespace(), cluster.GetCR().GetName(), cluster.GetName())
37+
38+
ensureZkPath(cluster)
39+
40+
w.a.V(1).
41+
WithEvent(cluster.GetCR(), a.EventActionCreate, a.EventReasonCreateCompleted).
42+
WithAction(cluster.GetCR()).
43+
M(cluster.GetCR()).F().
44+
Info("ZK path verified for cluster %s/%s/%s", cluster.GetCR().GetNamespace(), cluster.GetCR().GetName(), cluster.GetName())
45+
46+
return nil
47+
}
48+
49+
func ensureZkPath(cluster *api.Cluster) {
2750
conn := zookeeper.NewConnection(cluster.Zookeeper.Nodes)
2851
path := zookeeper.NewPathManager(conn)
2952
path.Ensure(cluster.Zookeeper.Root)
3053
path.Close()
31-
return nil
3254
}
3355

3456
func shouldReconcileClusterZookeeperPath(cluster *api.Cluster) bool {

0 commit comments

Comments
 (0)