Merge ~hloeung/ubuntu-repository-cache:fixes into ubuntu-repository-cache:master

Proposed by Haw Loeung
Status: Merged
Approved by: Haw Loeung
Approved revision: d9e23a091137bf97ec8ffb156548e006b96f415c
Merged at revision: d1273c26293afbf503a317372fb7dc8862ab4846
Proposed branch: ~hloeung/ubuntu-repository-cache:fixes
Merge into: ubuntu-repository-cache:master
Diff against target: 58 lines (+16/-24)
1 file modified
lib/ubuntu_repository_cache/apache.py (+16/-24)
Reviewer Review Type Date Requested Status
James Simpson Approve
Canonical IS Reviewers Pending
Review via email: mp+432107@code.launchpad.net

Commit message

Fix to handle cases when datasource is null

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.

Revision history for this message
James Simpson (jsimpso) wrote :

LGTM

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

Change successfully merged at revision d1273c26293afbf503a317372fb7dc8862ab4846

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/ubuntu_repository_cache/apache.py b/lib/ubuntu_repository_cache/apache.py
2index a674370..0ce7cee 100644
3--- a/lib/ubuntu_repository_cache/apache.py
4+++ b/lib/ubuntu_repository_cache/apache.py
5@@ -3,7 +3,6 @@
6 import multiprocessing
7 import os
8 import subprocess
9-import json
10
11 from charmhelpers import fetch
12
13@@ -340,29 +339,22 @@ def update_checks(nrpe_config):
14 '''Update nagios check for apache serving archive metadata'''
15
16 path_base = hookenv.config()['path-base']
17- try:
18- with open('/run/cloud-init/status.json') as status:
19- status_json = json.load(status)
20- except OSError:
21- pass
22- else:
23- # try to find proof we're in Azure
24- # in any version of the status json
25- if any('DataSourceAzure' in x.get('datasource', '') for x in status_json.values()):
26- # In azure, we rely on cloud services
27- # instead of doing our own haproxy work
28- nrpe_config.add_check(
29- shortname='load-balancer',
30- description='e2e check that regional load balancer is functioning',
31- check_cmd=(
32- 'check_http '
33- '--hostname ubuntu-archive-asm.trafficmanager.net '
34- '--url "/{}/" '
35- '--string "dists/" '
36- '--expect 200\\ OK '
37- '--header Accept-Encoding:\\ \\*'
38- ).format(path_base),
39- )
40+
41+ # In azure, we rely on cloud services instead of doing our own
42+ # haproxy work.
43+ if os.path.exists('/run/cloud-init/cloud-id-azure'):
44+ nrpe_config.add_check(
45+ shortname='load-balancer',
46+ description='e2e check that regional load balancer is functioning',
47+ check_cmd=(
48+ 'check_http '
49+ '--hostname ubuntu-archive-asm.trafficmanager.net '
50+ '--url "/{}/" '
51+ '--string "dists/" '
52+ '--expect 200\\ OK '
53+ '--header Accept-Encoding:\\ \\*'
54+ ).format(path_base),
55+ )
56
57 nrpe_config.add_check(
58 shortname='apache',

Subscribers

People subscribed via source and target branches