@@ -16,19 +16,41 @@ package chi
1616
1717import (
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
3456func shouldReconcileClusterZookeeperPath (cluster * api.Cluster ) bool {
0 commit comments