Merge lp:~hloeung/ubuntu-repository-cache/charm-env-fixes into lp:ubuntu-repository-cache

Proposed by Haw Loeung
Status: Merged
Approved by: Haw Loeung
Approved revision: 289
Merged at revision: 288
Proposed branch: lp:~hloeung/ubuntu-repository-cache/charm-env-fixes
Merge into: lp:ubuntu-repository-cache
Diff against target: 49 lines (+6/-4)
4 files modified
lib/ubuntu_repository_cache/metadata_sync.py (+3/-2)
lib/ubuntu_repository_cache/service.py (+1/-0)
lib/ubuntu_repository_cache/tests/test_metadata_sync.py (+1/-1)
templates/cron/ubuntu-repository-cache_rsync.cron (+1/-1)
To merge this branch: bzr merge lp:~hloeung/ubuntu-repository-cache/charm-env-fixes
Reviewer Review Type Date Requested Status
Thomas Cuthbert (community) Approve
Canonical IS Reviewers Pending
Review via email: mp+392157@code.launchpad.net

Commit message

Switch to the charm-env shipped with the charm, it's the latest and fixes GH#144

Description of the change

The latest charm-env fixes these import warnings/errors:

| root@machine-0:/etc/cron.d# . /etc/repository-sync/ubuntu-repository-cache && run-one /usr/local/sbin/charm-env --charm ubuntu-repository-cache | python3 -m ubuntu_repository_cache.metadata_sync
| Traceback (most recent call last):
| File "<string>", line 1, in <module>
| ModuleNotFoundError: No module named 'charmhelpers'
| Traceback (most recent call last):
| File "<string>", line 1, in <module>
| ModuleNotFoundError: No module named 'charmhelpers'

This is https://github.com/juju-solutions/layer-basic/commit/0845a8429aae4eb1c32131ef37235f2ac196676c

Sadly, /usr/local/sbin/charm-env is rarely updated, likely shipped out on unit provision / charm install. Switch to the version shipped out with the charm instead.

To post a comment you must log in.
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

This merge proposal is being monitored by mergebot. Change the status to Approved to merge.

289. By Haw Loeung

Cron job too

Revision history for this message
Thomas Cuthbert (tcuthbert) wrote :

LGTM +1

review: Approve
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

Change successfully merged at revision 288

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/ubuntu_repository_cache/metadata_sync.py'
--- lib/ubuntu_repository_cache/metadata_sync.py 2020-10-06 10:04:18 +0000
+++ lib/ubuntu_repository_cache/metadata_sync.py 2020-10-13 04:39:12 +0000
@@ -274,8 +274,9 @@
274274
275 # Call the sync hook inside the juju environment to propagate changes to275 # Call the sync hook inside the juju environment to propagate changes to
276 # other units276 # other units
277 path = '/usr/local/sbin/charm-env /var/lib/juju/agents/{}/charm/hooks/ubuntu-repository-cache-sync {}'277 charm_env = '/var/lib/juju/agents/{}/charm/bin/charm-env'.format(unit_path)
278 path = path.format(unit_path, meta_ver)278 path = '{} /var/lib/juju/agents/{}/charm/hooks/ubuntu-repository-cache-sync {}'
279 path = path.format(charm_env, unit_path, meta_ver)
279 cmd = ['juju-run', local_unit, path]280 cmd = ['juju-run', local_unit, path]
280281
281 log("Executing hook: {}".format(cmd))282 log("Executing hook: {}".format(cmd))
282283
=== modified file 'lib/ubuntu_repository_cache/service.py'
--- lib/ubuntu_repository_cache/service.py 2020-10-06 10:04:18 +0000
+++ lib/ubuntu_repository_cache/service.py 2020-10-13 04:39:12 +0000
@@ -276,6 +276,7 @@
276 cron_context['UnitPath'] = '-'.join(('unit', hookenv.local_unit().replace('/', '-')))276 cron_context['UnitPath'] = '-'.join(('unit', hookenv.local_unit().replace('/', '-')))
277 cron_context['MirrorSeries'] = config['mirror-series'].strip()277 cron_context['MirrorSeries'] = config['mirror-series'].strip()
278 cron_context['ConfigPath'] = urc_config_path278 cron_context['ConfigPath'] = urc_config_path
279 cron_context['CharmEnvPath'] = os.path.join(hookenv.charm_dir(), 'bin', 'charm-env')
279 templating.render('cron/ubuntu-repository-cache_rsync.cron', cron_filename, cron_context)280 templating.render('cron/ubuntu-repository-cache_rsync.cron', cron_filename, cron_context)
280 templating.render('cron/ubuntu-repository-cache-config', urc_config_path, cron_context)281 templating.render('cron/ubuntu-repository-cache-config', urc_config_path, cron_context)
281 else:282 else:
282283
=== modified file 'lib/ubuntu_repository_cache/tests/test_metadata_sync.py'
--- lib/ubuntu_repository_cache/tests/test_metadata_sync.py 2020-10-06 10:04:18 +0000
+++ lib/ubuntu_repository_cache/tests/test_metadata_sync.py 2020-10-13 04:39:12 +0000
@@ -187,7 +187,7 @@
187 [187 [
188 'juju-run',188 'juju-run',
189 'unit/0',189 'unit/0',
190 '/usr/local/sbin/charm-env '190 '/var/lib/juju/agents/something/charm/bin/charm-env '
191 '/var/lib/juju/agents/something/charm/hooks/'191 '/var/lib/juju/agents/something/charm/hooks/'
192 'ubuntu-repository-cache-sync some_meta_var',192 'ubuntu-repository-cache-sync some_meta_var',
193 ],193 ],
194194
=== modified file 'templates/cron/ubuntu-repository-cache_rsync.cron'
--- templates/cron/ubuntu-repository-cache_rsync.cron 2020-07-09 02:35:50 +0000
+++ templates/cron/ubuntu-repository-cache_rsync.cron 2020-10-13 04:39:12 +0000
@@ -1,4 +1,4 @@
1# This cronjob will make the leader sync its view of the metadata with upstream1# This cronjob will make the leader sync its view of the metadata with upstream
2# It will then trigger a juju-run to let its peers synchronise.2# It will then trigger a juju-run to let its peers synchronise.
3{{ Minutes }} * * * * root . {{ ConfigPath }} && run-one /usr/local/sbin/charm-env --charm ubuntu-repository-cache python3 -m ubuntu_repository_cache.metadata_sync3{{ Minutes }} * * * * root . {{ ConfigPath }} && run-one {{ CharmEnvPath }} --charm ubuntu-repository-cache python3 -m ubuntu_repository_cache.metadata_sync
44

Subscribers

People subscribed via source and target branches