From eb02eee05e8cd69a6ae9a6bb4e7289d9d2ec1f5f Mon Sep 17 00:00:00 2001 From: rallytime Date: Tue, 9 Jun 2015 12:39:12 -0600 Subject: [PATCH] The first arg in a state should always be name, and unfreeze name from salt/state.py This should fix the problems with the CentOS* test failures. --- salt/state.py | 1 - salt/states/zk_concurrency.py | 31 ++++++++++++++++--------------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/salt/state.py b/salt/state.py index d258b2d90d..060fdb1c4c 100644 --- a/salt/state.py +++ b/salt/state.py @@ -66,7 +66,6 @@ STATE_REQUISITE_IN_KEYWORDS = frozenset([ 'listen_in', ]) STATE_RUNTIME_KEYWORDS = frozenset([ - 'name', # name of the highstate running 'fun', 'state', 'check_cmd', diff --git a/salt/states/zk_concurrency.py b/salt/states/zk_concurrency.py index d4ec7b19f9..2af8d8aa0e 100644 --- a/salt/states/zk_concurrency.py +++ b/salt/states/zk_concurrency.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- ''' Control concurrency of steps within state execution using zookeeper -========================================================================= +=================================================================== This module allows you to "wrap" a state's execution with concurrency control. This is useful to protect against all hosts executing highstate simultaneously @@ -17,8 +17,8 @@ steps are executing with a single path. acquire_lock: zk_concurrency.lock: + - name: /trafficeserver - zk_hosts: 'zookeeper:2181' - - path: /trafficserver - max_concurrency: 4 - prereq: - service: trafficserver @@ -34,7 +34,7 @@ steps are executing with a single path. release_lock: zk_concurrency.unlock: - - path: /trafficserver + - name: /trafficserver - require: - service: trafficserver @@ -48,6 +48,7 @@ REQUIRED_FUNCS = ( 'zk_concurrency.unlock', 'zk_concurrency.party_members', ) + __virtualname__ = 'zk_concurrency' @@ -58,7 +59,7 @@ def __virtual__(): return __virtualname__ -def lock(path, +def lock(name, zk_hosts, identifier=None, max_concurrency=1, @@ -69,7 +70,7 @@ def lock(path, Block state execution until you are able to get the lock (or hit the timeout) ''' - ret = {'name': path, + ret = {'name': name, 'changes': {}, 'result': False, 'comment': ''} @@ -82,7 +83,7 @@ def lock(path, if identifier is None: identifier = __grains__['id'] - locked = __salt__['zk_concurrency.lock'](path, + locked = __salt__['zk_concurrency.lock'](name, zk_hosts, identifier=identifier, max_concurrency=max_concurrency, @@ -97,16 +98,16 @@ def lock(path, return ret -def unlock(path, +def unlock(name, zk_hosts=None, # in case you need to unlock without having run lock (failed execution for example) identifier=None, max_concurrency=1, ephemeral_lease=False ): ''' - Remove lease from semaphore + Remove lease from semaphore. ''' - ret = {'name': path, + ret = {'name': name, 'changes': {}, 'result': False, 'comment': ''} @@ -119,7 +120,7 @@ def unlock(path, if identifier is None: identifier = __grains__['id'] - unlocked = __salt__['zk_concurrency.unlock'](path, + unlocked = __salt__['zk_concurrency.unlock'](name, zk_hosts=zk_hosts, identifier=identifier, max_concurrency=max_concurrency, @@ -128,23 +129,23 @@ def unlock(path, if unlocked: ret['result'] = True else: - ret['comment'] = 'Unable to find lease for path {0}'.format(path) + ret['comment'] = 'Unable to find lease for path {0}'.format(name) return ret -def min_party(path, +def min_party(name, zk_hosts, min_nodes, ): ''' - Ensure that there are `min_nodes` in the party at `path` + Ensure that there are `min_nodes` in the party at `name`. ''' - ret = {'name': path, + ret = {'name': name, 'changes': {}, 'result': False, 'comment': ''} - nodes = __salt__['zk_concurrency.party_members'](path, zk_hosts) + nodes = __salt__['zk_concurrency.party_members'](name, zk_hosts) if not isinstance(nodes, list): raise Exception('Error from zk_concurrency.party_members, return was not a list: {0}'.format(nodes))