Merge lp:~psivaa/uci-engine/lander-jenkins-with-proxy into lp:uci-engine/mthood

Proposed by Para Siva
Status: Merged
Approved by: Francis Ginther
Approved revision: 414
Merged at revision: 414
Proposed branch: lp:~psivaa/uci-engine/lander-jenkins-with-proxy
Merge into: lp:uci-engine/mthood
Diff against target: 86 lines (+30/-3)
3 files modified
charms/precise/lander-jenkins/config.yaml (+4/-0)
charms/precise/lander-jenkins/hooks/hooks.py (+24/-2)
juju-deployer/lander.yaml.tmpl (+2/-1)
To merge this branch: bzr merge lp:~psivaa/uci-engine/lander-jenkins-with-proxy
Reviewer Review Type Date Requested Status
Francis Ginther Approve
Andy Doan (community) Approve
Review via email: mp+219894@code.launchpad.net

This proposal supersedes a proposal from 2014-05-09.

Description of the change

Resubmitting with proxy setup to install the plugin and other pkges from the ppa.

Note: For this to work well https://code.launchpad.net/~psivaa/charms/precise/jenkins/bundle-jenkins/+merge/215635 needs merging first

To post a comment you must log in.
Revision history for this message
Francis Ginther (fginther) wrote : Posted in a previous version of this proposal

I don't see how the plugin gets copied from the charm local directory to the jenkins plugin directory (see inline comment).

review: Needs Fixing
Revision history for this message
Para Siva (psivaa) wrote :

Thanks for that catch. Missed it. Was relying more on deploy.py for the install errors. Investigating this also spotted other issues. Hence using proxy to install the plugin from the jenkins-ci.org and to install other pkges from the ppa

414. By Para Siva

Log about proxy only if proxy is available

Revision history for this message
Andy Doan (doanac) :
review: Approve
Revision history for this message
Francis Ginther (fginther) wrote :

I wonder if we can apply this same approach to acquire the debs in the jenkins charm as well... Just something to consider if we need to revisit that charm.

review: Approve
Revision history for this message
Para Siva (psivaa) wrote :

Yes, Thanks. That's in the list to fix. But for now in order to move forward I'm using the debs in the charm version.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'charms/precise/lander-jenkins/config.yaml'
2--- charms/precise/lander-jenkins/config.yaml 2014-03-10 22:25:00 +0000
3+++ charms/precise/lander-jenkins/config.yaml 2014-05-16 19:14:17 +0000
4@@ -64,6 +64,10 @@
5 type: string
6 default: "https://updates.jenkins-ci.org/"
7 description: Site to download plugin .hpi files from.
8+ proxy_url:
9+ type: string
10+ default: ""
11+ description: The http proxy url for private clouds.
12 main:
13 type: string
14 default: ""
15
16=== modified file 'charms/precise/lander-jenkins/hooks/hooks.py'
17--- charms/precise/lander-jenkins/hooks/hooks.py 2014-03-10 22:25:00 +0000
18+++ charms/precise/lander-jenkins/hooks/hooks.py 2014-05-16 19:14:17 +0000
19@@ -160,8 +160,15 @@
20 plugin_file = '{}.hpi'.format(name)
21 juju_info('Installing {} from {}'.format(plugin_file, url))
22 plugin_file = os.path.join(JENKINS_HOME, 'plugins', plugin_file)
23- cmd = ['wget', '-O', plugin_file, url]
24- subprocess.check_call(cmd)
25+
26+ if config['proxy_url']:
27+ cmd = ['https_proxy=%s' % config['proxy_url'], 'wget',
28+ '-O', plugin_file, url]
29+ juju_info('Proxy {} is used'.format(config['proxy_url']))
30+ else:
31+ cmd = ['wget', '-O', plugin_file, url]
32+
33+ subprocess.check_call(cmd, shell=True)
34 cmd = ['chown', '-R', '{}.{}'.format(JENKINS_USER, JENKINS_GROUP),
35 plugin_file]
36 subprocess.check_call(cmd)
37@@ -264,6 +271,9 @@
38
39 def config_changed(config):
40 juju_info("Config: %s" % config)
41+ if config['proxy_url']:
42+ juju_info('Setting up apt with {}'.format(config['proxy_url']))
43+ setup_apt_proxy(config)
44 add_dependencies(config)
45 create_jobs(config)
46 create_user(config)
47@@ -341,6 +351,18 @@
48 })
49
50
51+def setup_apt_proxy(config):
52+ proxy_url = config['proxy_url']
53+ apt_conf = textwrap.dedent("""\
54+ Acquire::http::proxy "%s";
55+ Acquire::https::proxy "%s";
56+ Acquire::HTTP::PROXY "%s";
57+ Acquire::HTTPS::PROXY "%s";
58+ """ % (proxy_url, proxy_url, proxy_url, proxy_url))
59+ with open('/etc/apt/apt.conf.d/95proxies', 'w') as f:
60+ f.write(apt_conf)
61+
62+
63 def amqp_relation_changed(config):
64 with open(os.path.join(_service_dir(config), 'amqp_config.py'), 'w') as f:
65 f.write('# DO NOT EDIT. Generated by lander-jenkins charm hook\n')
66
67=== modified file 'juju-deployer/lander.yaml.tmpl'
68--- juju-deployer/lander.yaml.tmpl 2014-03-14 10:37:28 +0000
69+++ juju-deployer/lander.yaml.tmpl 2014-05-16 19:14:17 +0000
70@@ -21,7 +21,7 @@
71 wsgi_wsgi_file: lander.wsgi:app
72 lander-jenkins:
73 charm: jenkins
74- branch: lp:~ci-engineering-private/charms/precise/jenkins/ci-train@60
75+ branch: lp:~ci-engineering-private/charms/precise/jenkins/mthood@61
76 constraints: "cpu-cores=2 mem=8 root-disk=8192M"
77 exposed: true
78 options:
79@@ -35,6 +35,7 @@
80 vcs: ${CI_CODE_SOURCE}
81 branch: ${CI_BRANCH}
82 tarball: ${CI_PAYLOAD_URL}
83+ proxy_url: ${CI_PRIVATE_HTTP_PROXY}
84 bot_username: lander-bot
85 bot_password: lander-bot
86 sources: ${CI_PPA}

Subscribers

People subscribed via source and target branches