diff --git a/charmhelpers/core/unitdata.py b/charmhelpers/core/unitdata.py index 8f4bbc614..eb7245309 100644 --- a/charmhelpers/core/unitdata.py +++ b/charmhelpers/core/unitdata.py @@ -173,13 +173,25 @@ class Storage(object): """ def __init__(self, path=None, keep_revisions=False): self.db_path = path + # The following is a hack to work around a bug in which both the + # ops framework libraries and charmhelpers end up using the same + # DB path, which leads to conflicts. + # See: https://bugs.launchpad.net/charm-ceph-mon/+bug/2005137 + db_suffix = '.unit-state.db' + try: + import ops + db_suffix = '.unit-state2.db' + del ops # Don't hold an unneeded reference. + except: + pass + self.keep_revisions = keep_revisions if path is None: if 'UNIT_STATE_DB' in os.environ: self.db_path = os.environ['UNIT_STATE_DB'] else: self.db_path = os.path.join( - os.environ.get('CHARM_DIR', ''), '.unit-state.db') + os.environ.get('CHARM_DIR', ''), db_suffix) if self.db_path != ':memory:': with open(self.db_path, 'a') as f: os.fchmod(f.fileno(), 0o600)