charmhelpers/contrib/openstack/deferred_events.py: get_service_start_time raises exception for services which have never been started
This issue was first filed against https://bugs.launchpad.net/charm-ovn-chassis/+bug/2048806, but as I investigated the details, that bug appears to likely be due to a bug in charmhelpers, hence I'm creating a new bug here.
Specifically: I found that there appears to be a bug in charmhelpers/contrib/openstack/deferred_events.py in the get_service_start_time function. That function tries to parse the output of "systemctl show $SERVICE --property=ActiveEnterTimestamp" - but if the service has never been started before (thus returning "n/a"), the function will raise an exception.
Looking at the code today, it seems the issue still exists. The code assumes that a blank string might be returned, but it does not expect an "n/a" string.
As a concrete example, on an affected machine, this is what I see:
ubuntu@REDACTED:~$ systemctl show dpdk --property=ActiveEnterTimestamp
ActiveEnterTimestamp=n/a
This would clearly break when it hits the datetime.datetime.strptime call since "n/a" doesn't match the specified parse pattern.