syslog-relation-departed hook fails if self.get_local("path") returns None
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
PostgreSQL Charm |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
I have an environment where I have a relation between the postgresql and rsyslog-
Upon removing the unit of the other app, and in turn its rsyslog-
2021-03-04 19:19:39 ERROR juju-log syslog:31: Hook error:
Traceback (most recent call last):
File "/var/lib/
bus.
File "/var/lib/
_invoke(
File "/var/lib/
handler.
File "/var/lib/
self.
File "/var/lib/
if os.path.
File "/var/lib/
os.stat(path)
TypeError: stat: path should be string, bytes, os.PathLike or integer, not NoneType
Upon examining the .unit-state.db file, when running the query "select key from kv where key like '%local-data%';", I got zero rows back. charms.
This seems to be an older bit of code, from December 2015, and I don't understand the context of what it is trying to do here - but as far as I can see, in current versions of this charm, it's going to fail - get_local() will return None as a default, and that'll get passed into os.path.exists(), etc., resulting in the error.
Related branches
- Tom Haddon: Approve
- Canonical IS Reviewers: Pending requested
-
Diff: 48 lines (+3/-25)2 files modifieddev/null (+0/-22)
hooks/relations/syslog/provides.py (+3/-3)
Changed in postgresql-charm: | |
status: | New → Triaged |
Changed in postgresql-charm: | |
status: | Triaged → Fix Released |
My best guess as to a workaround is as follows, based on the code and what it seems to be doing, is:
* "fake" the depart hook: d/juju- landscape- postgresql_ 1-rsyslog- forwarder- ha_12.conf) juju/agents/ unit-landscape- postgresql- 1/charm/ ) conversations. syslog: 31.rsyslog- forwarder- ha/12'; conversations. syslog: 31.rsyslog- forwarder- ha/12'; by-this- bug>
* Identify the remote unit ID.
* SSH into the blocked unit.
* Remove the associated file from /etc/rsyslog.d/. (e.g. /etc/rsyslog.
* Restart rsyslog.
* CD to the charm directory. (e.g. /var/lib/
* Install sqlite3.
* Via an sqlite3 shell (sqlite3 .unit-state.db):
* Dump all the keys for conversation records: select key from kv where key like '%conversation%'
* Print the data for the associated record, e.g.: select data from kv where key='reactive.
* If there's only one unit in the "units" list from the previous command, delete the record, e.g.: delete from kv where key='reactive.
* Else, if more than one unit, manually update the record to remove the unit. (I did not see this, so no example here.)
* Finally, tell Juju to skip retrying the hook: juju resolved --no-retry <unit-blocked-
Note: I have not tried this yet, although I am considering doing this tomorrow; it seems like it's likely the right thing...