Merge lp:~james-sapara/charms/precise/redis-master/config-options into lp:charms/redis-master

Proposed by James Sapara
Status: Work in progress
Proposed branch: lp:~james-sapara/charms/precise/redis-master/config-options
Merge into: lp:charms/redis-master
Diff against target: 144 lines (+88/-4)
6 files modified
config.yaml (+34/-0)
hooks/config-changed (+48/-0)
hooks/install (+2/-1)
hooks/redis-admin-relation-joined (+1/-0)
hooks/redis-master-relation-joined (+2/-2)
revision (+1/-1)
To merge this branch: bzr merge lp:~james-sapara/charms/precise/redis-master/config-options
Reviewer Review Type Date Requested Status
Marco Ceppi (community) Needs Fixing
Charles Butler (community) Needs Fixing
Review via email: mp+200732@code.launchpad.net

Description of the change

Ability to configure some options in redis which are important for more persistant/reliable data setups.
- port is not configurable, some security/firewall setups work better with control over the port.
- requirepass can be set, enabling a small layer of security. hardly perfect, but better than nothing.
- appendonly can be set to yes or no, to control how redis writes out its logs for replay.
- appendfsync can be set to eversec, no, always to control when it flushes writes

Basically, the default can result in minutes of lost data, which is not a big deal in a cache or LRU setting. Some use cases require a bit more reliability and persistence (token buckets, aggregate metrics, etc). These settings allow you to configure redis to more frequently fsync data, and recover from loss of power/segfault/etc.

If accepted, I can update redis-slave to match functionality.

To post a comment you must log in.
Revision history for this message
Charles Butler (lazypower) wrote :

Greetings James,

I reviewed your changes and attached a bug to the MP to track progress. Please feel free to follow up if you have any questions about the review.

https://bugs.launchpad.net/charms/+bug/1274196

All the best

review: Needs Fixing
Revision history for this message
Marco Ceppi (marcoceppi) wrote :

Marking Needs Fixing to remove from queue.

When ready for another review, select "Request another review" and request one from "charmers"

review: Needs Fixing
Revision history for this message
Marco Ceppi (marcoceppi) wrote :

When ready for another review please move this item from Work in progress to Needs review. If it's no longer applicable please move to Rejected

Unmerged revisions

9. By James Sapara

Added some configurability to allow configuring redis for a more persistant/reliable use case.
- config options for port, requirepass, ppendonly and appendfsync (ease to add more)
- pass along the requirepass to master-relations

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'config.yaml'
2--- config.yaml 1970-01-01 00:00:00 +0000
3+++ config.yaml 2014-01-07 20:11:16 +0000
4@@ -0,0 +1,34 @@
5+options:
6+ port:
7+ type: int
8+ default: 6379
9+ description: Port to bind redis on
10+
11+ requirepass:
12+ type: string
13+ default: ''
14+ description: |
15+ Require clients to issue AUTH <PASSWORD> before processing any other
16+ commands. This might be useful in environments in which you do not trust
17+ others with access to the host running redis-server.
18+
19+ appendonly:
20+ type: string
21+ default: 'no'
22+ description: |
23+ By default Redis asynchronously dumps the dataset on disk. This mode is
24+ good enough in many applications, but an issue with the Redis process or
25+ a power outage may result into a few minutes of writes lost (depending on
26+ the configured save points).
27+
28+ appendfsync:
29+ type: string
30+ default: 'everysec'
31+ description: |
32+ The default is "everysec", as that's usually the right compromise between
33+ speed and data safety. It's up to you to understand if you can relax this to
34+ "no" that will let the operating system flush the output buffer when
35+ it wants, for better performances (but if you can live with the idea of
36+ some data loss consider the default persistence mode that's snapshotting),
37+ or on the contrary, use "always" that's very slow but a bit safer than
38+ everysec.
39
40=== added file 'hooks/config-changed'
41--- hooks/config-changed 1970-01-01 00:00:00 +0000
42+++ hooks/config-changed 2014-01-07 20:11:16 +0000
43@@ -0,0 +1,48 @@
44+#!/bin/bash
45+
46+############################################################################################################
47+# Set debugging
48+############################################################################################################
49+
50+set -ux
51+
52+############################################################################################################
53+# Set Port
54+############################################################################################################
55+
56+PORT=`config-get port`
57+open-port "${PORT}/TCP"
58+sed -i.bak -e "s/^port.*/port ${PORT}/" /etc/redis/redis.conf
59+
60+############################################################################################################
61+# Require Pass
62+############################################################################################################
63+
64+PASSWORD=`config-get requirepass`
65+if [ "${PASSWORD}" = "" ]; then
66+ sed -i.bak -e "s/^requirepass.*/requirepass ${PASSWORD}/" /etc/redis/redis.conf
67+else
68+ sed -i.bak -e "s/^requirepass.*//" /etc/redis/redis.conf
69+fi
70+
71+############################################################################################################
72+# Set appendonly
73+############################################################################################################
74+
75+APPENDONLY=`config-get appendonly`
76+if [ "${APPENDONLY}" = 'yes' -o "${APPENDONLY}" = 'no' ]; then
77+ sed -i.bak -e "s/^appendonly.*/appendonly ${APPENDONLY}/" /etc/redis/redis.conf
78+else
79+ juju-log "appendonly: ${APPENDONLY} is not valid. Valid options are yes|no"
80+fi
81+
82+############################################################################################################
83+# Set appendfsync
84+############################################################################################################
85+
86+APPENDFSYNC=`config-get appendfsync`
87+if [ "${APPENDFSYNC}" = 'everysec' -o "${APPENDFSYNC}" = 'no' -o "${APPENDFSYNC}" = 'always' ]; then
88+ sed -i.bak -e "s/^appendfsync.*/appendfsync ${APPENDFSYNC}/" /etc/redis/redis.conf
89+else
90+ juju-log "appendfsync: ${APPENDFSYNC} is not valid. Valid options are everysec|no|always"
91+fi
92
93=== modified file 'hooks/install'
94--- hooks/install 2013-07-31 12:40:38 +0000
95+++ hooks/install 2014-01-07 20:11:16 +0000
96@@ -17,6 +17,7 @@
97 ############################################################################################################
98
99 MY_HOSTNAME=`unit-get public-address`
100+PORT=`config-get port`
101
102 ############################################################################################################
103 # Modify the redis-server configuration file
104@@ -28,4 +29,4 @@
105 # Open the necessary ports
106 ############################################################################################################
107
108-open-port 6379/TCP
109+open-port "${PORT}/TCP"
110
111=== modified file 'hooks/redis-admin-relation-joined'
112--- hooks/redis-admin-relation-joined 2013-02-08 07:36:22 +0000
113+++ hooks/redis-admin-relation-joined 2014-01-07 20:11:16 +0000
114@@ -20,3 +20,4 @@
115
116 echo $JUJU_REMOTE_UNIT joined
117
118+
119
120=== modified file 'hooks/redis-master-relation-joined'
121--- hooks/redis-master-relation-joined 2013-02-08 07:36:22 +0000
122+++ hooks/redis-master-relation-joined 2014-01-07 20:11:16 +0000
123@@ -12,12 +12,12 @@
124
125 MY_HOSTNAME=`unit-get public-address`
126 MY_PORT="6379"
127+REQUIREDPASS=`unit-get requiredpass`
128
129 ############################################################################################################
130 # Set the hostname in the relation so it can be picked up by the _other_ side
131 ############################################################################################################
132
133-relation-set hostname="${MY_HOSTNAME}" port="${MY_PORT}"
134+relation-set hostname="${MY_HOSTNAME}" port="${MY_PORT}" requiredpass="${REQUIREDPASS}"
135
136 echo $JUJU_REMOTE_UNIT joined
137-
138
139=== modified file 'revision'
140--- revision 2011-10-13 08:12:21 +0000
141+++ revision 2014-01-07 20:11:16 +0000
142@@ -1,1 +1,1 @@
143-2
144+5

Subscribers

People subscribed via source and target branches

to all changes: