Merge lp:~johnsca/juju-deployer/fallback into lp:juju-deployer

Proposed by Cory Johns
Status: Rejected
Rejected by: Haw Loeung
Proposed branch: lp:~johnsca/juju-deployer/fallback
Merge into: lp:juju-deployer
Diff against target: 102 lines (+49/-0)
3 files modified
deployer/charm.py (+10/-0)
deployer/tests/test_charm.py (+33/-0)
deployer/tests/test_data/stack-placement.yaml (+6/-0)
To merge this branch: bzr merge lp:~johnsca/juju-deployer/fallback
Reviewer Review Type Date Requested Status
Tom Haddon (community) Abstain
juju-deployers Pending
Review via email: mp+273707@code.launchpad.net

Commit message

Allow charm specification with no prefix to fall back to store if not found locally

Description of the change

If a service is specified with no prefix (neither cs: nor local:) and it doesn't exist locally, fallback to using the charm store. (Current behavior is to assume local and fail if it doesn't exist.)

See https://github.com/juju/juju-bundlelib/issues/36

To post a comment you must log in.
Revision history for this message
Cory Johns (johnsca) wrote :

To clarify: the changes to stack-placement.yaml were necessary because that bundle was depending on the previous behavior of defaulting to local charms and not trying the store, which was causing deployer/tests/test_deployment.py:DeploymentTest.test_validate_placement_sorting to fail, when it attempted to fetch the charms from the store.

The changes to the .yaml force it to consider them local charms and not try to fetch them, matching the expected behavior.

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.

Revision history for this message
Tom Haddon (mthaddon) wrote :

Abstaining since this is so old

review: Abstain

Unmerged revisions

160. By Cory Johns

Allow charm specification with no prefix to fall back to store if not found locally

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'deployer/charm.py'
2--- deployer/charm.py 2015-09-16 19:54:35 +0000
3+++ deployer/charm.py 2015-10-07 15:02:50 +0000
4@@ -76,8 +76,18 @@
5 elif 'series' in data:
6 series = data['series']
7 charm_path = path_join(repo_path, series, name)
8+ if not branch and not os.path.exists(charm_path):
9+ # charm not found locally, fall back to store
10+ charm_path = None
11+ store_url = data.get('store_url',
12+ 'cs:%s/%s' % (series, name))
13 else:
14 charm_path = path_join(repo_path, deploy_series, name)
15+ if not branch and not os.path.exists(charm_path):
16+ # charm not found locally, fall back to store
17+ charm_path = None
18+ store_url = data.get('store_url',
19+ 'cs:%s/%s' % (deploy_series, name))
20
21 if not store_url:
22 store_url = data.get('charm_url', None)
23
24=== modified file 'deployer/tests/test_charm.py'
25--- deployer/tests/test_charm.py 2015-07-29 21:19:32 +0000
26+++ deployer/tests/test_charm.py 2015-10-07 15:02:50 +0000
27@@ -1,6 +1,8 @@
28 import os
29 import logging
30 import subprocess
31+from tempfile import mkdtemp
32+import mock
33
34 from deployer.charm import Charm
35 from deployer.utils import ErrorExit, yaml_dump
36@@ -21,6 +23,37 @@
37 self.assertIsNone(self.charm.repo_path)
38
39
40+class FallbackCharmTest(Base):
41+ def setUp(self):
42+ self.tmpdir = mkdtemp()
43+
44+ def tearDown(self):
45+ os.rmdir(self.tmpdir)
46+
47+ def test_fallback(self):
48+ charm1 = Charm.from_service('ubuntu', self.tmpdir, 'trusty', {'series': 'precise'})
49+ charm2 = Charm.from_service('ubuntu', self.tmpdir, 'trusty', {})
50+
51+ assert not charm1.is_local()
52+ self.assertIn('precise', charm1.charm_url)
53+ assert not charm2.is_local()
54+ self.assertIn('trusty', charm2.charm_url)
55+
56+ def test_no_fallback_exists(self):
57+ with mock.patch('os.path.exists'):
58+ charm1 = Charm.from_service('ubuntu', self.tmpdir, 'trusty', {'series': 'precise'})
59+ charm2 = Charm.from_service('ubuntu', self.tmpdir, 'trusty', {})
60+ assert charm1.is_local()
61+ assert charm2.is_local()
62+
63+ def test_no_fallback_branch(self):
64+ charm1 = Charm.from_service('ubuntu', self.tmpdir, 'trusty', {'series': 'precise', 'branch': 'lp:foo'})
65+ charm2 = Charm.from_service('ubuntu', self.tmpdir, 'trusty', {'branch': 'lp:foo'})
66+
67+ assert charm1.is_local()
68+ assert charm2.is_local()
69+
70+
71 class AbsolutePathCharmTest(Base):
72 def setUp(self):
73 self.charm = Charm(
74
75=== modified file 'deployer/tests/test_data/stack-placement.yaml'
76--- deployer/tests/test_data/stack-placement.yaml 2014-08-15 04:57:12 +0000
77+++ deployer/tests/test_data/stack-placement.yaml 2015-10-07 15:02:50 +0000
78@@ -5,18 +5,24 @@
79 charm: cs:precise/nova-compute
80 units: 3
81 ceph:
82+ charm: local:ceph
83 units: 3
84 to: [nova-compute, nova-compute]
85 mysql:
86+ charm: local:mysql
87 to: 0
88 quantum:
89+ charm: local:quantum
90 units: 4
91 to: ["lxc:nova-compute", "lxc:nova-compute", "lxc:nova-compute", "lxc:nova-compute"]
92 verity:
93+ charm: local:verity
94 to: lxc:nova-compute=2
95 semper:
96+ charm: local:semper
97 to: nova-compute=2
98 lxc-service:
99 # Ensure more than nova-compute, catches lp:1357196
100+ charm: local:lxc-service
101 num_units: 5
102 to: [ "lxc:nova-compute=1", "lxc:nova-compute=2", "lxc:nova-compute=0", "lxc:nova-compute=0", "lxc:nova-compute=2" ]

Subscribers

People subscribed via source and target branches