You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwhisk.apache.org by ch...@apache.org on 2019/10/12 05:36:17 UTC
[openwhisk] branch master updated: Fix Travis build pip install
issue in pre installation step (#4683)
This is an automated email from the ASF dual-hosted git repository.
chetanm pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/openwhisk.git
The following commit(s) were added to refs/heads/master by this push:
new ad4e9ca Fix Travis build pip install issue in pre installation step (#4683)
ad4e9ca is described below
commit ad4e9ca59ed630e06956c40026e96ecf7e0523d1
Author: Neeraj Mangal <ne...@users.noreply.github.com>
AuthorDate: Sat Oct 12 11:06:02 2019 +0530
Fix Travis build pip install issue in pre installation step (#4683)
Fixes the travis build which was failing due to some change in Python setup in base image. As part of fix also moved to `xenial` version from current usage of a deprecated image.
With xenial switching to systemd for init the way Docker is configured gets changed. setup-docker.py handles this new flow by seeding the daemon.json properly by adding the new fields needed by OpenWhisk tests to pass.
---
.travis.yml | 9 ++---
tools/travis/docker.conf | 19 +++++++++++
tools/travis/docker.sh | 18 ++++++++--
tools/travis/setup-docker.py | 78 ++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 117 insertions(+), 7 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index 968028b..04cf6a7 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -17,8 +17,8 @@
sudo: required
-group: deprecated-2017Q3
-
+dist: xenial
+jdk: openjdk8
language: scala
scala:
- 2.12.7
@@ -58,8 +58,9 @@ cache:
before_install:
- ./tools/travis/docker.sh
- - pip install --upgrade pip setuptools six
- - pip3 install --upgrade pip setuptools six
+ - sudo apt-get install -y python3-pip
+ - pip install --user --upgrade pip setuptools six
+ - pip3 install --user setuptools six
install:
- ./tools/travis/setup.sh
diff --git a/tools/travis/docker.conf b/tools/travis/docker.conf
new file mode 100644
index 0000000..4b9d8df
--- /dev/null
+++ b/tools/travis/docker.conf
@@ -0,0 +1,19 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+[Service]
+ExecStart=
+ExecStart=/usr/bin/dockerd
diff --git a/tools/travis/docker.sh b/tools/travis/docker.sh
index db7bc9d..21eed7c 100755
--- a/tools/travis/docker.sh
+++ b/tools/travis/docker.sh
@@ -16,8 +16,12 @@
# limitations under the License.
#
+BASEDIR=$(dirname "$0")
+echo "$BASEDIR"
+
sudo gpasswd -a travis docker
-sudo -E bash -c 'echo '\''DOCKER_OPTS="-H tcp://0.0.0.0:4243 -H unix:///var/run/docker.sock --storage-driver=overlay --userns-remap=default"'\'' > /etc/default/docker'
+sudo usermod -aG docker travis
+#sudo -E bash -c 'echo '\''DOCKER_OPTS="-H tcp://0.0.0.0:4243 -H unix:///var/run/docker.sock --storage-driver=overlay --userns-remap=default"'\'' > /etc/default/docker'
# Docker
sudo apt-get clean
@@ -36,9 +40,17 @@ sudo add-apt-repository \
sudo apt-get update
sudo apt-get -o Dpkg::Options::="--force-confold" --force-yes -y install docker-ce=18.06.3~ce~3-0~ubuntu containerd.io
-sudo service docker restart
+# daemon.json and flags does not work together. Overwritting the docker.service file
+# to remove the host flags. - https://docs.docker.com/config/daemon/#troubleshoot-conflicts-between-the-daemonjson-and-startup-scripts
+sudo mkdir -p /etc/systemd/system/docker.service.d
+sudo cp $BASEDIR/docker.conf /etc/systemd/system/docker.service.d/docker.conf
+# setup-docker will add configs to /etc/docker/daemon.json
+sudo python $BASEDIR/setup-docker.py
+sudo cat /etc/docker/daemon.json
+sudo systemctl daemon-reload
+sudo systemctl restart docker
+sudo systemctl status docker.service
echo "Docker Version:"
docker version
echo "Docker Info:"
docker info
-
diff --git a/tools/travis/setup-docker.py b/tools/travis/setup-docker.py
new file mode 100755
index 0000000..525e6f4
--- /dev/null
+++ b/tools/travis/setup-docker.py
@@ -0,0 +1,78 @@
+#!/usr/bin/env python
+"""Executable Python script for setting up docker daemon.
+
+Add docker daemon configuration options in /etc/docker/daemon.json
+
+ Run this script as:
+ $python setup-docker.py
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+"""
+
+from __future__ import print_function
+
+import json
+import traceback
+
+DOCKER_DAEMON_FILE = "/etc/docker/daemon.json"
+
+# Read the file.
+
+DOCKER_OPTS = {
+ "hosts": [
+ "tcp://0.0.0.0:4243",
+ "unix:///var/run/docker.sock"
+ ],
+ "storage-driver": "overlay",
+ "userns-remap": "default"
+}
+
+
+def get_daemon_content():
+ data = {}
+ with open(DOCKER_DAEMON_FILE) as json_file:
+ data = json.load(json_file)
+ return data
+
+
+def add_content(data):
+ for config in DOCKER_OPTS.items():
+ # config will be a tuple of key, value
+ # ('hosts', ['tcp://0.0.0.0:4243', 'unix:///var/run/docker.sock'])
+ key, value = config
+ data[key] = value
+ return data
+
+
+def write_to_daemon_conf(data):
+ try:
+ with open(DOCKER_DAEMON_FILE, 'w') as fp:
+ json.dump(data, fp)
+ except Exception as e:
+ print("Failed to write to daemon file")
+ print(e)
+ traceback.print_exc()
+
+
+if __name__ == "__main__":
+ current_data = get_daemon_content()
+ print(current_data)
+ updated_data = add_content(current_data)
+ print(updated_data)
+ write_to_daemon_conf(updated_data)
+ print("Successfully Configured Docker daemon.json")