Merge lp:~celebdor/charms/precise/cassandra/hostname_resolve into lp:charms/cassandra

Proposed by Antoni Segura Puimedon on 2015-04-22
Status: Merged
Approved by: Matt Bruzek on 2015-07-22
Approved revision: 42
Merged at revision: 39
Proposed branch: lp:~celebdor/charms/precise/cassandra/hostname_resolve
Merge into: lp:charms/cassandra
Diff against target: 64 lines (+22/-1)
2 files modified
config.yaml (+5/-0)
hooks/cassandra-common (+17/-1)
To merge this branch: bzr merge lp:~celebdor/charms/precise/cassandra/hostname_resolve
Reviewer Review Type Date Requested Status
Matt Bruzek (community) 2015-07-07 Approve on 2015-07-22
Charles Butler 2015-04-22 Pending
Review via email: mp+257120@code.launchpad.net

Description of the Change

see commit msg.

To post a comment you must log in.
Matt Bruzek (mbruzek) wrote :

Hello Antoni,

Thank you for submitting this fix. It is my understanding this fix allows cassandra to be installed on LXC.

The code adds a configuration option that is only evaluated at install time. If the customer were to change the package_version after install the operation would have no effect. This is what we call "immutable configuration". This is because "config-changed" is the only hook called when the Juju user changes the configuration in the GUI or on the command line.

If you are going to add a configuration option like this I would like to see the configuration option read and reacted in the "configure_cassandra" function of the hooks/cassandra-common file.

You can keep the code in the "install" function but need to add it to something that will be called on "config-changed".

Please let me know when you are ready for another review.

Thanks!

review: Needs Fixing
Matt Bruzek (mbruzek) wrote :

I can confirm that deploying with the following configuration created a precise with cassandra version 2.0.10 installed.

cassandra:
   allow-single-node: True
   cluster-name: midonet
   apt-repo-spec: "deb http://debian.datastax.com/community stable main"
   apt-repo-key: "7E41C00F85BFC1706C4FFFB3350200F2B999A372"
   extra_packages: "openjdk-7-jre-headless dsc20=2.0.10-1"
   package_version: "2.0.10"

+1 LGTM

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-10-23 17:35:45 +0000
3+++ config.yaml 2015-07-22 15:24:06 +0000
4@@ -202,6 +202,11 @@
5 default: ""
6 description: |
7 Extra packages to install. A space delimited list of packages.
8+ package_version:
9+ type: string
10+ default: ""
11+ description: |
12+ Force specific version of the cassandra package.
13 partitioner:
14 default: "org.apache.cassandra.dht.RandomPartitioner"
15 type: string
16
17=== modified file 'hooks/cassandra-common'
18--- hooks/cassandra-common 2014-07-10 13:30:43 +0000
19+++ hooks/cassandra-common 2015-07-22 15:24:06 +0000
20@@ -74,11 +74,15 @@
21 # Install cassandra source and install packages
22 install_cassandra () {
23 juju-log "Installing Cassandra"
24+ # Make sure that the hostname loopback resolution is set
25+ grep "$(hostname)" /etc/hosts > /dev/null || echo "127.0.1.1 $(cat /etc/hostname)" >> /etc/hosts
26+
27 # Install the repository
28 APT_REPO_SPEC="$(config-get apt-repo-spec)"
29 APT_REPO_KEY=$(config-get apt-repo-key)
30 # Check for configured extra packages to install from config
31 EXTRA_PACKAGES="$(config-get extra_packages)"
32+ PACKAGE_VERSION="$(config-get package_version)"
33 # Get the debian package in the files directory.
34 DEBIAN_PACKAGE_FILE=($CHARM_DIR/files/cassandra_*.deb)
35 # Does the debain cassandra package exist in the charm directory?
36@@ -103,8 +107,14 @@
37 apt-get update
38 # Ensure that cassandra does not startup before we have configured it
39 disable_cassandra_start
40+
41 # Install the package
42- DEBIAN_FRONTEND=noninteractive apt-get -qq install -y cassandra python-cheetah dnsutils bzr ${EXTRA_PACKAGES}
43+ if [[ "$PACKAGE_VERSION" != "" ]]; then
44+ DEBIAN_FRONTEND=noninteractive apt-get -qq install -y cassandra=${PACKAGE_VERSION} python-cheetah dnsutils bzr ${EXTRA_PACKAGES}
45+ DEBIAN_FRONTEND=noninteractive apt-mark -qq hold dsc20 cassandra
46+ else
47+ DEBIAN_FRONTEND=noninteractive apt-get -qq install -y cassandra python-cheetah dnsutils bzr ${EXTRA_PACKAGES}
48+ fi
49 fi
50 bzr_ci || :
51 }
52@@ -663,6 +673,12 @@
53 ;;
54 config-changed)
55 needs_restart=
56+ CASSANDRA_VERSION=`dpkg -s cassandra | grep Version | cut -f2 -d' '`
57+ PACKAGE_VERSION="$(config-get package_version)"
58+ if [[ "$PACKAGE_VERSION" != "" && "$PACKAGE_VERSION" != "$CASSANDRA_VERSION" ]]; then
59+ DEBIAN_FRONTEND=noninteractive apt-get -qq remove cassandra
60+ install_cassandra
61+ fi
62 # Update the cassandra environment with the appropriate JMX port
63 configure_jmx_port
64 bzr_ci && needs_restart=:

Subscribers

People subscribed via source and target branches