You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwhisk.apache.org by du...@apache.org on 2019/01/07 14:13:06 UTC
[incubator-openwhisk] branch master updated: Switch to new Box
Upload proxy (#4200)
This is an automated email from the ASF dual-hosted git repository.
dubeejw pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk.git
The following commit(s) were added to refs/heads/master by this push:
new db9364b Switch to new Box Upload proxy (#4200)
db9364b is described below
commit db9364b862b184b38e95689adeba7ae2682f7b6e
Author: Jonathan Springer <jo...@gmail.com>
AuthorDate: Mon Jan 7 09:12:59 2019 -0500
Switch to new Box Upload proxy (#4200)
* Switch to new Box Upload proxy
* Add stderr redirect to docker logs, just because
---
ansible/logs.yml | 2 +-
tools/travis/box-upload.py | 32 +++++++++++++++++++++++++++++---
tools/travis/setup.sh | 3 +++
3 files changed, 33 insertions(+), 4 deletions(-)
diff --git a/ansible/logs.yml b/ansible/logs.yml
index 73a84fa..5370238 100644
--- a/ansible/logs.yml
+++ b/ansible/logs.yml
@@ -49,7 +49,7 @@
local_action: shell docker {{ docker_host_flag }} ps -a --format="{% raw %}{{.Names}}{% endraw %}"
register: container_names
- name: get logs from all containers
- local_action: shell docker {{ docker_host_flag }} logs {{ item }} > "{{ openwhisk_home }}/logs/{{ item }}.log"; exit 0
+ local_action: shell docker {{ docker_host_flag }} logs {{ item }} > "{{ openwhisk_home }}/logs/{{ item }}.log" 2>&1; exit 0
with_items: "{{ container_names.stdout_lines | difference('whisk_docker_registry') }}"
when: "'docker' not in exclude_logs_from"
- name: workaround to make synchronize work
diff --git a/tools/travis/box-upload.py b/tools/travis/box-upload.py
index e240449..6152fd9 100755
--- a/tools/travis/box-upload.py
+++ b/tools/travis/box-upload.py
@@ -26,11 +26,16 @@ Compresses the contents of a folder and upload the result to Box.
*/
"""
+from __future__ import print_function
+
import os
import subprocess
import sys
import tempfile
import urllib
+import humanize
+import requests
+import hashlib
def upload_file(local_file, remote_file):
@@ -38,9 +43,15 @@ def upload_file(local_file, remote_file):
if remote_file[0] == '/':
remote_file = remote_file[1:]
- subprocess.call(["curl", "-X", "POST", "--data-binary", "@%s" % local_file,
- "http://wsklogfwd.mybluemix.net/upload?%s" %
- urllib.urlencode({"name": remote_file})])
+ url = "http://DamCYhF8.mybluemix.net/upload?%s" % \
+ urllib.urlencode({"name": remote_file})
+
+ r = requests.post(url,
+ headers={"Content-Type": "application/gzip"},
+ data=open(local_file, 'rb'))
+
+ print("Posting result", r)
+ print(r.text)
def tar_gz_dir(dir_path):
@@ -49,6 +60,19 @@ def tar_gz_dir(dir_path):
subprocess.call(["tar", "-cvzf", dst, dir_path])
return dst
+
+def print_tarball_size(tarball):
+ """Get and print the size of the tarball"""
+ tarballsize = os.path.getsize(tarball)
+ print("Size of tarball", tarball, "is", humanize.naturalsize(tarballsize))
+
+ sha256_hash = hashlib.sha256()
+ with open(tarball, "rb") as f:
+ for byte_block in iter(lambda: f.read(4096), b""):
+ sha256_hash.update(byte_block)
+ print("SHA256 hash of tarball is", sha256_hash.hexdigest())
+
+
if __name__ == "__main__":
dir_path = sys.argv[1]
dst_path = sys.argv[2]
@@ -59,5 +83,7 @@ if __name__ == "__main__":
print("Compressing logs dir...")
tar = tar_gz_dir(dir_path)
+ print_tarball_size(tar)
+
print("Uploading to Box...")
upload_file(tar, dst_path)
diff --git a/tools/travis/setup.sh b/tools/travis/setup.sh
index f13b58a..f712897 100755
--- a/tools/travis/setup.sh
+++ b/tools/travis/setup.sh
@@ -51,6 +51,9 @@ pip install --user ansible==2.5.2
# Azure CosmosDB
pip install --user pydocumentdb
+# Support the revises log upload script
+pip install --user humanize requests
+
# Basic check that all code compiles and depdendencies are downloaded correctly.
# Compiling the tests will compile all components as well.
#