[VOL-1862] rwCore waits for kafka and KV Store
This commit is a cherry pick into the master branch from the
voltha 2.1 branch of patch https://gerrit.opencord.org/#/c/15030/
Change-Id: I8a306c8b37ad700ef8234466919e0604e14787cd
diff --git a/kafka/sarama_client.go b/kafka/sarama_client.go
index 0576da9..8037002 100755
--- a/kafka/sarama_client.go
+++ b/kafka/sarama_client.go
@@ -228,6 +228,13 @@
var err error
+ // Add a cleanup in case of failure to startup
+ defer func() {
+ if err != nil {
+ sc.Stop()
+ }
+ }()
+
// Create the Cluster Admin
if err = sc.createClusterAdmin(); err != nil {
log.Errorw("Cannot-create-cluster-admin", log.Fields{"error": err})