lib/charms/apt.py install_queued causing traceback when unit in error state

Bug #1784482 reported by Drew Freiberger
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Apt layer
Fix Released
High
Stuart Bishop
PostgreSQL Charm
Fix Released
High
Stuart Bishop

Bug Description

apt.py library issue is causing an infinite error state for failed hooks on juju 2.4.1.

From the below traceback you can see that lib/charms/apt.py line 127 is calling a set_status with state None which causes the set_status routine to query the unit's current state for status. I'd recommend that when running an apt installation, the state should be shifted to "maintenance" to give a non-error status when running a resolved --retry on update-status.

This does seem a potential regression in juju not allowing the units to set an error state.

root@landscapesql-2:/var/lib/juju/agents/unit-landscape-postgresql-0/charm# hooks/update-status
none
Traceback (most recent call last):
  File "hooks/update-status", line 19, in <module>
    main()
  File "/var/lib/juju/agents/unit-landscape-postgresql-0/.venv/lib/python3.5/site-packages/charms/reactive/__init__.py", line 72, in main
    bus.dispatch(restricted=restricted_mode)
  File "/var/lib/juju/agents/unit-landscape-postgresql-0/.venv/lib/python3.5/site-packages/charms/reactive/bus.py", line 375, in dispatch
    _invoke(other_handlers)
  File "/var/lib/juju/agents/unit-landscape-postgresql-0/.venv/lib/python3.5/site-packages/charms/reactive/bus.py", line 351, in _invoke
    handler.invoke()
  File "/var/lib/juju/agents/unit-landscape-postgresql-0/.venv/lib/python3.5/site-packages/charms/reactive/bus.py", line 173, in invoke
    self._action(*args)
  File "/var/lib/juju/agents/unit-landscape-postgresql-0/charm/reactive/apt.py", line 44, in install_queued
    charms.apt.install_queued()
  File "lib/charms/apt.py", line 127, in install_queued
    status_set(None, 'Installing {}'.format(','.join(packages)))
  File "lib/charms/apt.py", line 216, in status_set
    hookenv.status_set(state, message)
  File "/var/lib/juju/agents/unit-landscape-postgresql-0/.venv/lib/python3.5/site-packages/charmhelpers/core/hookenv.py", line 890, in status_set
    '{!r} is not a valid workload state'.format(workload_state)
ValueError: 'error' is not a valid workload state
root@landscapesql-2:/var/lib/juju/agents/unit-landscape-postgresql-0/charm# status-get
error
root@landscapesql-2:/var/lib/juju/agents/unit-landscape-postgresql-0/charm# status-set blocked
root@landscapesql-2:/var/lib/juju/agents/unit-landscape-postgresql-0/charm# status-get
error

Revision history for this message
Drew Freiberger (afreiberger) wrote :

This is actually a bug in apt.py layer caused by a juju regression. Filed as: https://github.com/stub42/layer-apt/issues/3

Revision history for this message
Stuart Bishop (stub) wrote :

Apt layer should force the workload state to maintenance if the current state is not one of blocked, waiting, maintenance or active. Its an easy workaround, so we should do it even if Juju deems this a regression.

The PostgreSQL charm needs to be rebuilt with the updated layer.

Revision history for this message
Stuart Bishop (stub) wrote :

Workaround is 'juju run --unit=landscape-postgresql/0 -- status set blocked whoops'

Revision history for this message
Stuart Bishop (stub) wrote :

(correction)

Workaround is 'juju run --unit=landscape-postgresql/0 -- status-set blocked whoops'

Changed in layer-apt:
status: New → Triaged
Changed in postgresql-charm:
status: New → Triaged
Changed in layer-apt:
importance: Undecided → High
Changed in postgresql-charm:
importance: Undecided → High
Stuart Bishop (stub)
Changed in layer-apt:
status: Triaged → Fix Released
assignee: nobody → Stuart Bishop (stub)
Stuart Bishop (stub)
Changed in postgresql-charm:
status: Triaged → Fix Released
Stuart Bishop (stub)
Changed in postgresql-charm:
assignee: nobody → Stuart Bishop (stub)
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.