Merge lp:~justin-fathomdb/charms/precise/elasticsearch/update-version into lp:~charmers/charms/precise/elasticsearch/trunk

Proposed by justinsb
Status: Merged
Merged at revision: 29
Proposed branch: lp:~justin-fathomdb/charms/precise/elasticsearch/update-version
Merge into: lp:~charmers/charms/precise/elasticsearch/trunk
Diff against target: 202 lines (+59/-32)
6 files modified
config.yaml (+2/-2)
files/charm/services/elasticsearch.conf (+25/-0)
hooks/common.sh (+2/-1)
hooks/install (+17/-24)
hooks/start (+8/-3)
hooks/stop (+5/-2)
To merge this branch: bzr merge lp:~justin-fathomdb/charms/precise/elasticsearch/update-version
Reviewer Review Type Date Requested Status
Charles Butler (community) Approve
Review via email: mp+215696@code.launchpad.net

Description of the change

Update to elasticsearch 1.1.0

Also replace the Java service wrapper with Upstart.

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

Justin,

Thank you for this submitted merge proposal.

I like that you're removed the java service wrapper and placed management of the service under upstart. This is a welcome addition plus the latest version upgrade.

The included amulet tests pass, while basic, provided a quick path to validation.

I'm approving this merge. +1 LGTM

Thanks again!

review: Approve

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-01-21 15:38:51 +0000
3+++ config.yaml 2014-04-14 15:52:45 +0000
4@@ -1,7 +1,7 @@
5 options:
6 version:
7 type: string
8- default: "0.90.3"
9+ default: "1.1.0"
10 description: |
11 This sets the elasticsearch version number that will be used.
12 If you're going to plug in logstash, make sure versions match.
13@@ -39,7 +39,7 @@
14 This sets the s3 bucket name for the elasticsearch s3 gateway.
15 checksum:
16 type: string
17- default: "24843192bee3afd19f5a958800e896153dbc3569"
18+ default: "6518b6f90df21e034b20e9a222b780651a6cdcdb"
19 description: |
20 SHA1 checksum of elasticsearch download.
21 checksumwrapper:
22
23=== removed file 'files/charm/elasticsearch-0.19.10.tar.gz'
24Binary files files/charm/elasticsearch-0.19.10.tar.gz 2012-11-04 04:06:00 +0000 and files/charm/elasticsearch-0.19.10.tar.gz 1970-01-01 00:00:00 +0000 differ
25=== removed file 'files/charm/es-wrapper.tar.gz'
26Binary files files/charm/es-wrapper.tar.gz 2012-11-04 04:06:00 +0000 and files/charm/es-wrapper.tar.gz 1970-01-01 00:00:00 +0000 differ
27=== added directory 'files/charm/services'
28=== added file 'files/charm/services/elasticsearch.conf'
29--- files/charm/services/elasticsearch.conf 1970-01-01 00:00:00 +0000
30+++ files/charm/services/elasticsearch.conf 2014-04-14 15:52:45 +0000
31@@ -0,0 +1,25 @@
32+#!/usr/bin/bash
33+
34+# elasticsearch instance
35+#
36+
37+description "elasticsearch instance"
38+
39+start on virtual-filesystems
40+stop on runlevel [06]
41+
42+respawn
43+respawn limit 5 30
44+env HOME=/opt/elasticsearch
45+
46+# Gives "Incompatible minimum and maximum heap sizes specified"
47+#env JAVA_OPTS='-Xms512m -Xmx512m'
48+
49+chdir /opt/elasticsearch
50+setuid elasticsearch
51+setgid adm
52+console log
53+
54+script
55+ /opt/elasticsearch/bin/elasticsearch
56+end script
57\ No newline at end of file
58
59=== added directory 'files/charm/users'
60=== added file 'files/charm/users/elasticsearch'
61=== modified file 'hooks/common.sh'
62--- hooks/common.sh 2012-11-11 18:34:00 +0000
63+++ hooks/common.sh 2014-04-14 15:52:45 +0000
64@@ -14,4 +14,5 @@
65 ZENMASTERS=$(config-get zenmasters)
66 HOST=`unit-get private-address`
67 HEAP_SIZE=1024 # may need to change this if using small ec2 instance
68-#HEAP_SIZE=`cat /proc/meminfo | grep MemTotal | awk '{print int($2*.5/1000)}'`
69\ No newline at end of file
70+#HEAP_SIZE=`cat /proc/meminfo | grep MemTotal | awk '{print int($2*.5/1000)}'`
71+USER="elasticsearch"
72
73=== modified file 'hooks/install'
74--- hooks/install 2013-09-29 13:21:22 +0000
75+++ hooks/install 2014-04-14 15:52:45 +0000
76@@ -5,10 +5,14 @@
77 HOME=`dirname $0`
78 . $HOME/common.sh
79
80+juju-log "create elasticsearch user"
81+[ -z "$(id ${USER})"] && useradd ${USER}
82+
83 juju-log "Check if we've installed elasticsearch before"
84
85 if [ ! -f "/opt/elasticsearch-$VERSION/bin/elasticsearch" ]; then
86 juju-log "Installing OpenJDK"
87+ apt-get update
88 apt-get install -y default-jre-headless wget curl
89
90 juju-log "Downloading elasticsearch"
91@@ -20,7 +24,7 @@
92 install -o root -g root -m 0644 $HOME/../files/charm/elasticsearch-$VERSION.tar.gz /tmp/elasticsearch-$VERSION.tar.gz
93 else
94 # Download and checksum
95- juju-log "elasticsearch wrapper binary not found local ... download"
96+ juju-log "elasticsearch binary not found local ... download"
97 wget -q -O /tmp/elasticsearch-$VERSION.tar.gz "${DOWNLOADURL}/elasticsearch-$VERSION.tar.gz"
98 if [[ $(sha1sum "/tmp/elasticsearch-$VERSION.tar.gz" | cut -d " " -f 1) != ${CHECKSUM} ]]; then
99 juju-log --log-level CRITICAL "Checksum of elasticsearch-$VERSION.tar.gz failed"
100@@ -28,42 +32,31 @@
101 fi
102 fi
103
104- juju-log "Installing service wrapper"
105- if [ -f $HOME/../files/charm/es-wrapper.tar.gz ]
106- then
107- juju-log "elasticsearch wrapper binary found local"
108- install -o root -g root -m 0644 $HOME/../files/charm/es-wrapper.tar.gz /tmp/es-wrapper.tar.gz
109- else
110- # Download and checksum
111- juju-log "elasticsearch wrapper binary not found local ... download"
112- wget -q -O /tmp/es-wrapper.tar.gz "http://github.com/elasticsearch/elasticsearch-servicewrapper/tarball/master"
113- if [[ $(md5sum "/tmp/es-wrapper.tar.gz" | cut -d " " -f 1) != ${CHECKSUMWRAPPER} ]]; then
114- juju-log --log-level CRITICAL "Checksum of es-wrapper.tar.gz failed"
115- exit 1
116- fi
117- fi
118 juju-log "untar elasticsearch"
119 cd /opt
120 tar xzvf /tmp/elasticsearch-$VERSION.tar.gz
121 ln -s elasticsearch-$VERSION elasticsearch
122 rm /tmp/elasticsearch-$VERSION.tar.gz
123- juju-log "untar elasticsearch service wrapper"
124- tar xzvf /tmp/es-wrapper.tar.gz
125- rm /tmp/es-wrapper.tar.gz
126- mv *servicewrapper*/service elasticsearch/bin/
127- rm -Rf *servicewrapper*
128
129 cd /opt/elasticsearch
130
131 juju-log "Setup elasticsearch as a service"
132- /opt/elasticsearch/bin/service/elasticsearch install
133+ install -o root -g root -m 0644 ${HOME}/../files/charm/services/elasticsearch.conf /etc/init/elasticsearch.conf
134+
135+ # Service wrapper stuff
136+ #sed -i "s/<Path to ElasticSearch Home>/\/opt\/elasticsearch/" bin/service/elasticsearch.conf
137+ #sed -i "s/set\.default\.ES_HEAP_SIZE=.*/set.default.ES_HEAP_SIZE=${HEAP_SIZE}/" bin/service/elasticsearch.conf
138+ #sed -i "s/wrapper.app.parameter.1.*/wrapper.app.parameter.1=$BOOTSTRAP_CLASS/" bin/service/elasticsearch.conf
139
140 juju-log "Update elasticsearch config"
141- sed -i "s/<Path to ElasticSearch Home>/\/opt\/elasticsearch/" bin/service/elasticsearch.conf
142- sed -i "s/set\.default\.ES_HEAP_SIZE=.*/set.default.ES_HEAP_SIZE=${HEAP_SIZE}/" bin/service/elasticsearch.conf
143- sed -i "s/wrapper.app.parameter.1.*/wrapper.app.parameter.1=$BOOTSTRAP_CLASS/" bin/service/elasticsearch.conf
144 sed -i "s/# cluster.name:.*/cluster.name: $CLUSTER_NAME/" config/elasticsearch.yml
145
146+ juju-log "Make sure ${USER} user can write"
147+ mkdir -p /opt/elasticsearch/logs/
148+ chown -R ${USER}. /opt/elasticsearch/logs/
149+ mkdir -p /opt/elasticsearch/data/
150+ chown -R ${USER}. /opt/elasticsearch/data/
151+
152 # If Amazon install some magic stuff to allow auto-discovery of other ES nodes.
153 if [ ! -z "$ACCESS_KEY" ] && [ ! -z "$SECRET_KEY" ]; then
154 juju-log "Install elasticsearch aws plugin"
155
156=== modified file 'hooks/start'
157--- hooks/start 2014-01-23 21:09:52 +0000
158+++ hooks/start 2014-04-14 15:52:45 +0000
159@@ -2,18 +2,23 @@
160 # Here put anything that is needed to start the service.
161 # Note that currently this is run directly after install
162 # i.e. 'service apache2 start'
163+
164 set -eux # -x for verbose logging to juju debug-log
165+
166 HOME=`dirname $0`
167 . $HOME/common.sh
168
169-
170 open-port 9200/tcp
171 open-port 9300/tcp
172-/opt/elasticsearch/bin/service/elasticsearch start
173+
174+juju-log "run elasticsearch"
175+initctl start elasticsearch
176+
177+juju-log "started"
178
179 # load up logstash template.
180 # https://github.com/logstash/logstash/wiki/Elasticsearch-Storage-Optimization
181 # really we should do this as part of the relationship join.
182-juju-log "sleep 10seconds then install logstash template"
183+juju-log "sleep 10 seconds then install logstash template"
184 sleep 10s
185 curl -XPUT 'http://localhost:9200/_template/template_logstash/' -d @${HOME}/../files/charm/logstash-template.json
186
187=== modified file 'hooks/stop'
188--- hooks/stop 2012-11-11 18:34:00 +0000
189+++ hooks/stop 2014-04-14 15:52:45 +0000
190@@ -9,7 +9,10 @@
191 HOME=`dirname $0`
192 . $HOME/common.sh
193
194-
195 #close-port 9200/tcp
196 #close-port 9300/tcp
197-/opt/elasticsearch/bin/service/elasticsearch stop
198+
199+if ( initctl status elasticsearch | grep start ); then
200+ initctl stop elasticsearch
201+fi
202+

Subscribers

People subscribed via source and target branches

to all changes: