Merge ~hloeung/content-cache-charm:cleanup into content-cache-charm:master

Proposed by Haw Loeung
Status: Merged
Approved by: Haw Loeung
Approved revision: 0c8c5ddb3d503af235f2178e038e0efa23b59f23
Merged at revision: eb6c52390c6809405dabe14d3b435ec3fd293538
Proposed branch: ~hloeung/content-cache-charm:cleanup
Merge into: content-cache-charm:master
Diff against target: 57 lines (+14/-4)
3 files modified
config.yaml (+4/-4)
lib/haproxy.py (+4/-0)
tests/unit/test_haproxy.py (+6/-0)
Reviewer Review Type Date Requested Status
Paul Collins Approve
Canonical IS Reviewers Pending
Review via email: mp+386430@code.launchpad.net

Commit message

Assume 64-bit CPU, set max. threads and processes to 64

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
Paul Collins (pjdc) wrote :

LGTM, observation inline.

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

Change successfully merged at revision eb6c52390c6809405dabe14d3b435ec3fd293538

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/config.yaml b/config.yaml
2index 7030778..03bf2eb 100644
3--- a/config.yaml
4+++ b/config.yaml
5@@ -43,16 +43,16 @@ options:
6 description: >
7 Sets the number of HAProxy processes. If both processs and
8 threads specified and using HAProxy 2.x and above, the number of
9- HAProxy threadsd will be configured using processes multiplied
10- by threads.
11+ HAProxy threads will be configured using processes multiplied
12+ by threads (max. 64).
13 haproxy_threads:
14 default: 0
15 type: int
16 description: >
17 Sets the number of HAProxy threads. If both processs and
18 threads specified and using HAProxy 2.x and above, the number of
19- HAProxy threadsd will be configured using processes multiplied
20- by threads.
21+ HAProxy threads will be configured using processes multiplied
22+ by threads (max. 64).
23 log_retention:
24 type: int
25 default: 30
26diff --git a/lib/haproxy.py b/lib/haproxy.py
27index b21bcb4..02bec57 100644
28--- a/lib/haproxy.py
29+++ b/lib/haproxy.py
30@@ -266,6 +266,10 @@ backend backend-{name}
31 num_procs = 0
32 if not num_threads:
33 num_threads = 0
34+ # Assume 64-bit CPU so limit processes and threads to 64.
35+ # https://discourse.haproxy.org/t/architectural-limitation-for-nbproc/5270
36+ num_procs = min(64, num_procs)
37+ num_threads = min(64, num_threads)
38 return (num_procs, num_threads)
39
40 def render(self, config, num_procs=None, num_threads=None, monitoring_password=None, tls_cipher_suites=None):
41diff --git a/tests/unit/test_haproxy.py b/tests/unit/test_haproxy.py
42index e45d42b..cac29ca 100644
43--- a/tests/unit/test_haproxy.py
44+++ b/tests/unit/test_haproxy.py
45@@ -219,6 +219,12 @@ class TestLibHAProxy(unittest.TestCase):
46 self.assertEqual(haproxy._calculate_num_procs_threads(3, None), (3, 0))
47 self.assertEqual(haproxy._calculate_num_procs_threads(None, None), (0, 4))
48
49+ # Max. threads and procs ceiling 64
50+ package_version.return_value = '2.0.13-2'
51+ self.assertEqual(haproxy._calculate_num_procs_threads(2, 100), (0, 64))
52+ self.assertEqual(haproxy._calculate_num_procs_threads(100, 0), (64, 0))
53+ self.assertEqual(haproxy._calculate_num_procs_threads(100, 100), (0, 64))
54+
55 def test_get_parent_pid(self):
56 haproxy = HAProxy.HAProxyConf(self.tmpdir)
57 self.assertEqual(haproxy.get_parent_pid(pidfile='tests/unit/files/haproxy.pid'), 31337)

Subscribers

People subscribed via source and target branches