Merge ~ubuntu-docker-images/ubuntu-docker-images/+git/cassandra:initial-review into ~ubuntu-docker-images/ubuntu-docker-images/+git/cassandra:main

Proposed by Athos Ribeiro
Status: Merged
Merged at revision: c1ab28277af7506678d651682009b3b8d07cdb86
Proposed branch: ~ubuntu-docker-images/ubuntu-docker-images/+git/cassandra:initial-review
Merge into: ~ubuntu-docker-images/ubuntu-docker-images/+git/cassandra:main
Diff against target: 161 lines (+39/-59)
3 files modified
Dockerfile (+31/-35)
data/cassandra.yaml (+5/-4)
entrypoint.sh (+3/-20)
Reviewer Review Type Date Requested Status
Sergio Durigan Junior Approve
Bryce Harrington Pending
Canonical Server Pending
Review via email: mp+404127@code.launchpad.net

Description of the change

Addressing Sergio's comments from the mailing list review at https://lists.launchpad.net/ubuntu-docker-images/msg00031.html

Two points are not being addressed here

1) Moving all RUN commands from the final build stage into a single RUN command:
This requires changes in the snap (marking the binary file as executable).

2) matching any Java version when setting the JAVA environment variable:
I'd rather explicitly tell what version to use in case the image ends up containing multiple Java versions installed by whatever reason (if this is ever the case, it should be fixed, but we may miss it and and up shipping a container that runs cassandra on an unexpected Java version. WDYT?)

To post a comment you must log in.
Revision history for this message
Athos Ribeiro (athos-ribeiro) wrote :

I forgot to also update the description, as requested in the review (that should be done now).

Moreover, on the CQLVERSION matter: that seems to be specific to the container image used for the sqlsh CLI right?

In their entrypoint, I see they set "export CQLVERSION=${CQLVERSION:-"3.4.4"}".

And in Cassandra cqlsh.py, we have "by default the highest version supported by the server will be used" for the --cqlversion description.

I'd expect the user to use a client compatible with the version of the server being deployed.

I also intend to snap the cqlsh in the future (ship it within the cassandra snap).

Revision history for this message
Sergio Durigan Junior (sergiodj) wrote :

Thanks for the MP, Athos!

It looks great. I'm leaving a few comments about indentation, but otherwise I'm happy with the changes you've made. As for the comments you posted:

1) ACK. I will review the snap change when you put it up, and then we can join the RUN statements.

2) Agreed :-).

3) About the CQLVERSION, I agree that it's specific to the cqlsh image. I was just frustrated that I needed to do some digging in order to figure out why the "docker run" wasn't working. But we can revisit this later if needed.

review: Needs Fixing
Revision history for this message
Athos Ribeiro (athos-ribeiro) wrote :

I merged the RUN, VOLUME, and ENV commands to reduce the number of layers generated here.

Revision history for this message
Sergio Durigan Junior (sergiodj) wrote :

Thanks, Athos. This looks better now :-). There's still the indentation nit to fix, but I think the Dockerfile is great otherwise.

Revision history for this message
Athos Ribeiro (athos-ribeiro) wrote :

Done!

Thanks, Sergio :)

Revision history for this message
Sergio Durigan Junior (sergiodj) wrote :

Thanks, Athos.

This LGTM now (modulo the "curl" command which will obviously need adjustment when you upload the snap).

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/Dockerfile b/Dockerfile
2index d1cf855..ef4d6da 100644
3--- a/Dockerfile
4+++ b/Dockerfile
5@@ -3,35 +3,31 @@
6 # cassandra.yaml logback.xml cassandra-env.sh jvm.options
7 FROM ubuntu:focal AS snap-installer
8
9-RUN apt-get update && \
10- DEBIAN_FRONTEND=noninteractive apt-get dist-upgrade -y && \
11- DEBIAN_FRONTEND=noninteractive apt-get install -y \
12- curl ca-certificates squashfs-tools
13-
14-# taken from https://snapcraft.io/docs/build-on-docker
15-# Alternatively, we can install snapd, and issue `snap download cassandra`
16-RUN curl -L 'https://launchpad.net/~athos-ribeiro/+snap/cassandra-test/+build/1430794/+files/cassandra_4.0-rc1_amd64.snap' --output cassandra.snap
17-
18-RUN mkdir -p /snap && unsquashfs -d /snap/cassandra cassandra.snap
19+RUN set -eux; \
20+ apt-get update && \
21+ DEBIAN_FRONTEND=noninteractive apt-get full-upgrade -y && \
22+ DEBIAN_FRONTEND=noninteractive apt-get install -y \
23+ curl ca-certificates squashfs-tools && \
24+ # taken from https://snapcraft.io/docs/build-on-docker
25+ # Alternatively, we can install snapd, and issue `snap download cassandra`
26+ curl -L 'https://launchpad.net/~athos-ribeiro/+snap/cassandra-test/+build/1437307/+files/cassandra_4.0-rc1_amd64.snap' --output cassandra.snap && \
27+ mkdir -p /snap && unsquashfs -d /snap/cassandra cassandra.snap
28
29
30 FROM ubuntu:focal
31
32 LABEL maintainer="Ubuntu Server team <ubuntu-server@lists.ubuntu.com>"
33
34-ENV TZ UTC
35-
36-ENV CASSANDRA_HOME /usr/share/cassandra
37-ENV STATIC_CONF /etc/cassandra
38-ENV CASSANDRA_CONF /etc/cassandra
39-ENV CASSANDRA_LOG_DIR /var/log/cassandra
40-ENV CASSANDRA_DATA /var/lib/cassandra
41-ENV CLASSPATH $CASSANDRA_CONF
42-ENV CASSANDRA_INCLUDE ""
43-ENV JAVA_VERSION 8
44-ENV cassandra_storagedir "$CASSANDRA_DATA"
45-
46-RUN mkdir -p $CASSANDRA_CONF $CASSANDRA_LOG_DIR $CASSANDRA_DATA
47+ENV TZ=UTC \
48+ CASSANDRA_HOME=/usr/share/cassandra \
49+ STATIC_CONF=/etc/cassandra \
50+ CASSANDRA_CONF=/etc/cassandra \
51+ CASSANDRA_LOG_DIR=/var/log/cassandra \
52+ CASSANDRA_DATA=/var/lib/cassandra \
53+ CASSANDRA_INCLUDE="" \
54+ JAVA_VERSION=8
55+ENV CLASSPATH=$CASSANDRA_CONF \
56+ cassandra_storagedir="$CASSANDRA_DATA"
57
58 COPY --from=snap-installer /snap/cassandra/usr/sbin/cassandra /usr/sbin/cassandra
59 COPY --from=snap-installer /snap/cassandra/usr/share/cassandra /usr/share/cassandra
60@@ -45,32 +41,32 @@ RUN set -eux; \
61 apt-get update; \
62 DEBIAN_FRONTEND=noninteractive apt-get full-upgrade -y; \
63 DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
64- openjdk-8-jre-headless ca-certificates tzdata \
65-# solves warning: "jemalloc shared library could not be preloaded to speed up memory allocations"
66+ openjdk-8-jre-headless ca-certificates tzdata \
67+ # solves warning: "jemalloc shared library could not be preloaded to speed up memory allocations"
68 libjemalloc2 \
69-# "free" is used by cassandra-env.sh
70+ # "free" is used by cassandra-env.sh
71 procps \
72-# "ip" is not required by Cassandra itself, but is commonly used in scripting Cassandra's configuration (since it is so fixated on explicit IP addresses)
73+ # "ip" is not required by Cassandra itself, but is commonly used in scripting Cassandra's configuration (since it is so fixated on explicit IP addresses)
74 iproute2 \
75-# Cassandra will automatically use numactl if available
76-# https://github.com/apache/cassandra/blob/18bcda2d4c2eba7370a0b21f33eed37cb730bbb3/bin/cassandra#L90-L100
77-# https://github.com/apache/cassandra/commit/604c0e87dc67fa65f6904ef9a98a029c9f2f865a
78+ # Cassandra will automatically use numactl if available
79+ # https://github.com/apache/cassandra/blob/18bcda2d4c2eba7370a0b21f33eed37cb730bbb3/bin/cassandra#L90-L100
80+ # https://github.com/apache/cassandra/commit/604c0e87dc67fa65f6904ef9a98a029c9f2f865a
81 numactl \
82- ; \
83+ ; \
84 DEBIAN_FRONTEND=noninteractive apt-get remove --purge --auto-remove -y; \
85 rm -rf /var/lib/apt/lists/*; \
86-# https://issues.apache.org/jira/browse/CASSANDRA-15767 ("bin/cassandra" only looks for "libjemalloc.so" or "libjemalloc.so.1" which doesn't match our "libjemalloc.so.2")
87+ # https://issues.apache.org/jira/browse/CASSANDRA-15767 ("bin/cassandra" only looks for "libjemalloc.so" or "libjemalloc.so.1" which doesn't match our "libjemalloc.so.2")
88 libjemalloc="$(readlink -e /usr/lib/*/libjemalloc.so.2)"; \
89 ln -sT "$libjemalloc" /usr/local/lib/libjemalloc.so; \
90 ldconfig; \
91- chmod +x /usr/sbin/cassandra
92+ mkdir -p $CASSANDRA_CONF $CASSANDRA_LOG_DIR $CASSANDRA_DATA
93
94 ENV JVM_OPTS "$JVM_OPTS -Dcassandra.config=file://$CASSANDRA_CONF/cassandra.yaml"
95
96 COPY entrypoint.sh /usr/local/bin/
97
98-VOLUME /var/lib/cassandra
99-VOLUME /var/log/cassandra
100+VOLUME /var/lib/cassandra \
101+ /var/log/cassandra
102
103 ENTRYPOINT ["entrypoint.sh"]
104 # 7000: intra-node communication
105diff --git a/data/cassandra.yaml b/data/cassandra.yaml
106index 281a5cc..92a0d7b 100644
107--- a/data/cassandra.yaml
108+++ b/data/cassandra.yaml
109@@ -2,10 +2,11 @@ application: Cassandra
110 main: true
111 repo: cassandra
112 description: >
113- Apache Cassandra is a highly-scalable partitioned row store. Rows are organized into tables with a required primary key.
114- [Partitioning](https://cwiki.apache.org/confluence/display/CASSANDRA2/Partitioners) means that Cassandra can distribute your data across multiple machines in an application-transparent matter. Cassandra will automatically repartition as machines are added and removed from the cluster.
115- [Row store](https://cwiki.apache.org/confluence/display/CASSANDRA2/DataModel) means that like relational databases, Cassandra organizes data by rows and columns. The Cassandra Query Language (CQL) is a close relative of SQL.
116- For more information, see the [Apache Cassandra web site](http://cassandra.apache.org/).
117+ Apache Cassandra is an open source NoSQL distributed database trusted by
118+ thousands of companies for scalability and high availability without
119+ compromising performance. Linear scalability and proven fault-tolerance on
120+ commodity hardware or cloud infrastructure make it a good platform for
121+ mission-critical data.
122 version: "4.0-rc1"
123 base: Ubuntu 20.04
124 architectures:
125diff --git a/entrypoint.sh b/entrypoint.sh
126index 5cc4c47..59c947f 100755
127--- a/entrypoint.sh
128+++ b/entrypoint.sh
129@@ -1,29 +1,12 @@
130 #!/bin/bash
131
132-for jar in $SNAP/usr/share/cassandra/lib/*.jar; do
133- CLASSPATH="$CLASSPATH:$jar"
134+for jar in /usr/share/cassandra/lib/*.jar; do
135+ CLASSPATH="$CLASSPATH:$jar"
136 done
137
138 export CLASSPATH
139
140-case $(arch) in
141- x86_64)
142- export ARCH=amd64
143- ;;
144- aarch64)
145- export ARCH=arm64
146- ;;
147- ppc64le)
148- export ARCH=ppc64el
149- ;;
150- s390x)
151- export ARCH=s390x
152- ;;
153- *)
154- echo "Unsupported architecture $(arch)"
155- exit 1
156- ;;
157-esac
158+export ARCH=$(dpkg --print-architecture)
159 export JAVA=/usr/lib/jvm/java-8-openjdk-"$ARCH"/jre/bin/java
160
161 # From upstream entrypoint

Subscribers

People subscribed via source and target branches

to all changes: