Merge lp:~jillrouleau/charms/trusty/swift-storage/sysctl-handling into lp:~openstack-charmers-archive/charms/trusty/swift-storage/trunk

Proposed by Jill Rouleau
Status: Work in progress
Proposed branch: lp:~jillrouleau/charms/trusty/swift-storage/sysctl-handling
Merge into: lp:~openstack-charmers-archive/charms/trusty/swift-storage/trunk
Diff against target: 86 lines (+55/-0)
3 files modified
config.yaml (+12/-0)
hooks/charmhelpers/core/sysctl.py (+34/-0)
hooks/swift_storage_hooks.py (+9/-0)
To merge this branch: bzr merge lp:~jillrouleau/charms/trusty/swift-storage/sysctl-handling
Reviewer Review Type Date Requested Status
OpenStack Charmers Pending
Review via email: mp+240927@code.launchpad.net

Commit message

Adding ability to set a sysctl.d file for extra parameters swift often needs, such as ip_conntrack_max.

Description of the change

Adding ability to set a sysctl.d file for extra parameters swift often needs, such as ip_conntrack_max. Work in progress - generating MP for collaboration review.

To post a comment you must log in.
Revision history for this message
JuanJo Ciarlante (jjo) wrote :

Some 1st pass comments.

53. By Jill Rouleau

Trying to loop thru dict to grab values per feedback lp/~jillrouleau/charms/trusty/swift-storage/sysctl-handling/+merge/240927

Unmerged revisions

53. By Jill Rouleau

Trying to loop thru dict to grab values per feedback lp/~jillrouleau/charms/trusty/swift-storage/sysctl-handling/+merge/240927

52. By Jill Rouleau

Adding yaml options back in, adding addt'l handling

51. By Jill Rouleau

Removing extraneous yaml, will be handled in deploy yaml

50. By Jill Rouleau

Implementing sysctl handling via charmhelpers, adding sysctl.py to bundled charmhelpers

49. By Jill Rouleau

Add options for creating systcl.d file 20-swift-storage.conf

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'config.yaml'
2--- config.yaml 2014-10-06 21:45:39 +0000
3+++ config.yaml 2014-11-07 21:17:08 +0000
4@@ -95,3 +95,15 @@
5 type: int
6 description: |
7 Number of replication workers to spawn.
8+ sysctl_dict:
9+ default: {}
10+ type: dict
11+ description:
12+ YAML-formatted list of sysctl values, e.g.:
13+ '{ net.ipv4.tcp_max_syn_backlog : 65536 }'
14+ sysctl_file:
15+ default: "/etc/sysctl.d/20-swift-storage.conf"
16+ type: string
17+ description:
18+ Location of sysctl.d configuration file
19+
20
21=== added file 'hooks/charmhelpers/core/sysctl.py'
22--- hooks/charmhelpers/core/sysctl.py 1970-01-01 00:00:00 +0000
23+++ hooks/charmhelpers/core/sysctl.py 2014-11-07 21:17:08 +0000
24@@ -0,0 +1,34 @@
25+#!/usr/bin/env python
26+# -*- coding: utf-8 -*-
27+
28+__author__ = 'Jorge Niedbalski R. <jorge.niedbalski@canonical.com>'
29+
30+import yaml
31+
32+from subprocess import check_call
33+
34+from charmhelpers.core.hookenv import (
35+ log,
36+ DEBUG,
37+)
38+
39+
40+def create(sysctl_dict, sysctl_file):
41+ """Creates a sysctl.conf file from a YAML associative array
42+
43+ :param sysctl_dict: a dict of sysctl options eg { 'kernel.max_pid': 1337 }
44+ :type sysctl_dict: dict
45+ :param sysctl_file: path to the sysctl file to be saved
46+ :type sysctl_file: str or unicode
47+ :returns: None
48+ """
49+ sysctl_dict = yaml.load(sysctl_dict)
50+
51+ with open(sysctl_file, "w") as fd:
52+ for key, value in sysctl_dict.items():
53+ fd.write("{}={}\n".format(key, value))
54+
55+ log("Updating sysctl_file: %s values: %s" % (sysctl_file, sysctl_dict),
56+ level=DEBUG)
57+
58+ check_call(["sysctl", "-p", sysctl_file])
59\ No newline at end of file
60
61=== modified file 'hooks/swift_storage_hooks.py'
62--- hooks/swift_storage_hooks.py 2014-10-07 08:37:20 +0000
63+++ hooks/swift_storage_hooks.py 2014-11-07 21:17:08 +0000
64@@ -40,6 +40,8 @@
65 get_ipv6_addr
66 )
67
68+from charmhelpers.core.sysctl import create as sysctl_create
69+
70 hooks = Hooks()
71 CONFIGS = register_configs()
72
73@@ -65,6 +67,13 @@
74 CONFIGS.write_all()
75 save_script_rc()
76
77+ try:
78+ config.get('sysctl_dict', 'sysctl_file')
79+ for key, value in sysctl_dict.iteritems():
80+ sysctl_create()
81+ except NameError:
82+ pass
83+
84
85 @hooks.hook('upgrade-charm')
86 def upgrade_charm():

Subscribers

People subscribed via source and target branches