This is an automated email from the ASF dual-hosted git repository. liuxun 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 6faf663 [ZEPPELIN-4241] Configure the interpreter docker container time zone 6faf663 is described below commit 6faf663c59ee21121522911c588d82e8627fb7fd Author: Xun Liu <liu...@apache.org> AuthorDate: Sat Aug 3 22:46:55 2019 +0800 [ZEPPELIN-4241] Configure the interpreter docker container time zone ### What is this PR for? Need to set the interpreter container and zeppelin service to have the same time zone Otherwise, the time in the container is inconsistent with the zeppelin server time. ### What type of PR is it? [Improvement] ### What is the Jira issue? https://issues.apache.org/jira/browse/ZEPPELIN-4241 ### How should this be tested? [CI pass](https://travis-ci.org/liuxunorg/zeppelin/builds/566315011) ### Screenshots (if appropriate) ### Questions: * Does the licenses files need update? * Is there breaking changes for older versions? * Does this needs documentation? Author: Xun Liu <liu...@apache.org> Closes #3418 from liuxunorg/ZEPPELIN-4241 and squashes the following commits: 5a1033bc1 [Xun Liu] add `&& apt-get clean` b682039a8 [Xun Liu] Modify `Environment` to `Configuration`. 80b1f14e0 [Xun Liu] revert code. c84f08382 [Xun Liu] [ZEPPELIN-4241] Set the interpreter docker container time zone --- conf/zeppelin-env.sh.template | 2 + docs/quickstart/docker.md | 44 +++++++++++++--------- scripts/docker/interpreter/Dockerfile | 8 ++-- .../launcher/DockerInterpreterProcess.java | 8 ++++ .../launcher/DockerInterpreterProcessTest.java | 4 +- 5 files changed, 44 insertions(+), 22 deletions(-) diff --git a/conf/zeppelin-env.sh.template b/conf/zeppelin-env.sh.template index 9f10be8..5aaf83d 100644 --- a/conf/zeppelin-env.sh.template +++ b/conf/zeppelin-env.sh.template @@ -60,6 +60,8 @@ # export ZEPPELIN_NOTEBOOK_ONE_WAY_SYNC # If there are multiple notebook storages, should we treat the first one as the only source of truth? # export ZEPPELIN_NOTEBOOK_PUBLIC # Make notebook public by default when created, private otherwise +# export DOCKER_TIME_ZONE # Set to the same time zone as the zeppelin server. E.g, "America/New_York" or "Asia/Shanghai" + #### Spark interpreter configuration #### ## Kerberos ticket refresh setting diff --git a/docs/quickstart/docker.md b/docs/quickstart/docker.md index 9cb2c4f..dca9a89 100644 --- a/docs/quickstart/docker.md +++ b/docs/quickstart/docker.md @@ -58,21 +58,28 @@ vi `/etc/docker/daemon.json`, Add `tcp://0.0.0.0:2375` to the `hosts` configurat ## Quickstart -Modify these 2 configuration items in `zeppelin-site.xml`. +1. Modify these 2 configuration items in `zeppelin-site.xml`. ``` - <property> - <name>zeppelin.run.mode</name> - <value>docker</value> - <description>'auto|local|k8s|docker'</description> - </property> - - <property> - <name>zeppelin.docker.container.image</name> - <value>apache/zeppelin</value> - <description>Docker image for interpreters</description> - </property> +<property> + <name>zeppelin.run.mode</name> + <value>docker</value> + <description>'auto|local|k8s|docker'</description> +</property> + +<property> + <name>zeppelin.docker.container.image</name> + <value>apache/zeppelin</value> + <description>Docker image for interpreters</description> +</property> +``` + +2. set timezone in zeppelin-env.sh +Set to the same time zone as the zeppelin server, keeping the time zone in the interpreter docker container the same as the server. E.g, `"America/New_York"` or `"Asia/Shanghai"` + +``` +export DOCKER_TIME_ZONE="America/New_York" ``` @@ -90,12 +97,14 @@ ENV SPARK_VERSION=2.3.3 ENV HADOOP_VERSION=2.7 # support Kerberos certification -RUN install -yq curl unzip wget grep sed vim krb5-user libpam-krb5 && apt-get clean +RUN export DEBIAN_FRONTEND=noninteractive && apt-get update && apt-get install -yq krb5-user libpam-krb5 && apt-get clean + +RUN apt-get update && apt-get install -y curl unzip wget grep sed vim tzdata && apt-get clean # auto upload zeppelin interpreter lib -RUN rm /zeppelin -R +RUN rm -rf /zeppelin -RUN rm /spark -R +RUN rm -rf /spark RUN wget https://www-us.apache.org/dist/spark/spark-${SPARK_VERSION}/spark-${SPARK_VERSION}-bin-hadoop${HADOOP_VERSION}.tgz RUN tar zxvf spark-${SPARK_VERSION}-bin-hadoop${HADOOP_VERSION}.tgz RUN mv spark-${SPARK_VERSION}-bin-hadoop${HADOOP_VERSION} spark @@ -192,8 +201,9 @@ Instead of build Zeppelin distribution package and docker image everytime during Zeppelin can run locally (such as inside your IDE in debug mode) and able to run Interpreter using [DockerInterpreterLauncher](https://github.com/apache/zeppelin/blob/master/zeppelin-plugins/launcher/docker/src/main/java/org/apache/zeppelin/interpreter/launcher/DockerInterpreterLauncher.java) by configuring following environment variables. -| Environment variable | Value | Description | +1. zeppelin-site.xml + +| Configuration variable | Value | Description | | ----- | ----- | ----- | | ZEPPELIN_RUN_MODE | docker | Make Zeppelin run interpreter on Docker | | ZEPPELIN_DOCKER_CONTAINER_IMAGE | <image>:<version> | Zeppelin interpreter docker image to use | - diff --git a/scripts/docker/interpreter/Dockerfile b/scripts/docker/interpreter/Dockerfile index ca282ee..e886865 100644 --- a/scripts/docker/interpreter/Dockerfile +++ b/scripts/docker/interpreter/Dockerfile @@ -20,12 +20,14 @@ ENV SPARK_VERSION=2.3.3 ENV HADOOP_VERSION=2.7 # support Kerberos certification -RUN install -yq curl unzip wget grep sed vim krb5-user libpam-krb5 && apt-get clean +RUN export DEBIAN_FRONTEND=noninteractive && apt-get update && apt-get install -yq krb5-user libpam-krb5 && apt-get clean + +RUN apt-get update && apt-get install -y curl unzip wget grep sed vim tzdata && apt-get clean # auto upload zeppelin interpreter lib -RUN rm /zeppelin -R +RUN rm -rf /zeppelin -RUN rm /spark -R +RUN rm -rf /spark RUN wget https://www-us.apache.org/dist/spark/spark-${SPARK_VERSION}/spark-${SPARK_VERSION}-bin-hadoop${HADOOP_VERSION}.tgz RUN tar zxvf spark-${SPARK_VERSION}-bin-hadoop${HADOOP_VERSION}.tgz RUN mv spark-${SPARK_VERSION}-bin-hadoop${HADOOP_VERSION} spark diff --git a/zeppelin-plugins/launcher/docker/src/main/java/org/apache/zeppelin/interpreter/launcher/DockerInterpreterProcess.java b/zeppelin-plugins/launcher/docker/src/main/java/org/apache/zeppelin/interpreter/launcher/DockerInterpreterProcess.java index b1374e7..a2f59bf 100644 --- a/zeppelin-plugins/launcher/docker/src/main/java/org/apache/zeppelin/interpreter/launcher/DockerInterpreterProcess.java +++ b/zeppelin-plugins/launcher/docker/src/main/java/org/apache/zeppelin/interpreter/launcher/DockerInterpreterProcess.java @@ -36,6 +36,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Properties; +import java.util.TimeZone; import java.util.concurrent.atomic.AtomicBoolean; import com.spotify.docker.client.DefaultDockerClient; @@ -296,6 +297,13 @@ public class DockerInterpreterProcess extends RemoteInterpreterProcess { envs.put("ZEPPELIN_FORCE_STOP", "true"); envs.put("SPARK_HOME", this.CONTAINER_SPARK_HOME); + // set container time zone + String dockerTimeZone = System.getenv("DOCKER_TIME_ZONE"); + if (StringUtils.isBlank(dockerTimeZone)) { + dockerTimeZone = TimeZone.getDefault().getID(); + } + envs.put("TZ", dockerTimeZone); + List<String> listEnv = new ArrayList<>(); for (Map.Entry<String, String> entry : this.envs.entrySet()) { String env = entry.getKey() + "=" + entry.getValue(); diff --git a/zeppelin-plugins/launcher/docker/src/test/java/org/apache/zeppelin/interpreter/launcher/DockerInterpreterProcessTest.java b/zeppelin-plugins/launcher/docker/src/test/java/org/apache/zeppelin/interpreter/launcher/DockerInterpreterProcessTest.java index ce35b79..7e6a918 100644 --- a/zeppelin-plugins/launcher/docker/src/test/java/org/apache/zeppelin/interpreter/launcher/DockerInterpreterProcessTest.java +++ b/zeppelin-plugins/launcher/docker/src/test/java/org/apache/zeppelin/interpreter/launcher/DockerInterpreterProcessTest.java @@ -132,14 +132,14 @@ public class DockerInterpreterProcessTest { assertTrue(null != dockerProperties.get("zeppelin.interpreter.connect.timeout")); List<String> listEnvs = intp.getListEnvs(); - assertEquals(listEnvs.size(), 5); + assertEquals(listEnvs.size(), 6); Map<String, String> mapEnv = new HashMap<>(); for (int i = 0; i < listEnvs.size(); i++) { String env = listEnvs.get(i); String kv[] = env.split("="); mapEnv.put(kv[0], kv[1]); } - assertEquals(mapEnv.size(), 5); + assertEquals(mapEnv.size(), 6); assertTrue(mapEnv.containsKey("ZEPPELIN_HOME")); assertTrue(mapEnv.containsKey("ZEPPELIN_CONF_DIR")); assertTrue(mapEnv.containsKey("ZEPPELIN_FORCE_STOP"));