[gnuoy,trivial] Pre-release charmhelper sync to pickup leadership election peer migration fix

This commit is contained in:
Liam Young 2015-08-03 14:59:29 +01:00
parent 2e6970ca0e
commit 4f84dd2776
2 changed files with 21 additions and 5 deletions

View File

@ -59,7 +59,7 @@ def some_hook():
"""
def leader_get(attribute=None):
def leader_get(attribute=None, rid=None):
"""Wrapper to ensure that settings are migrated from the peer relation.
This is to support upgrading an environment that does not support
@ -94,7 +94,8 @@ def leader_get(attribute=None):
# If attribute not present in leader db, check if this unit has set
# the attribute in the peer relation
if not leader_settings:
peer_setting = relation_get(attribute=attribute, unit=local_unit())
peer_setting = _relation_get(attribute=attribute, unit=local_unit(),
rid=rid)
if peer_setting:
leader_set(settings={attribute: peer_setting})
leader_settings = peer_setting
@ -103,7 +104,7 @@ def leader_get(attribute=None):
settings_migrated = True
migrated.add(attribute)
else:
r_settings = relation_get(unit=local_unit())
r_settings = _relation_get(unit=local_unit(), rid=rid)
if r_settings:
for key in set(r_settings.keys()).difference(migrated):
# Leader setting wins
@ -151,7 +152,7 @@ def relation_get(attribute=None, unit=None, rid=None):
"""
try:
if rid in relation_ids('cluster'):
return leader_get(attribute)
return leader_get(attribute, rid)
else:
raise NotImplementedError
except NotImplementedError:

View File

@ -34,7 +34,22 @@ import errno
import tempfile
from subprocess import CalledProcessError
from charmhelpers.cli import cmdline
try:
from charmhelpers.cli import cmdline
except ImportError as e:
# due to the anti-pattern of partially synching charmhelpers directly
# into charms, it's possible that charmhelpers.cli is not available;
# if that's the case, they don't really care about using the cli anyway,
# so mock it out
if str(e) == 'No module named cli':
class cmdline(object):
@classmethod
def subcommand(cls, *args, **kwargs):
def _wrap(func):
return func
return _wrap
else:
raise
import six
if not six.PY3: