Merge lp:~niedbalski/charms/trusty/ceph/update-sysctl-next into lp:~openstack-charmers-archive/charms/trusty/ceph/next

Proposed by Jorge Niedbalski
Status: Superseded
Proposed branch: lp:~niedbalski/charms/trusty/ceph/update-sysctl-next
Merge into: lp:~openstack-charmers-archive/charms/trusty/ceph/next
Diff against target: 142 lines (+82/-1) (has conflicts)
4 files modified
config.yaml (+12/-0)
hooks/charmhelpers/core/sysctl.py (+34/-0)
hooks/hooks.py (+7/-0)
hooks/utils.py (+29/-1)
Text conflict in config.yaml
To merge this branch: bzr merge lp:~niedbalski/charms/trusty/ceph/update-sysctl-next
Reviewer Review Type Date Requested Status
Edward Hope-Morley Approve
Corey Bryant (community) Approve
OpenStack Charmers Pending
Review via email: mp+235624@code.launchpad.net

This proposal supersedes a proposal from 2014-09-22.

This proposal has been superseded by a proposal from 2014-10-07.

Description of the change

- Added a sysctl configuration option for passing ceph specific
runtime flags.
       - Modified config.yaml to expose this option, by default is ""
       - Modified utils.py to add the update_sysctl function

To post a comment you must log in.
Revision history for this message
Edward Hope-Morley (hopem) wrote : Posted in a previous version of this proposal

Few nits inline, othwerwise looks ok.

review: Needs Fixing
Revision history for this message
Edward Hope-Morley (hopem) : Posted in a previous version of this proposal
Revision history for this message
Corey Bryant (corey.bryant) wrote : Posted in a previous version of this proposal

Tested and works good for me. I do have a few comments inline though.

review: Needs Fixing
Revision history for this message
Corey Bryant (corey.bryant) wrote : Posted in a previous version of this proposal

2 more nits from my end. After that I'll approve.

Revision history for this message
Corey Bryant (corey.bryant) : Posted in a previous version of this proposal
review: Needs Fixing
Revision history for this message
Corey Bryant (corey.bryant) :
review: Approve
Revision history for this message
Edward Hope-Morley (hopem) wrote :

LGTM

review: Approve
Revision history for this message
Edward Hope-Morley (hopem) wrote :

@niedbalski this patch will also need to land in the ceph osd charm. Ceph hosts that acting as scale-out for OSDs will not necessarily have the ceph charm installed. The update_sysctl() function should therefore go to charm-helpers.

Unmerged revisions

85. By Jorge Niedbalski

- Moved this logic to charm-helpers for re-usage on ceph-osd

84. By Jorge Niedbalski

Addressed @corey.bryant observations

83. By Jorge Niedbalski

- Updated config.yaml to 'associative array'
- Updated hooks.py for not check on (None, "")
- Updated utils.py for docstrings and debug log

82. By Jorge Niedbalski

- Added update_sysctl util function for pass sysctl.conf values through juju set
  - Added 'sysctl' config entry into the default config.yaml

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 22:07:41 +0000
3+++ config.yaml 2014-10-07 08:46:55 +0000
4@@ -138,6 +138,7 @@
5 The IP address and netmask of the public (front-side) network (e.g.,
6 192.168.0.0/24)
7 ceph-cluster-network:
8+<<<<<<< TREE
9 type: string
10 default:
11 description: |
12@@ -155,3 +156,14 @@
13 order for this charm to function correctly, the privacy extension must be
14 disabled and a non-temporary address must be configured/available on
15 your network interface.
16+=======
17+ type: string
18+ description: |
19+ The IP address and netmask of the cluster (back-side) network (e.g.,
20+ 192.168.0.0/24)
21+ sysctl:
22+ type: string
23+ default: ""
24+ description: |
25+ YAML formatted associative array of sysctl values, e.g.:
26+ '{ kernel.pid_max : 4194303 }'>>>>>>> MERGE-SOURCE
27
28=== added file 'hooks/charmhelpers/core/sysctl.py'
29--- hooks/charmhelpers/core/sysctl.py 1970-01-01 00:00:00 +0000
30+++ hooks/charmhelpers/core/sysctl.py 2014-10-07 08:46:55 +0000
31@@ -0,0 +1,34 @@
32+#!/usr/bin/env python
33+# -*- coding: utf-8 -*-
34+
35+__author__ = 'Jorge Niedbalski R. <jorge.niedbalski@canonical.com>'
36+
37+import yaml
38+
39+from subprocess import check_call
40+
41+from charmhelpers.core.hookenv import (
42+ log,
43+ DEBUG,
44+)
45+
46+
47+def create(sysctl_dict, sysctl_file):
48+ """Creates a sysctl.conf file from a YAML associative array
49+
50+ :param sysctl_dict: a dict of sysctl options eg { 'kernel.max_pid': 1337 }
51+ :type sysctl_dict: dict
52+ :param sysctl_file: path to the sysctl file to be saved
53+ :type sysctl_file: str or unicode
54+ :returns: None
55+ """
56+ sysctl_dict = yaml.load(sysctl_dict)
57+
58+ with open(sysctl_file, "w") as fd:
59+ for key, value in sysctl_dict.items():
60+ fd.write("{}={}\n".format(key, value))
61+
62+ log("Updating sysctl_file: %s values: %s" % (sysctl_file, sysctl_dict),
63+ level=DEBUG)
64+
65+ check_call(["sysctl", "-p", sysctl_file])
66
67=== modified file 'hooks/hooks.py'
68--- hooks/hooks.py 2014-09-30 03:06:10 +0000
69+++ hooks/hooks.py 2014-10-07 08:46:55 +0000
70@@ -38,6 +38,9 @@
71 filter_installed_packages,
72 add_source
73 )
74+
75+from charmhelpers.core.sysctl import create as create_sysctl
76+
77 from charmhelpers.payload.execd import execd_preinstall
78 from charmhelpers.contrib.openstack.alternatives import install_alternative
79 from charmhelpers.contrib.network.ip import (
80@@ -119,6 +122,10 @@
81 log('Invalid OSD disk format configuration specified', level=ERROR)
82 sys.exit(1)
83
84+ sysctl_dict = config('sysctl')
85+ if sysctl_dict:
86+ create_sysctl(sysctl_dict, '/etc/sysctl.d/50-ceph-charm.conf')
87+
88 emit_cephconf()
89
90 e_mountpoint = config('ephemeral-unmount')
91
92=== modified file 'hooks/utils.py'
93--- hooks/utils.py 2014-09-30 03:06:10 +0000
94+++ hooks/utils.py 2014-10-07 08:46:55 +0000
95@@ -9,11 +9,18 @@
96
97 import socket
98 import re
99+import yaml
100+
101+from subprocess import check_call
102+
103 from charmhelpers.core.hookenv import (
104 unit_get,
105 cached,
106- config
107+ config,
108+ log,
109+ DEBUG,
110 )
111+
112 from charmhelpers.fetch import (
113 apt_install,
114 filter_installed_packages
115@@ -45,6 +52,27 @@
116 import dns.resolver
117
118
119+def update_sysctl(sysctl_dict, sysctl_file="/etc/sysctl.d/50-ceph-charm.conf"):
120+ """Creates a sysctl.conf file from a YAML associative array
121+
122+ :param sysctl_dict: a dict of sysctl options eg { 'kernel.max_pid': 1337 }
123+ :type sysctl_dict: dict
124+ :param sysctl_file: path to the sysctl file to be saved
125+ :type sysctl_file: str or unicode
126+ :returns: None
127+ """
128+ sysctl_dict = yaml.load(sysctl_dict)
129+
130+ with open(sysctl_file, "w") as fd:
131+ for key, value in sysctl_dict.items():
132+ fd.write("{}={}\n".format(key, value))
133+
134+ log("Updating sysctl_file: %s values: %s" % (sysctl_file, sysctl_dict),
135+ level=DEBUG)
136+
137+ check_call(["sysctl", "-p", sysctl_file])
138+
139+
140 def render_template(template_name, context, template_dir=TEMPLATES_DIR):
141 templates = jinja2.Environment(
142 loader=jinja2.FileSystemLoader(template_dir))

Subscribers

People subscribed via source and target branches