Skip to content

Commit 3aa7b9a

Browse files
committed
INTERNAL - Upgrade to zookeeper 3.6.2 and use azul openjdk 16.0.0
1 parent db25d76 commit 3aa7b9a

File tree

7 files changed

+290
-8
lines changed

7 files changed

+290
-8
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ The project is currently alpha. While no breaking API changes are currently plan
2828

2929
### Overview
3030

31-
This operator runs a Zookeeper 3.6.1 cluster, and uses Zookeeper dynamic reconfiguration to handle node membership.
31+
This operator runs a Zookeeper 3.6.2 cluster, and uses Zookeeper dynamic reconfiguration to handle node membership.
3232

3333
The operator itself is built with the [Operator framework](https://github.com/operator-framework/operator-sdk).
3434

charts/zookeeper/values.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
replicas: 3
22

33
image:
4-
repository: pravega/zookeeper
5-
tag: 0.2.9
4+
repository: adobe/zookeeper
5+
tag: 3.6.2-0.2.9-adobe-20210407
66
pullPolicy: IfNotPresent
77

88
domainName:

docker/Dockerfile

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,18 @@
88
# http://www.apache.org/licenses/LICENSE-2.0
99
#
1010

11-
ARG DOCKER_REGISTRY
12-
FROM ${DOCKER_REGISTRY:+$DOCKER_REGISTRY/}openjdk:11-jdk
11+
FROM azul/zulu-openjdk:11
1312
RUN mkdir /zu
1413
COPY zu /zu
1514
WORKDIR /zu
1615
RUN ./gradlew --console=verbose --info shadowJar
1716

18-
FROM ${DOCKER_REGISTRY:+$DOCKER_REGISTRY/}zookeeper:3.6.1
17+
# use forked base zookeeper 3.6.2 docker image
18+
# that runs on azul openjdk 16.0.0
19+
FROM adobe/zookeeper:3.6.2-apache-zk-20210407
1920
COPY bin /usr/local/bin
2021
RUN chmod +x /usr/local/bin/*
2122
COPY --from=0 /zu/build/libs/zu.jar /root/
2223

2324
RUN apt-get -q update && \
24-
apt-get install -y dnsutils curl procps
25+
apt-get install --no-install-recommends -y curl dnsutils procps

docker/zookeeper-image/Dockerfile

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
FROM azul/zulu-openjdk:16.0.0
2+
3+
ENV ZOO_CONF_DIR=/conf \
4+
ZOO_DATA_DIR=/data \
5+
ZOO_DATA_LOG_DIR=/datalog \
6+
ZOO_LOG_DIR=/logs \
7+
ZOO_TICK_TIME=2000 \
8+
ZOO_INIT_LIMIT=5 \
9+
ZOO_SYNC_LIMIT=2 \
10+
ZOO_AUTOPURGE_PURGEINTERVAL=0 \
11+
ZOO_AUTOPURGE_SNAPRETAINCOUNT=3 \
12+
ZOO_MAX_CLIENT_CNXNS=60 \
13+
ZOO_STANDALONE_ENABLED=true \
14+
ZOO_ADMINSERVER_ENABLED=true
15+
16+
# Add a user with an explicit UID/GID and create necessary directories
17+
RUN set -eux; \
18+
groupadd -r zookeeper --gid=1000; \
19+
useradd -r -g zookeeper --uid=1000 zookeeper; \
20+
mkdir -p "$ZOO_DATA_LOG_DIR" "$ZOO_DATA_DIR" "$ZOO_CONF_DIR" "$ZOO_LOG_DIR"; \
21+
chown zookeeper:zookeeper "$ZOO_DATA_LOG_DIR" "$ZOO_DATA_DIR" "$ZOO_CONF_DIR" "$ZOO_LOG_DIR"
22+
23+
# Install required packges
24+
RUN set -eux; \
25+
apt-get update; \
26+
DEBIAN_FRONTEND=noninteractive \
27+
apt-get install -y --no-install-recommends \
28+
ca-certificates \
29+
dirmngr \
30+
gosu \
31+
gnupg \
32+
netcat \
33+
wget; \
34+
rm -rf /var/lib/apt/lists/*; \
35+
# Verify that gosu binary works
36+
gosu nobody true
37+
38+
ARG SHORT_DISTRO_NAME=zookeeper-3.6.2
39+
ARG DISTRO_NAME=apache-zookeeper-3.6.2-bin
40+
41+
# Download Apache Zookeeper, verify its PGP signature, untar and clean up
42+
RUN set -eux; \
43+
ddist() { \
44+
local f="$1"; shift; \
45+
local distFile="$1"; shift; \
46+
local success=; \
47+
local distUrl=; \
48+
for distUrl in \
49+
'https://www.apache.org/dyn/closer.cgi?action=download&filename=' \
50+
https://www-us.apache.org/dist/ \
51+
https://www.apache.org/dist/ \
52+
https://archive.apache.org/dist/ \
53+
; do \
54+
if wget -q -O "$f" "$distUrl$distFile" && [ -s "$f" ]; then \
55+
success=1; \
56+
break; \
57+
fi; \
58+
done; \
59+
[ -n "$success" ]; \
60+
}; \
61+
ddist "$DISTRO_NAME.tar.gz" "zookeeper/$SHORT_DISTRO_NAME/$DISTRO_NAME.tar.gz"; \
62+
ddist "$DISTRO_NAME.tar.gz.asc" "zookeeper/$SHORT_DISTRO_NAME/$DISTRO_NAME.tar.gz.asc"; \
63+
ddist "KEYS" "zookeeper/KEYS"; \
64+
export GNUPGHOME="$(mktemp -d)"; \
65+
gpg --import KEYS; \
66+
gpg --batch --verify "$DISTRO_NAME.tar.gz.asc" "$DISTRO_NAME.tar.gz"; \
67+
tar -zxf "$DISTRO_NAME.tar.gz"; \
68+
mv "$DISTRO_NAME/conf/"* "$ZOO_CONF_DIR"; \
69+
rm -rf "$GNUPGHOME" "KEYS" "$DISTRO_NAME.tar.gz" "$DISTRO_NAME.tar.gz.asc" "$DISTRO_NAME/docs"; \
70+
chown -R zookeeper:zookeeper "/$DISTRO_NAME"
71+
COPY opt/zkEnv.sh $DISTRO_NAME/bin/zkEnv.sh
72+
73+
WORKDIR $DISTRO_NAME
74+
VOLUME ["$ZOO_DATA_DIR", "$ZOO_DATA_LOG_DIR", "$ZOO_LOG_DIR"]
75+
76+
EXPOSE 2181 2888 3888 8080
77+
78+
ENV PATH=$PATH:/$DISTRO_NAME/bin \
79+
ZOOCFGDIR=$ZOO_CONF_DIR
80+
81+
COPY docker-entrypoint.sh /
82+
ENTRYPOINT ["/docker-entrypoint.sh"]
83+
CMD ["zkServer.sh", "start-foreground"]
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
# Allow the container to be started with `--user`
6+
if [[ "$1" = 'zkServer.sh' && "$(id -u)" = '0' ]]; then
7+
chown -R zookeeper "$ZOO_DATA_DIR" "$ZOO_DATA_LOG_DIR" "$ZOO_LOG_DIR" "$ZOO_CONF_DIR"
8+
exec gosu zookeeper "$0" "$@"
9+
fi
10+
11+
# Generate the config only if it doesn't exist
12+
if [[ ! -f "$ZOO_CONF_DIR/zoo.cfg" ]]; then
13+
CONFIG="$ZOO_CONF_DIR/zoo.cfg"
14+
{
15+
echo "dataDir=$ZOO_DATA_DIR"
16+
echo "dataLogDir=$ZOO_DATA_LOG_DIR"
17+
18+
echo "tickTime=$ZOO_TICK_TIME"
19+
echo "initLimit=$ZOO_INIT_LIMIT"
20+
echo "syncLimit=$ZOO_SYNC_LIMIT"
21+
22+
echo "autopurge.snapRetainCount=$ZOO_AUTOPURGE_SNAPRETAINCOUNT"
23+
echo "autopurge.purgeInterval=$ZOO_AUTOPURGE_PURGEINTERVAL"
24+
echo "maxClientCnxns=$ZOO_MAX_CLIENT_CNXNS"
25+
echo "standaloneEnabled=$ZOO_STANDALONE_ENABLED"
26+
echo "admin.enableServer=$ZOO_ADMINSERVER_ENABLED"
27+
} >> "$CONFIG"
28+
if [[ -z $ZOO_SERVERS ]]; then
29+
ZOO_SERVERS="server.1=localhost:2888:3888;2181"
30+
fi
31+
32+
for server in $ZOO_SERVERS; do
33+
echo "$server" >> "$CONFIG"
34+
done
35+
36+
if [[ -n $ZOO_4LW_COMMANDS_WHITELIST ]]; then
37+
echo "4lw.commands.whitelist=$ZOO_4LW_COMMANDS_WHITELIST" >> "$CONFIG"
38+
fi
39+
40+
for cfg_extra_entry in $ZOO_CFG_EXTRA; do
41+
echo "$cfg_extra_entry" >> "$CONFIG"
42+
done
43+
fi
44+
45+
# Write myid only if it doesn't exist
46+
if [[ ! -f "$ZOO_DATA_DIR/myid" ]]; then
47+
echo "${ZOO_MY_ID:-1}" > "$ZOO_DATA_DIR/myid"
48+
fi
49+
50+
exec "$@"
Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
#!/usr/bin/env bash
2+
3+
# Licensed to the Apache Software Foundation (ASF) under one or more
4+
# contributor license agreements. See the NOTICE file distributed with
5+
# this work for additional information regarding copyright ownership.
6+
# The ASF licenses this file to You under the Apache License, Version 2.0
7+
# (the "License"); you may not use this file except in compliance with
8+
# the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
18+
# This script should be sourced into other zookeeper
19+
# scripts to setup the env variables
20+
21+
# We use ZOOCFGDIR if defined,
22+
# otherwise we use /etc/zookeeper
23+
# or the conf directory that is
24+
# a sibling of this script's directory.
25+
# Or you can specify the ZOOCFGDIR using the
26+
# '--config' option in the command line.
27+
28+
ZOOBINDIR="${ZOOBINDIR:-/usr/bin}"
29+
ZOOKEEPER_PREFIX="${ZOOBINDIR}/.."
30+
31+
#check to see if the conf dir is given as an optional argument
32+
if [ $# -gt 1 ]
33+
then
34+
if [ "--config" = "$1" ]
35+
then
36+
shift
37+
confdir=$1
38+
shift
39+
ZOOCFGDIR=$confdir
40+
fi
41+
fi
42+
43+
if [ "x$ZOOCFGDIR" = "x" ]
44+
then
45+
if [ -e "${ZOOKEEPER_PREFIX}/conf" ]; then
46+
ZOOCFGDIR="$ZOOBINDIR/../conf"
47+
else
48+
ZOOCFGDIR="$ZOOBINDIR/../etc/zookeeper"
49+
fi
50+
fi
51+
52+
if [ -f "${ZOOCFGDIR}/zookeeper-env.sh" ]; then
53+
. "${ZOOCFGDIR}/zookeeper-env.sh"
54+
fi
55+
56+
if [ "x$ZOOCFG" = "x" ]
57+
then
58+
ZOOCFG="zoo.cfg"
59+
fi
60+
61+
ZOOCFG="$ZOOCFGDIR/$ZOOCFG"
62+
63+
if [ -f "$ZOOCFGDIR/java.env" ]
64+
then
65+
. "$ZOOCFGDIR/java.env"
66+
fi
67+
68+
if [ "x${ZOO_LOG_DIR}" = "x" ]
69+
then
70+
ZOO_LOG_DIR="$ZOOKEEPER_PREFIX/logs"
71+
fi
72+
73+
if [ "x${ZOO_LOG4J_PROP}" = "x" ]
74+
then
75+
ZOO_LOG4J_PROP="INFO,CONSOLE"
76+
fi
77+
78+
if [[ -n "$JAVA_HOME" ]] && [[ -x "$JAVA_HOME/bin/java" ]]; then
79+
JAVA="$JAVA_HOME/bin/java"
80+
elif type -p java; then
81+
JAVA=java
82+
else
83+
echo "Error: JAVA_HOME is not set and java could not be found in PATH." 1>&2
84+
exit 1
85+
fi
86+
87+
#add the zoocfg dir to classpath
88+
CLASSPATH="$ZOOCFGDIR:$CLASSPATH"
89+
90+
for i in "$ZOOBINDIR"/../zookeeper-server/src/main/resources/lib/*.jar
91+
do
92+
CLASSPATH="$i:$CLASSPATH"
93+
done
94+
95+
#make it work in the binary package
96+
#(use array for LIBPATH to account for spaces within wildcard expansion)
97+
if ls "${ZOOKEEPER_PREFIX}"/share/zookeeper/zookeeper-*.jar > /dev/null 2>&1; then
98+
LIBPATH=("${ZOOKEEPER_PREFIX}"/share/zookeeper/*.jar)
99+
else
100+
#release tarball format
101+
for i in "$ZOOBINDIR"/../zookeeper-*.jar
102+
do
103+
CLASSPATH="$i:$CLASSPATH"
104+
done
105+
LIBPATH=("${ZOOBINDIR}"/../lib/*.jar)
106+
fi
107+
108+
for i in "${LIBPATH[@]}"
109+
do
110+
CLASSPATH="$i:$CLASSPATH"
111+
done
112+
113+
#make it work for developers
114+
for d in "$ZOOBINDIR"/../build/lib/*.jar
115+
do
116+
CLASSPATH="$d:$CLASSPATH"
117+
done
118+
119+
for d in "$ZOOBINDIR"/../zookeeper-server/target/lib/*.jar
120+
do
121+
CLASSPATH="$d:$CLASSPATH"
122+
done
123+
124+
#make it work for developers
125+
CLASSPATH="$ZOOBINDIR/../build/classes:$CLASSPATH"
126+
127+
#make it work for developers
128+
CLASSPATH="$ZOOBINDIR/../zookeeper-server/target/classes:$CLASSPATH"
129+
130+
case "`uname`" in
131+
CYGWIN*|MINGW*) cygwin=true ;;
132+
*) cygwin=false ;;
133+
esac
134+
135+
if $cygwin
136+
then
137+
CLASSPATH=`cygpath -wp "$CLASSPATH"`
138+
fi
139+
140+
#echo "CLASSPATH=$CLASSPATH"
141+
142+
ZK_SERVER_HEAP="-XX:InitialRAMPercentage=30 -XX:MaxRAMPercentage=70 -XX:MinRAMPercentage=70"
143+
ZK_PERF_OPTS="-server --illegal-access=permit -XX:+UseG1GC -XX:MetaspaceSize=96m -XX:G1HeapRegionSize=16M -XX:MinMetaspaceFreeRatio=50 -XX:MaxMetaspaceFreeRatio=80 -XX:MaxGCPauseMillis=20 -XX:InitiatingHeapOccupancyPercent=35 -XX:+ExplicitGCInvokesConcurrent -Djava.awt.headless=true -Dsun.net.inetaddr.ttl=60"
144+
export SERVER_JVMFLAGS="$ZK_SERVER_HEAP $ZK_PERF_OPTS $SERVER_JVMFLAGS"
145+
146+
# default heap for zookeeper client
147+
ZK_CLIENT_HEAP="${ZK_CLIENT_HEAP:-256}"
148+
export CLIENT_JVMFLAGS="-Xmx${ZK_CLIENT_HEAP}m $CLIENT_JVMFLAGS"

docker/zu/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ repositories {
1212

1313
dependencies {
1414
implementation(kotlin("stdlib"))
15-
implementation("org.apache.zookeeper:zookeeper:3.6.1")
15+
implementation("org.apache.zookeeper:zookeeper:3.6.2")
1616
}
1717

1818
tasks.withType<ShadowJar>() {

0 commit comments

Comments
 (0)