Merge lp:~hloeung/ubuntu-repository-cache/health-check-flush-output-buffers into lp:ubuntu-repository-cache

Proposed by Haw Loeung
Status: Merged
Approved by: Haw Loeung
Approved revision: 322
Merged at revision: 323
Proposed branch: lp:~hloeung/ubuntu-repository-cache/health-check-flush-output-buffers
Merge into: lp:ubuntu-repository-cache
Diff against target: 31 lines (+6/-2)
1 file modified
files/health_check.py (+6/-2)
To merge this branch: bzr merge lp:~hloeung/ubuntu-repository-cache/health-check-flush-output-buffers
Reviewer Review Type Date Requested Status
David Lawson (community) Approve
Canonical IS Reviewers Pending
Review via email: mp+399129@code.launchpad.net

Commit message

Avoid holding up connection/request based on sending metrics and flush buffers - LP:1917317

To post a comment you must log in.
Revision history for this message
David Lawson (deej) wrote :

LGTM

review: Approve
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
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

Change successfully merged at revision 323

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'files/health_check.py'
2--- files/health_check.py 2021-03-03 22:57:07 +0000
3+++ files/health_check.py 2021-03-03 23:03:25 +0000
4@@ -75,7 +75,7 @@
5 print('Status: 503 Service Unavailable')
6 print('Content-type: text/html\n')
7 disabled_time = os.stat(disabled_flag).st_mtime
8- print('Currently disabled for maintenance since {}'.format(time.ctime(int(disabled_time))))
9+ print('Currently disabled for maintenance since {}'.format(time.ctime(int(disabled_time))), flush=True)
10 logging.info('DISABLED since {:.3f}'.format(disabled_time))
11 # Rather than 0 here, we want to make maintenance/disabled
12 # units stand out a little in the grafana graphs, so 5.03s with
13@@ -89,7 +89,7 @@
14 if not os.path.exists(os.path.join(apache_root, 'data', 'ubuntu_active')):
15 print('Status: 503 Service Unavailable')
16 print('Content-type: text/html\n')
17- print('Currently provisioning or missing metadata')
18+ print('Currently provisioning or missing metadata', flush=True)
19 logging.warning('DISABLED ubuntu_active missing')
20 # Rather than 0 here, we want to make disabled units stand out
21 # a little in the grafana graphs, so 4.04s with the average
22@@ -154,6 +154,10 @@
23 labels = 'url={},status=SUCCESS,status_code={}'.format(url, status_code)
24 metrics.append(render_influx(METRIC_NAME, labels, duration))
25
26+ # Flush the buffer to ensure we're not holding up
27+ # request/connection on sending metrics to influx.
28+ print('', flush=True)
29+
30 for metric in metrics:
31 send_to_influx(metric)
32

Subscribers

People subscribed via source and target branches