csantanapr closed pull request #111: upload logs to box at end of build URL: https://github.com/apache/incubator-openwhisk-deploy-kube/pull/111
This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/.travis.yml b/.travis.yml index d120ba6..c8587e5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,18 +1,25 @@ sudo: required + env: global: - TRAVIS_KUBE_VERSION=v1.7.4 - TRAVIS_MINIKUBE_VERSION=v0.23.0 - secure: d7CuMXbhT83W2x78qiLwgogX1+3aPicd1PlTwwNNDN6QSkImbxareyKThnsqlHIiNj3o5l5DBuiYjy7wrF/xD1g8BQMmTwm99DRx5q3CI3Im3VCi/ZK8SaNjuOy24d7cf5k2tB/87Gk7zmKsMDYm+fpCl+GpgUmIEeIwthiAxuXSDWZ8eQPIptmxj56DeFRNouvXG+dEUtBfWiwN27UPxNKExCixFnegmdtffLbz6hhst7BHr5Ry9acbycre98PCwWZcu9lxFs+SJ1kvnzX2iue4otmDkF1WkJjxaOFPJVs/D3YItg+neLCSxjwBskPed+Fct8bOjcM/uVROJPNIq5icBmaPX2isH0lvtxOeVw/dmioWYXYPN9ygBOe4eO/vtPllN0bcAUo5xl9jXev8ciAozYrYpHVh9Fplfd81rcYTeYzALmRJBdoiWoc3KQGzwGc9sB1ffmy+KWgG9T0zbnS4fALSR4PSzyNlKSLXw9vuvdNP0OBYtO+6yTJXavIxqmDoj64Lb93n+uGPatnaIGPTKEEBMJTSjsgYVEfxzzZuxUT9Ldkf2lzqvN2PCllGoMqxkgsdb8i4v4QgRaMWBDbKa5Va4k0O4dnhRmtdbJavOSKN6fECJbyfoJlV1VvJGxk5znVLRznBmUPBKbNccyPZJULugKD3QIh4q8Q5jBU= - secure: CJtnU94HTDqd4A6uvhFl8IpnmU+wTdlzb8bPBFUl/lI/VKXiRrYpgJdKUro5xEoxFKuqMprLhbyf66niyWLTIeogjUAEu/h/o2dBVeGgSGKoqC0hQgqvnxKFeGlzFJ0XuEs3vbStJGRnQszGsfnnDrscJtR0x9X+1w4aBKI7iPyyuFtVkDD1UsmBbSi+M8FTeq7G7A0reMDaey7uog3CFCpIMl4geshcohQEcKEGbnXQZoLPFpb7cBOE83VXBJ7Y7Dgf/U4keiLovvnuJThGKZm/SVV2KlELmBmtmbx3rMT6Vb5k9ChSdRWapromNnnzmJBIQ5Scc2mwV3A93/SMha1F3IlYpDKs5djfTw8jZfVnuiou7HhTaRjHkmmcwP12/k30gLe2kw0Vezg1TCY4zgtOpcmCxc8RHEy0ceA74rKvRi8LbexTCwX+iAMQFn/pSrh/OqAq/50JbLyczcoO1zXWS38txUQNLW8i+XllhCg9pjkjyfBeGjOOcWiVIz9rWJd2XufjSXDcj6xoZHtkh1XDt1CnVkpsYKtyyZucQnhUM9ebmaWqbSW2+bpqC/2hI+G+kOyyCesGdB1q+VmN1augMMs6RgWjk4yw5dyLAshATSoUlE8KH2cDcJL19r4ECaQ99PSLwxoB89yfPoJiNc42vwxRdsLmB1BMNyPa81Y= + services: -- docker + - docker + before_install: -- "./tools/travis/setupscan.sh" -- "./tools/travis/setup.sh" + - ./tools/travis/setupscan.sh + - ./tools/travis/setup.sh + script: -- "./tools/travis/scancode.sh" -- "./tools/travis/build.sh" + - ./tools/travis/scancode.sh + - ./tools/travis/build.sh + - ./tools/travis/collect-logs.sh + - ./tools/travis/box-upload.py "$TRAVIS_BUILD_DIR/logs" "deploy-kube-$TRAVIS_BUILD_ID-$TRAVIS_BRANCH.tar.gz" + deploy: - provider: script script: "./tools/travis/publish.sh openwhisk kube-couchdb latest" diff --git a/tools/travis/box-upload.py b/tools/travis/box-upload.py new file mode 100755 index 0000000..e240449 --- /dev/null +++ b/tools/travis/box-upload.py @@ -0,0 +1,63 @@ +#!/usr/bin/env python +"""Executable Python script for compressing folders to Box. + +Compresses the contents of a folder and upload the result to Box. + + Run this script as: + $ upload-logs.py LOG_DIR DEST_NAME + + e.g.: $ upload-logs.py /tmp/wsklogs logs-5512.tar.gz + +/* + * 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. + */ +""" + +import os +import subprocess +import sys +import tempfile +import urllib + + +def upload_file(local_file, remote_file): + """Upload 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})]) + + +def tar_gz_dir(dir_path): + """Create TAR (ZIP) of path and its contents.""" + _, dst = tempfile.mkstemp(suffix=".tar.gz") + subprocess.call(["tar", "-cvzf", dst, dir_path]) + return dst + +if __name__ == "__main__": + dir_path = sys.argv[1] + dst_path = sys.argv[2] + + if not os.path.isdir(dir_path): + print("Directory doesn't exist: %s." % dir_path) + sys.exit(0) + + print("Compressing logs dir...") + tar = tar_gz_dir(dir_path) + print("Uploading to Box...") + upload_file(tar, dst_path) diff --git a/tools/travis/collect-logs.sh b/tools/travis/collect-logs.sh new file mode 100755 index 0000000..0670bde --- /dev/null +++ b/tools/travis/collect-logs.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +set -x + +SCRIPTDIR=$(cd $(dirname "$0") && pwd) +ROOTDIR="$SCRIPTDIR/../../" + +cd $ROOTDIR + +echo "Gathering logs to upload to https://app.box.com/v/openwhisk-travis-logs" + +mkdir logs + +# Logs from all the pods +kubectl -n openwhisk logs -lname=couchdb >& logs/couchdb.log +kubectl -n openwhisk logs -lname=zookeeper >& logs/zookeeper.log +kubectl -n openwhisk logs -lname=kafka >& logs/kafka.log +kubectl -n openwhisk logs controller-0 >& logs/controller-0.log +kubectl -n openwhisk logs controller-1 >& logs/controller-1.log +kubectl -n openwhisk logs -lname=invoker >& logs/invoker.log +kubectl -n openwhisk logs -lname=nginx >& logs/nginx.log +kubectl get pods --all-namespaces -o wide --show-all >& logs/all-pods.txt + +# System level logs from minikube +minikube logs >& logs/minikube.log ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
