[openstack-dev] [charms] evolving the ha interface type

James Page james.page at ubuntu.com
Sun Nov 5 23:03:56 UTC 2017

Hi Team

Whilst working on migrating to using Python 3 as the default charm
execution environment, I've hit upon a snag with presentation of data from
principle charms to the hacluster subordinate charm.

Specifically the data presented on the relation is simple str
representation of python dicts which are then parsed used ast in the
hacluster charm.

This has worked OK under Python 2, but due to the non-deterministic
iteration of dict keys, the data presented from the principle charm can
change over time when the ha_joined function is re-exec'ed (such as during
a config-changed hook execution).

I'd like to propose that we move to using json to serialise this data so
that we can used ordered dicts to present data in a consistent fashion.

We need to evolve the interface to deal with this - we could potentially
take two approaches:

a) Attempt to parse presented data using json, fallback to ast for
backwards compat

b) Present a version flag from the hacluster charm, allowing the principle
to switch to the new approach when the required version of the hacluster
charm is presented to it.  We'd still do a) but it would avoid hook
failures in the event that a user does not upgrade hacluster application
instances prior to upgrading principle charms.

Anyway - that's my current thoughts. I have a prototype for a) which works
nicely, but I think adding b) will provide a better UX (thanks gnuoy for
pointing to this solution).


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstack.org/pipermail/openstack-dev/attachments/20171105/b2ec1421/attachment.html>

More information about the OpenStack-dev mailing list