Browse Source

Added gc_threshold overrides to sysctl.conf

When clouds have a large number of hosts, the default size of the ARP
cache is too small. The cache can overflow, which means that the
system has no way to reach some ip addresses.

Setting the threshold limits higher addresses the situation, in a
reasonably safe way (the maximum impact is 5MB or so of additional RAM
used). Docs on ARP at http://man7.org/linux/man-pages/man7/arp.7.html,
and more discussion of the issue in the bug.

Change-Id: Iaf8382ee0b42e1444cfea589bb05a687cd0c23fa
Closes-Bug: 1780348
changes/84/639984/1
Pete Vander Giessen 7 months ago
parent
commit
c9a19c4077
3 changed files with 14 additions and 20 deletions
  1. 10
    1
      config.yaml
  2. 1
    6
      hooks/nova_compute_hooks.py
  3. 3
    13
      unit_tests/test_nova_compute_hooks.py

+ 10
- 1
config.yaml View File

@@ -379,7 +379,16 @@ options:
379 379
   # Other config
380 380
   sysctl:
381 381
     type: string
382
-    default:
382
+    default: |
383
+      { vm.swappiness : 1,
384
+        net.ipv4.neigh.default.gc_thresh1 : 128,
385
+        net.ipv4.neigh.default.gc_thresh2 : 28672,
386
+        net.ipv4.neigh.default.gc_thresh3 : 32768,
387
+        net.ipv6.neigh.default.gc_thresh1 : 128,
388
+        net.ipv6.neigh.default.gc_thresh2 : 28672,
389
+        net.ipv6.neigh.default.gc_thresh3 : 32768,
390
+        net.nf_conntrack_max : 1000000,
391
+        net.netfilter.nf_conntrack_max : 1000000 }
383 392
     description: |
384 393
       YAML formatted associative array of sysctl values, e.g.:
385 394
       '{ kernel.pid_max : 4194303 }'

+ 1
- 6
hooks/nova_compute_hooks.py View File

@@ -19,13 +19,11 @@ import json
19 19
 import platform
20 20
 import sys
21 21
 import uuid
22
-import yaml
23 22
 import os
24 23
 import subprocess
25 24
 import grp
26 25
 import shutil
27 26
 
28
-
29 27
 import charmhelpers.core.unitdata as unitdata
30 28
 
31 29
 from charmhelpers.core.hookenv import (
@@ -184,10 +182,7 @@ def config_changed():
184 182
 
185 183
     sysctl_settings = config('sysctl')
186 184
     if sysctl_settings:
187
-        sysctl_dict = yaml.safe_load(sysctl_settings)
188
-        sysctl_dict['vm.swappiness'] = sysctl_dict.get('vm.swappiness', 1)
189
-        create_sysctl(yaml.dump(sysctl_dict),
190
-                      '/etc/sysctl.d/50-nova-compute.conf')
185
+        create_sysctl(sysctl_settings, '/etc/sysctl.d/50-nova-compute.conf')
191 186
 
192 187
     remove_libvirt_network('default')
193 188
 

+ 3
- 13
unit_tests/test_nova_compute_hooks.py View File

@@ -215,21 +215,11 @@ class NovaComputeRelationsTests(CharmTestCase):
215 215
         self.migration_enabled.return_value = False
216 216
         self.test_config.set(
217 217
             'sysctl',
218
-            '{ kernel.max_pid : "1337", vm.swappiness : 10 }')
219
-        hooks.config_changed()
220
-        self.create_sysctl.assert_called_with(
221
-            "{kernel.max_pid: '1337', vm.swappiness: 10}\n",
222
-            '/etc/sysctl.d/50-nova-compute.conf')
223
-
224
-    @patch.object(hooks, 'compute_joined')
225
-    def test_config_changed_with_sysctl_swappy_default(self, compute_joined):
226
-        self.test_config.set(
227
-            'sysctl',
228
-            '{ kernel.max_pid : "1337" }')
229
-        self.migration_enabled.return_value = False
218
+            '{foo : bar}'
219
+        )
230 220
         hooks.config_changed()
231 221
         self.create_sysctl.assert_called_with(
232
-            "{kernel.max_pid: '1337', vm.swappiness: 1}\n",
222
+            '{foo : bar}',
233 223
             '/etc/sysctl.d/50-nova-compute.conf')
234 224
 
235 225
     @patch.object(hooks, 'compute_joined')

Loading…
Cancel
Save