From c9a19c40777ea40d64c22070c1346c14708fabdf Mon Sep 17 00:00:00 2001 From: Pete Vander Giessen Date: Wed, 27 Feb 2019 15:50:05 +0100 Subject: [PATCH] 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 --- config.yaml | 11 ++++++++++- hooks/nova_compute_hooks.py | 7 +------ unit_tests/test_nova_compute_hooks.py | 16 +++------------- 3 files changed, 14 insertions(+), 20 deletions(-) diff --git a/config.yaml b/config.yaml index 4ba87e1c..5c634c3a 100644 --- a/config.yaml +++ b/config.yaml @@ -379,7 +379,16 @@ options: # Other config sysctl: type: string - default: + default: | + { vm.swappiness : 1, + net.ipv4.neigh.default.gc_thresh1 : 128, + net.ipv4.neigh.default.gc_thresh2 : 28672, + net.ipv4.neigh.default.gc_thresh3 : 32768, + net.ipv6.neigh.default.gc_thresh1 : 128, + net.ipv6.neigh.default.gc_thresh2 : 28672, + net.ipv6.neigh.default.gc_thresh3 : 32768, + net.nf_conntrack_max : 1000000, + net.netfilter.nf_conntrack_max : 1000000 } description: | YAML formatted associative array of sysctl values, e.g.: '{ kernel.pid_max : 4194303 }' diff --git a/hooks/nova_compute_hooks.py b/hooks/nova_compute_hooks.py index 70e817af..620a73cf 100755 --- a/hooks/nova_compute_hooks.py +++ b/hooks/nova_compute_hooks.py @@ -19,13 +19,11 @@ import json import platform import sys import uuid -import yaml import os import subprocess import grp import shutil - import charmhelpers.core.unitdata as unitdata from charmhelpers.core.hookenv import ( @@ -184,10 +182,7 @@ def config_changed(): sysctl_settings = config('sysctl') if sysctl_settings: - sysctl_dict = yaml.safe_load(sysctl_settings) - sysctl_dict['vm.swappiness'] = sysctl_dict.get('vm.swappiness', 1) - create_sysctl(yaml.dump(sysctl_dict), - '/etc/sysctl.d/50-nova-compute.conf') + create_sysctl(sysctl_settings, '/etc/sysctl.d/50-nova-compute.conf') remove_libvirt_network('default') diff --git a/unit_tests/test_nova_compute_hooks.py b/unit_tests/test_nova_compute_hooks.py index ff06ac54..1f46f974 100644 --- a/unit_tests/test_nova_compute_hooks.py +++ b/unit_tests/test_nova_compute_hooks.py @@ -215,21 +215,11 @@ class NovaComputeRelationsTests(CharmTestCase): self.migration_enabled.return_value = False self.test_config.set( 'sysctl', - '{ kernel.max_pid : "1337", vm.swappiness : 10 }') + '{foo : bar}' + ) hooks.config_changed() self.create_sysctl.assert_called_with( - "{kernel.max_pid: '1337', vm.swappiness: 10}\n", - '/etc/sysctl.d/50-nova-compute.conf') - - @patch.object(hooks, 'compute_joined') - def test_config_changed_with_sysctl_swappy_default(self, compute_joined): - self.test_config.set( - 'sysctl', - '{ kernel.max_pid : "1337" }') - self.migration_enabled.return_value = False - hooks.config_changed() - self.create_sysctl.assert_called_with( - "{kernel.max_pid: '1337', vm.swappiness: 1}\n", + '{foo : bar}', '/etc/sysctl.d/50-nova-compute.conf') @patch.object(hooks, 'compute_joined')