You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@zeppelin.apache.org by al...@apache.org on 2020/04/17 07:42:55 UTC
[zeppelin] branch master updated: [ZEPPELIN-4757] Fix startup
script errors/warnings
This is an automated email from the ASF dual-hosted git repository.
alexott pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/zeppelin.git
The following commit(s) were added to refs/heads/master by this push:
new b877e38 [ZEPPELIN-4757] Fix startup script errors/warnings
b877e38 is described below
commit b877e3877ec73dccfe969004d0f80e2e73ef21fa
Author: Alex Ott <al...@apache.org>
AuthorDate: Wed Apr 15 09:13:03 2020 +0200
[ZEPPELIN-4757] Fix startup script errors/warnings
### What is this PR for?
Errors & warnings are produced from the checks that are assuming that Zeppelin is running
on Linux (`getent` is present) & in the container environment (`/etc/passwd` is
writable).
This patch fixes following:
- added check for presence of the `getent`
- added explicit check that script is running in the container by checking
`/proc/self/cgroup`
- also removed `MaxPermSize` JVM flag that isn't supported in Java 8
### What type of PR is it?
Bug Fix
### What is the Jira issue?
* ZEPPELIN-4757
### How should this be tested?
* https://travis-ci.org/github/alexott/zeppelin/builds/675356068
Author: Alex Ott <al...@apache.org>
Closes #3735 from alexott/ZEPPELIN-4757 and squashes the following commits:
ee1475aef [Alex Ott] [ZEPPELIN-4757] Fix startup script errors/warnings
---
bin/common.cmd | 4 ++--
bin/common.sh | 4 ++--
bin/interpreter.sh | 23 +++++++++++++++++++++++
bin/zeppelin.sh | 50 ++++++++++++++++++++++++++++++++------------------
4 files changed, 59 insertions(+), 22 deletions(-)
diff --git a/bin/common.cmd b/bin/common.cmd
index 13f33e5..0ddbad8 100644
--- a/bin/common.cmd
+++ b/bin/common.cmd
@@ -58,11 +58,11 @@ if not defined ZEPPELIN_ENCODING (
)
if not defined ZEPPELIN_MEM (
- set ZEPPELIN_MEM=-Xms1024m -Xmx1024m -XX:MaxPermSize=512m
+ set ZEPPELIN_MEM=-Xms1024m -Xmx1024m
)
if not defined ZEPPELIN_INTP_MEM (
- set ZEPPELIN_INTP_MEM=-Xms1024m -Xmx1024m -XX:MaxPermSize=512m
+ set ZEPPELIN_INTP_MEM=-Xms1024m -Xmx1024m
)
if not defined ZEPPELIN_JAVA_OPTS (
diff --git a/bin/common.sh b/bin/common.sh
index 4e86ce9..c9b01dd 100644
--- a/bin/common.sh
+++ b/bin/common.sh
@@ -118,11 +118,11 @@ if [[ -z "${ZEPPELIN_ENCODING}" ]]; then
fi
if [[ -z "${ZEPPELIN_MEM}" ]]; then
- export ZEPPELIN_MEM="-Xms1024m -Xmx1024m -XX:MaxPermSize=512m"
+ export ZEPPELIN_MEM="-Xms1024m -Xmx1024m"
fi
if [[ -z "${ZEPPELIN_INTP_MEM}" ]]; then
- export ZEPPELIN_INTP_MEM="-Xms1024m -Xmx2048m -XX:MaxPermSize=512m"
+ export ZEPPELIN_INTP_MEM="-Xms1024m -Xmx2048m"
fi
JAVA_OPTS+=" ${ZEPPELIN_JAVA_OPTS} -Dfile.encoding=${ZEPPELIN_ENCODING} ${ZEPPELIN_MEM}"
diff --git a/bin/interpreter.sh b/bin/interpreter.sh
index 961d688..672f307 100755
--- a/bin/interpreter.sh
+++ b/bin/interpreter.sh
@@ -24,6 +24,29 @@ function usage() {
echo "usage) $0 -p <port> -r <intp_port> -d <interpreter dir to load> -l <local interpreter repo dir to load> -g <interpreter group name>"
}
+# pre-requisites for checking that we're running in container
+if [ -f /proc/self/cgroup ] && [ -n "$(command -v getent)" ]; then
+ # checks if we're running in container...
+ if awk -F: '/cpu/ && $3 ~ /^\/$/{ c=1 } END { exit c }' /proc/self/cgroup; then
+ # Check whether there is a passwd entry for the container UID
+ myuid="$(id -u)"
+ mygid="$(id -g)"
+ # turn off -e for getent because it will return error code in anonymous uid case
+ set +e
+ uidentry="$(getent passwd "$myuid")"
+ set -e
+
+ # If there is no passwd entry for the container UID, attempt to create one
+ if [ -z "$uidentry" ] ; then
+ if [ -w /etc/passwd ] ; then
+ echo "zeppelin:x:$myuid:$mygid:anonymous uid:$Z_HOME:/bin/false" >> /etc/passwd
+ else
+ echo "Container ENTRYPOINT failed to add passwd entry for anonymous UID"
+ fi
+ fi
+ fi
+fi
+
while getopts "hc:p:r:i:d:l:v:u:g:" o; do
case ${o} in
h)
diff --git a/bin/zeppelin.sh b/bin/zeppelin.sh
index 9f32fb4..d559618 100755
--- a/bin/zeppelin.sh
+++ b/bin/zeppelin.sh
@@ -19,24 +19,33 @@
# Run Zeppelin
#
-# Check whether there is a passwd entry for the container UID
-myuid=$(id -u)
-mygid=$(id -g)
-# turn off -e for getent because it will return error code in anonymous uid case
-set +e
-uidentry=$(getent passwd $myuid)
-set -e
-
-# If there is no passwd entry for the container UID, attempt to create one
-if [ -z "$uidentry" ] ; then
- if [ -w /etc/passwd ] ; then
- echo "zeppelin:x:$myuid:$mygid:anonymous uid:$Z_HOME:/bin/false" >> /etc/passwd
- else
- echo "Container ENTRYPOINT failed to add passwd entry for anonymous UID"
+# pre-requisites for checking that we're running in container
+if [ -f /proc/self/cgroup ] && [ -n "$(command -v getent)" ]; then
+ # checks if we're running in container...
+ if awk -F: '/cpu/ && $3 ~ /^\/$/{ c=1 } END { exit c }' /proc/self/cgroup; then
+ # Check whether there is a passwd entry for the container UID
+ myuid="$(id -u)"
+ mygid="$(id -g)"
+ # turn off -e for getent because it will return error code in anonymous uid case
+ set +e
+ uidentry="$(getent passwd "$myuid")"
+ set -e
+
+ # If there is no passwd entry for the container UID, attempt to create one
+ if [ -z "$uidentry" ] ; then
+ if [ -w /etc/passwd ] ; then
+ echo "zeppelin:x:$myuid:$mygid:anonymous uid:$Z_HOME:/bin/false" >> /etc/passwd
+ else
+ echo "Container ENTRYPOINT failed to add passwd entry for anonymous UID"
+ fi
+ fi
fi
fi
-USAGE="Usage: bin/zeppelin.sh [--config <conf-dir>] [--run <noteId>]"
+function usage() {
+ echo "Usage: bin/zeppelin.sh [--config <conf-dir>] [--run <noteId>]"
+ exit 0
+}
POSITIONAL=()
while [[ $# -gt 0 ]]
@@ -53,6 +62,12 @@ do
shift # past argument
shift # past value
;;
+ --help)
+ usage
+ ;;
+ -h)
+ usage
+ ;;
esac
done
set -- "${POSITIONAL[@]}" # restore positional parameters
@@ -68,7 +83,6 @@ fi
HOSTNAME=$(hostname)
ZEPPELIN_LOGFILE="${ZEPPELIN_LOG_DIR}/zeppelin-${ZEPPELIN_IDENT_STRING}-${HOSTNAME}.log"
-LOG="${ZEPPELIN_LOG_DIR}/zeppelin-cli-${ZEPPELIN_IDENT_STRING}-${HOSTNAME}.out"
ZEPPELIN_SERVER=org.apache.zeppelin.server.ZeppelinServer
JAVA_OPTS+=" -Dzeppelin.log.file=${ZEPPELIN_LOGFILE}"
@@ -103,12 +117,12 @@ fi
if [[ ! -d "${ZEPPELIN_LOG_DIR}" ]]; then
echo "Log dir doesn't exist, create ${ZEPPELIN_LOG_DIR}"
- $(mkdir -p "${ZEPPELIN_LOG_DIR}")
+ mkdir -p "${ZEPPELIN_LOG_DIR}"
fi
if [[ ! -d "${ZEPPELIN_PID_DIR}" ]]; then
echo "Pid dir doesn't exist, create ${ZEPPELIN_PID_DIR}"
- $(mkdir -p "${ZEPPELIN_PID_DIR}")
+ mkdir -p "${ZEPPELIN_PID_DIR}"
fi
exec $ZEPPELIN_RUNNER $JAVA_OPTS -cp $ZEPPELIN_CLASSPATH_OVERRIDES:${ZEPPELIN_CLASSPATH} $ZEPPELIN_SERVER "$@"