Skip to content

Commit

Permalink
fix 0 size cache config
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisohaver committed May 3, 2018
1 parent ec96ee0 commit 502784c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 21 deletions.
5 changes: 0 additions & 5 deletions dns/cluster/coredns-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,4 @@ data:
fallthrough in-addr.arpa ip6.arpa
}
prometheus :9153
proxy . /etc/resolv.conf
cache 30 {
success 1000
denial 1000
}
}
13 changes: 8 additions & 5 deletions dns/py/params.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,14 @@ def is_relevant(self, attributes):
return 'cluster-dns' not in attributes

def set(self, inputs, value):
config = inputs.configmap_yaml['data']
config['Corefile'] = re.sub(r'success \d+', 'success ' + repr(value),
config['Corefile'])
config['Corefile'] = re.sub(r'denial \d+', 'denial ' + repr(value),
config['Corefile'])
if value > 0:
cf = inputs.configmap_yaml['data']['Corefile']
cf = re.sub(r'\n', "\n"
" cache {\n"
" success " + repr(value) + "\n"
" denial " + repr(value) + "\n"
" }\n", cf, 1)
inputs.configmap_yaml['data']['Corefile'] = cf

class DnsperfCmdlineParam(Param):
"""
Expand Down
19 changes: 8 additions & 11 deletions dns/py/params_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,17 +123,14 @@ def test_coredns_params(self):
continue
param.set(inputs, values[param.name])

self.assertEquals(
'100m',
inputs.deployment_yaml['spec']['template']['spec']['containers']
[0]['resources']['limits']['cpu'])
self.assertTrue(
"""
cache 30 {
success 200
denial 200
}"""
in inputs.configmap_yaml['data']['Corefile'])
self.assertTrue("success 200"
in inputs.configmap_yaml['data']['Corefile'])
self.assertTrue("denial 200"
in inputs.configmap_yaml['data']['Corefile'])
self.assertEquals(
'100m',
inputs.deployment_yaml['spec']['template']['spec']['containers']
[0]['resources']['limits']['cpu'])

def test_null_params(self):
# These should result in no limits.
Expand Down

0 comments on commit 502784c

Please sign in to comment.