Return-Path: X-Original-To: apmail-couchdb-commits-archive@www.apache.org Delivered-To: apmail-couchdb-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 1737710E3F for ; Thu, 4 Dec 2014 10:52:14 +0000 (UTC) Received: (qmail 47238 invoked by uid 500); 4 Dec 2014 10:52:14 -0000 Delivered-To: apmail-couchdb-commits-archive@couchdb.apache.org Received: (qmail 47189 invoked by uid 500); 4 Dec 2014 10:52:14 -0000 Mailing-List: contact commits-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list commits@couchdb.apache.org Received: (qmail 47046 invoked by uid 99); 4 Dec 2014 10:52:13 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 04 Dec 2014 10:52:13 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 7D6CBA1B5E8; Thu, 4 Dec 2014 10:52:13 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: mikewallace@apache.org To: commits@couchdb.apache.org Date: Thu, 04 Dec 2014 10:52:13 -0000 Message-Id: <2fa89e52dab943c1b0961b5d900f2ea2@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [1/3] couchdb commit: updated refs/heads/2452-users-db-security-on-clustered-interface to ed4a4a9 Repository: couchdb Updated Branches: refs/heads/2452-users-db-security-on-clustered-interface [created] ed4a4a9e2 Teach dev/run to clear nodes DB This commit makes dev/run replace the nodes DB with an empty DB before adding the nodes doc. This changes the previous behaviour which was to just try adding the docs and ignore conflicts. The change makes it possible for a developer to run `dev/run -n 1` (to spawn a single node cluster) having previously run `dev/run` (which spawns a three node cluster). Without replacing the nodes DB the `dev/run -n 1` single-node cluster would still have two other nodes in the nodes DB and therefore not work correctly. Note that we explicitly delete each node doc rather than deleting the whole database because the cluster membership layer gets upset when the nodes database itself is deleted/recreated. Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/49f03e2b Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/49f03e2b Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/49f03e2b Branch: refs/heads/2452-users-db-security-on-clustered-interface Commit: 49f03e2be48dac56c27b220b11cd70676df50f99 Parents: 126ec76 Author: Mike Wallace Authored: Wed Nov 26 23:17:04 2014 +0000 Committer: Mike Wallace Committed: Wed Dec 3 19:11:09 2014 +0000 ---------------------------------------------------------------------- dev/run | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb/blob/49f03e2b/dev/run ---------------------------------------------------------------------- diff --git a/dev/run b/dev/run index ada5492..bce55f1 100755 --- a/dev/run +++ b/dev/run @@ -17,6 +17,7 @@ import contextlib import functools import glob import inspect +import json import optparse import os import re @@ -230,6 +231,7 @@ def hashify(pwd, salt=COMMON_SALT, iterations=10, keylen=20): def startup(ctx): atexit.register(kill_processes, ctx) boot_nodes(ctx) + reset_nodes_db(ctx, "127.0.0.1") join_nodes(ctx, "127.0.0.1", 15986) @@ -295,6 +297,27 @@ def boot_node(ctx, node): return sp.Popen(cmd, stdin=sp.PIPE, stdout=log, stderr=sp.STDOUT, env=env) +@log('Reset nodes DB') +def reset_nodes_db(ctx, host): + _, port = get_ports(1) + conn = httpclient.HTTPConnection(host, port) + conn.request('GET', '/nodes/_all_docs') + resp = conn.getresponse() + if not resp.status == 200: + print('Could not read nodes DB documents', resp.reason) + exit(1) + nodes = json.loads(resp.read())['rows'] + for node in nodes: + node_id = node['id'] + rev = node['value']['rev'] + conn = httpclient.HTTPConnection(host, port) + conn.request('DELETE', '/nodes/{0}?rev={1}'.format(node_id, rev)) + resp = conn.getresponse() + if not resp.status == 200: + print('Failed to reset nodes DB', resp.reason) + exit(1) + + @log('Join nodes into cluster') def join_nodes(ctx, host, port): for node in ctx['nodes']: