Skip to content
This repository has been archived by the owner on Feb 8, 2024. It is now read-only.

Commit

Permalink
kafka bug init phase resolution (#486)
Browse files Browse the repository at this point in the history
Signed-off-by: Rohit Dwivedi <rohit.k.dwivedi@seagate.com>
  • Loading branch information
rohit-k-dwivedi committed Aug 31, 2021
1 parent 6940718 commit 15e689e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 19 deletions.
15 changes: 6 additions & 9 deletions py-utils/src/utils/setup/kafka/kafka.post-install.conf.tmpl
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
{
"cortx": {
"sw": {
"kafka": {
"num_servers": "TMPL_NUM_SERVER"
}
}
}
}
cortx:
software:
kafka:
servers:
# Value should be in format <FQDN>:<port>. Port is optional
- TMPL_KAFKA_SERVER1_FQDN:TMPL_KAFKA_SERVER1_PORT
13 changes: 6 additions & 7 deletions py-utils/src/utils/setup/kafka/kafka.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def _set_kafka_config(hostname: str, port: str, kafka_servers: list):
# /var/lib/zookeeper myid file
if len(kafka_servers) > 1:
with open('/var/lib/zookeeper/myid', 'w+') as myid_f:
myid_f.write(str(index))
myid_f.write(str(index + 1))

Kafka._update_properties_file(
server_properties_file, server_properties)
Expand Down Expand Up @@ -223,14 +223,13 @@ def init(self, *args, **kwargs):
if not (curr_host_fqdn in hosts or curr_host_ip in hosts) :
return 0 # return if current host is not a kafka server

_, err, rc = SimpleProcess.run("systemctl restart kafka-zookeeper")
_, err, rc = SimpleProcess("systemctl restart kafka-zookeeper").run()
if rc != 0:
raise KafkaSetupError(\
rc, "Unable to start Zookeeper", err)
raise KafkaSetupError(rc, "Unable to start Zookeeper", err)
attempt = 0
while attempt <= 100 :
_, _, rc = SimpleProcess.run(
"echo ruok | nc `hostname` 2181 | grep imok")
_, _, rc = SimpleProcess(
"echo ruok|nc `hostname` 2181|grep imok").run()
if rc != 0 :
attempt += 1
sleep(1)
Expand All @@ -240,7 +239,7 @@ def init(self, *args, **kwargs):
if attempt > 100 :
raise KafkaSetupError(ERR_OP_FAILED, "Unable to start Zookeeper")

_, err, rc = SimpleProcess.run("systemctl restart kafka")
_, err, rc = SimpleProcess("systemctl restart kafka").run()
if rc != 0:
raise KafkaSetupError(rc, "Unable to start Kakfa", err)

Expand Down
5 changes: 2 additions & 3 deletions py-utils/src/utils/setup/kafka/kafka_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ def __init__(self, args):
self.kafka = Kafka()

def process(self, *args, **kwargs):
# TODO: Add actions here
kafka_servers = args[0]
rc = self.kafka.config(kafka_servers)
return rc
Expand All @@ -136,8 +135,8 @@ def __init__(self, args):
self.kafka = Kafka()

def process(self, *args, **kwargs):
# TODO: Add actions here
rc = self.kafka.init()
kafka_servers = args[0]
rc = self.kafka.init(kafka_servers)
return rc


Expand Down

0 comments on commit 15e689e

Please sign in to comment.