Code review comment for ~dashmage/charm-sysconfig:bug-2012581/clear-notification-fix

Revision history for this message
Eric Chen (eric-chen) wrote :

> > Why we need to flush local's unit data here? Also the previous line is
> `set`, flush after set look make not sense to me.
> > Could you explain why we need to do this?
>
> So without explicitly adding `unitdata.kv().flush()` it seems that the local
> unit's data is not being written to the DB. Without this line, when we try to
> get the value later, it's only returning `None`.
>
> For the other line, `datetime.fromtimestamp` is the correct function to
> convert the POSIX timestamp (in float) to the local date.

https://github.com/juju/charm-helpers/blob/master/charmhelpers/core/unitdata.py#L165

Modifications are not persisted unless :meth:`flush` is called.

https://github.com/juju/charm-helpers/blob/master/charmhelpers/contrib/hardening/audits/file.py#L423
I can find similar usage here.

« Back to merge proposal