Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

keystone_wait_for_propagation has key error when relation key does not exist #143

Closed
ryan-beisner opened this issue Apr 2, 2018 · 1 comment
Assignees

Comments

@ryan-beisner
Copy link
Contributor

In a circular twist of missing keys, the attempt to raise an exception for missing relation data results in a key error while trying to log details into the exception message.

DEBUG:runner:Traceback (most recent call last):
DEBUG:runner:  File "/tmp/bundletester-7ZZqdN/keystone/tests/gate-basic-trusty-kilo", line 24, in <module>
DEBUG:runner:    source='cloud:trusty-updates/kilo')
DEBUG:runner:  File "/tmp/bundletester-7ZZqdN/keystone/tests/basic_deployment.py", line 66, in __init__
DEBUG:runner:    self._initialize_test_differences()
DEBUG:runner:  File "/tmp/bundletester-7ZZqdN/keystone/tests/basic_deployment.py", line 331, in _initialize_test_differences
DEBUG:runner:    self.set_api_version(2)
DEBUG:runner:  File "/tmp/bundletester-7ZZqdN/keystone/tests/basic_deployment.py", line 197, in set_api_version
DEBUG:runner:    u.keystone_configure_api_version(se_rels, self, api_version)
DEBUG:runner:  File "/tmp/bundletester-7ZZqdN/keystone/tests/charmhelpers/contrib/openstack/amulet/utils.py", line 351, in keystone_configure_api_version
DEBUG:runner:    self.keystone_wait_for_propagation(sentry_relation_pairs, api_version)
DEBUG:runner:  File "/tmp/bundletester-7ZZqdN/keystone/tests/charmhelpers/contrib/openstack/amulet/utils.py", line 331, in keystone_wait_for_propagation
DEBUG:runner:    "".format(rel['api_version'], api_version))
DEBUG:runner:KeyError: 'api_version'
DEBUG:runner:Exit Code: 1
    def keystone_wait_for_propagation(self, sentry_relation_pairs,
                                      api_version):
        """Iterate over list of sentry and relation tuples and verify that
           api_version has the expected value.

        :param sentry_relation_pairs: list of sentry, relation name tuples used
                                      for monitoring propagation of relation
                                      data
        :param api_version: api_version to expect in relation data
        :returns: None if successful.  Raise on error.
        """
        for (sentry, relation_name) in sentry_relation_pairs:
            rel = sentry.relation('identity-service',
                                  relation_name)
            self.log.debug('keystone relation data: {}'.format(rel))
            if rel.get('api_version') != str(api_version):
                raise Exception("api_version not propagated through relation"
                                " data yet ('{}' != '{}')."
                                "".format(rel['api_version'], api_version))
@ryan-beisner ryan-beisner self-assigned this Apr 2, 2018
ryan-beisner pushed a commit to ryan-beisner/charm-helpers that referenced this issue Apr 2, 2018
keystone_wait_for_propagation had a key error when raising
a custom exception message because it was trying to use a
dict key which may not always exist.

Use dict.get instead of dict explicit key reference, as
dict.get returns None when the key does not exist.

Fixes juju#143
wolsen pushed a commit that referenced this issue Apr 2, 2018
keystone_wait_for_propagation had a key error when raising
a custom exception message because it was trying to use a
dict key which may not always exist.

Use dict.get instead of dict explicit key reference, as
dict.get returns None when the key does not exist.

Fixes #143
@ryan-beisner
Copy link
Contributor Author

ryan-beisner commented Apr 2, 2018

Revoked this comment, wrong PR. Hi and bye.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant