removing relation results in hook error

Bug #1835426 reported by James Page
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Keystone SAML Mellon Charm
Triaged
Low
Unassigned

Bug Description

We've also noticed that removing the mellon relations puts the charm in error state with this error logged:

2019-06-26 10:56:35 DEBUG worker.uniter.jujuc server.go:182 running hook tool "juju-log"
2019-06-26 10:56:35 INFO juju-log keystone-fid-service-provider:121: Invoking reactive handler: reactive/keystone_saml_mellon_handlers.py:39:publish_sp_fid
2019-06-26 10:56:35 DEBUG worker.uniter.jujuc server.go:182 running hook tool "juju-log"
2019-06-26 10:56:35 ERROR juju-log keystone-fid-service-provider:121: Hook error:
Traceback (most recent call last):
File "/var/lib/juju/agents/unit-keystone-saml-mellon-0/.venv/lib/python3.6/site-packages/charms/reactive/__init__.py", line 73, in main
bus.dispatch(restricted=restricted_mode)
File "/var/lib/juju/agents/unit-keystone-saml-mellon-0/.venv/lib/python3.6/site-packages/charms/reactive/bus.py", line 390, in dispatch
_invoke(other_handlers)
File "/var/lib/juju/agents/unit-keystone-saml-mellon-0/.venv/lib/python3.6/site-packages/charms/reactive/bus.py", line 359, in _invoke
handler.invoke()
File "/var/lib/juju/agents/unit-keystone-saml-mellon-0/.venv/lib/python3.6/site-packages/charms/reactive/bus.py", line 181, in invoke
self._action(*args)
File "/var/lib/juju/agents/unit-keystone-saml-mellon-0/charm/reactive/keystone_saml_mellon_handlers.py", line 43, in publish_sp_fid
charm_instance.options.remote_id_attribute)
File "/var/lib/juju/agents/unit-keystone-saml-mellon-0/charm/hooks/relations/keystone-fid-service-provider/provides.py", line 78, in publish
rel = self.relations[0]
File "/var/lib/juju/agents/unit-keystone-saml-mellon-0/.venv/lib/python3.6/site-packages/charms/reactive/endpoints.py", line 569, in __getitem__
return super().__getitem__(self._translate_key(key))
IndexError: list index out of range

Tags: scaleback
Ryan Beisner (1chb1n)
tags: added: scaleback
Revision history for this message
Alex Kavanagh (ajkavanagh) wrote :

The bug still exists in the charm-interface-keystone-fid-service-provider interface in provides.py at line 78:

    def publish(self, protocol_name, remote_id_attribute):
        # get the first relation object as we only have one relation
        # to a primary as a subordinate
        rel = self.relations[0]
        # can have multiple dashboard charms in general, therefore,
        # all relation objects and all units must be handled
        # to_publish/relation_set work on a per-relation basis
        rel.to_publish['protocol-name'] = protocol_name
        rel.to_publish['remote-id-attribute'] = remote_id_attribute

Easiest fix is just to check that self.relations has at least one element or wrap it in a try: except:

Changed in charm-keystone-saml-mellon:
importance: Undecided → Low
status: New → Triaged
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.