From commits-return-10779-archive-asf-public=cust-asf.ponee.io@pulsar.incubator.apache.org Tue Jul 10 19:01:12 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 6A09B180663 for ; Tue, 10 Jul 2018 19:01:11 +0200 (CEST) Received: (qmail 61613 invoked by uid 500); 10 Jul 2018 17:01:10 -0000 Mailing-List: contact commits-help@pulsar.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@pulsar.incubator.apache.org Delivered-To: mailing list commits@pulsar.incubator.apache.org Received: (qmail 61604 invoked by uid 99); 10 Jul 2018 17:01:10 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 10 Jul 2018 17:01:10 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id E984581ED1; Tue, 10 Jul 2018 17:01:09 +0000 (UTC) Date: Tue, 10 Jul 2018 17:01:09 +0000 To: "commits@pulsar.apache.org" Subject: [incubator-pulsar] branch master updated: Only exit from watch-znode if we managed to communicate with zk (#2127) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Message-ID: <153124206982.15981.2600481937587809418@gitbox.apache.org> From: mmerli@apache.org X-Git-Host: gitbox.apache.org X-Git-Repo: incubator-pulsar X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: 5c9d077d3679a51410c47904cd42ef6f1578c737 X-Git-Newrev: 914de19f8d3a1f11d547cde934519f08fa3d6d4c X-Git-Rev: 914de19f8d3a1f11d547cde934519f08fa3d6d4c X-Git-NotificationType: ref_changed_plus_diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated This is an automated email from the ASF dual-hosted git repository. mmerli pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-pulsar.git The following commit(s) were added to refs/heads/master by this push: new 914de19 Only exit from watch-znode if we managed to communicate with zk (#2127) 914de19 is described below commit 914de19f8d3a1f11d547cde934519f08fa3d6d4c Author: Ivan Kelly AuthorDate: Tue Jul 10 18:01:07 2018 +0100 Only exit from watch-znode if we managed to communicate with zk (#2127) The integration tests sometimes fail because the watch-znode script which is used to set the order of service startup throws an exception and exits without waiting for initialization to happen. This patch changes the watch-znode script to only ever exit if communication with zk has been successful. --- docker/pulsar/scripts/watch-znode.py | 40 +++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/docker/pulsar/scripts/watch-znode.py b/docker/pulsar/scripts/watch-znode.py index 5075353..6e8d55d 100755 --- a/docker/pulsar/scripts/watch-znode.py +++ b/docker/pulsar/scripts/watch-znode.py @@ -20,6 +20,7 @@ import sys, getopt, time, logging from kazoo.client import KazooClient +from kazoo.exceptions import NodeExistsError from kazoo.retry import KazooRetry logging.getLogger('kazoo.client').addHandler(logging.StreamHandler()) @@ -80,19 +81,26 @@ if (not watch and not create and not exists): usage() sys.exit(5) -zk = KazooClient(hosts=zookeeper, timeout=1, connection_retry=KazooRetry(max_tries=-1)) -zk.start() - -if create: - zk.create(znode) -elif watch: - while not zk.exists(znode): - print "Waiting for %s" % znode - time.sleep(1) -elif exists: - if zk.exists(znode): - sys.exit(0) - else: - sys.exit(-1) - -zk.stop() +while True: + zk = KazooClient(hosts=zookeeper, timeout=1, connection_retry=KazooRetry(max_tries=-1)) + try: + zk.start() + if create: + try: + zk.create(znode) + except NodeExistsError: + pass + sys.exit(0) + elif watch: + while not zk.exists(znode): + print "Waiting for %s" % znode + time.sleep(1) + sys.exit(0) + elif exists: + if zk.exists(znode): + sys.exit(0) + else: + sys.exit(-1) + finally: + zk.stop() + zk.close()