Merge lp:~abentley/charms/precise/juju-reports/stop-on-ssh-source into lp:~juju-qa/charms/precise/juju-reports/trunk

Proposed by Aaron Bentley
Status: Merged
Approved by: Martin Packman
Approved revision: 52
Merged at revision: 51
Proposed branch: lp:~abentley/charms/precise/juju-reports/stop-on-ssh-source
Merge into: lp:~juju-qa/charms/precise/juju-reports/trunk
Diff against target: 57 lines (+12/-5)
1 file modified
hooks/common.py (+12/-5)
To merge this branch: bzr merge lp:~abentley/charms/precise/juju-reports/stop-on-ssh-source
Reviewer Review Type Date Requested Status
Martin Packman (community) Approve
Review via email: mp+248777@code.launchpad.net

Commit message

Fix new deploy problems.

Description of the change

This fixes two issues that were discovered when spinning up the juju-ci4 env.

First, it attempts to use bzr+ssh urls when there's no lp ssh key, causing the unit to error.

Second, it assumes that the mongodb charm will always supply replset, when in fact, the trusty charm supplies replset only when there are more than one units.

This branch changes the charm so that it stops, instead of erroring, when it can't use a bzr+ssh url. It changes the mongodb handling so that uses replset only when supplied.

To post a comment you must log in.
Revision history for this message
Martin Packman (gz) wrote :

Looks good. Wasn't sure about the stop vs error on bzr+ssh but it's clear from the code that's the right thing.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hooks/common.py'
2--- hooks/common.py 2015-01-12 19:11:34 +0000
3+++ hooks/common.py 2015-02-05 15:04:08 +0000
4@@ -138,7 +138,7 @@
5
6 def configure_lp(ssh_key):
7 if ssh_key == '':
8- return
9+ return False
10 with open_secret('/root/.ssh/lp_rsa') as key_file:
11 key_file.write(ssh_key)
12 pwd = getpwnam('ubuntu')
13@@ -147,6 +147,7 @@
14 key_file.write(ssh_key)
15 # Login to LP
16 call_bzr(['lp-login', 'juju-qa-bot'])
17+ return True
18
19
20 def call_bzr(args):
21@@ -238,15 +239,18 @@
22 'hostname' not in relation_data):
23 continue
24 if replset is None:
25- replset = relation_data['replset']
26+ replset = relation_data.get('replset')
27 # All units should be members of the same replication set.
28- elif replset != relation_data['replset']:
29+ if replset is not None and replset != relation_data['replset']:
30 raise AssertionError('DB instances are from different sets!')
31 host_ports.append(
32 '%(hostname)s:%(port)s' % relation_data)
33 if len(host_ports) == 0:
34 return ''
35- return 'mongodb://%s/?replicaSet=%s' % (','.join(host_ports), replset)
36+ replica_str = ''
37+ if replset is not None:
38+ replica_str = '?replicaSet=%s' % replset
39+ return 'mongodb://%s/%s' % (','.join(host_ports), replica_str)
40
41
42 def update_website(ini):
43@@ -315,10 +319,13 @@
44 mongo_url = get_mongo_url()
45 config = hookenv.config()
46 set_port(ini, False)
47- configure_lp(config['lp-key'])
48+ has_lp_key = configure_lp(config['lp-key'])
49 if config['source'] == '':
50 hookenv.log('Incomplete config: source')
51 return
52+ if not has_lp_key and config['source'].startswith('bzr+ssh'):
53+ hookenv.log('Incomplete config: ssh URL but no LP key')
54+ return
55 last_source_url, last_revision = get_last_revision()
56 needs_install_update = (
57 (last_source_url, last_revision) != (config['source'], config['revno'])

Subscribers

People subscribed via source and target branches

to all changes: