Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CI] Several CI/Infrastructure Improvement & Fix #595

Merged
merged 136 commits into from
Jan 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
136 commits
Select commit Hold shift + click to select a range
58296fa
Starting to add travis
simon-mo Oct 30, 2018
fa54104
Use generic environment
simon-mo Oct 30, 2018
d217c79
Install coreutils
simon-mo Oct 30, 2018
8e4181d
Use example travis
simon-mo Oct 30, 2018
ceeef41
Use python, does it work?
simon-mo Oct 30, 2018
49b2dfc
Remove Vagrantfile
simon-mo Nov 7, 2018
79fc56c
Pin cloudpickle version
simon-mo Nov 7, 2018
50c3c87
Use minikube for k8s test
simon-mo Nov 7, 2018
af03aa0
Sign into Dockerhub
simon-mo Nov 7, 2018
d2142db
Fix docker login non tty
simon-mo Nov 7, 2018
e28e487
Fix flags
simon-mo Nov 7, 2018
6e6036a
Fix password flag
simon-mo Nov 7, 2018
ab26335
Remove travis secret, added in web ui
simon-mo Nov 7, 2018
4d03b2c
Don't use logger.warn
simon-mo Nov 7, 2018
1141c56
Move proxy process to k8s tests, lower the number of apps and models
simon-mo Nov 11, 2018
dd264db
Use shipyard to build docker images
simon-mo Nov 11, 2018
250a2b3
Merge branch 'shipyard' of https://github.com/simon-mo/clipper into s…
simon-mo Nov 11, 2018
cd9f132
Use py3 in jenkins
simon-mo Nov 11, 2018
75bd58b
Use bootstrap container
simon-mo Nov 11, 2018
c6153c0
fix path when running docker
simon-mo Nov 11, 2018
962ebb6
Move functions to clipper build specific
simon-mo Nov 11, 2018
4f4c095
Use pwd as root
simon-mo Nov 11, 2018
2bb73f5
Fix JVM and use strecth for py35
simon-mo Nov 11, 2018
dd9e6be
Disable yapf, pending the switch to black
simon-mo Nov 11, 2018
fa7150d
Merge branch 'shipyard' of https://github.com/simon-mo/clipper into s…
simon-mo Nov 11, 2018
5a70818
Add fluentd, start using it for the log
simon-mo Nov 15, 2018
1d3ec3c
Housekeeping, cleanup fluetnd
simon-mo Nov 15, 2018
c4fb08f
Typo
simon-mo Nov 15, 2018
cb1be8b
Fix jq issue
simon-mo Nov 15, 2018
13fa5ee
Non tty mode for docker
simon-mo Nov 15, 2018
9e7a0f5
Fix typo again
simon-mo Nov 15, 2018
64d168d
Don't time docker build
simon-mo Nov 15, 2018
3eca259
Reduce apt-get verbosity
simon-mo Nov 15, 2018
480793d
Pip install quiet
simon-mo Nov 15, 2018
cf13737
Add Travis images for build
simon-mo Nov 20, 2018
9a1b388
Fix travis
simon-mo Nov 21, 2018
ba66595
Tee to stdout
simon-mo Nov 21, 2018
29caf46
Check color support
simon-mo Nov 26, 2018
8177e98
Add colorize output
simon-mo Nov 26, 2018
4462253
Remove color check
simon-mo Nov 26, 2018
caf52f4
Only use stdlib for colorize output
simon-mo Nov 26, 2018
67c8c6a
Make coloring atomic
simon-mo Nov 26, 2018
cb7ffff
Let travis wait for jenkins build
simon-mo Nov 26, 2018
55d6fc3
Fix pulling image name
simon-mo Nov 26, 2018
70ea372
Format code
simon-mo Nov 26, 2018
6c7eb9f
Fixi fstring
simon-mo Nov 26, 2018
53af02e
Chmod
simon-mo Nov 26, 2018
8e83e52
Use jenkins env var
simon-mo Nov 26, 2018
e0d0097
Add jenkins tag to shipyard.sh
simon-mo Nov 26, 2018
9af3bc0
Fix var check
simon-mo Nov 26, 2018
70bbb47
Bash done right
simon-mo Nov 26, 2018
745bbe9
Use prepull to speed up docker build
simon-mo Dec 26, 2018
5bb7c54
Time making all containers
simon-mo Dec 26, 2018
1365b4e
Fix Action init
simon-mo Dec 26, 2018
ac4819c
Fix travis a bit
simon-mo Dec 27, 2018
1b0af26
Add header footer
simon-mo Dec 27, 2018
2245a31
Add makefile tagging
simon-mo Dec 27, 2018
357c748
Forgot the .py
simon-mo Dec 27, 2018
5a1af48
Add back new lines
simon-mo Dec 27, 2018
7a247b6
reverse postprocessing orders
simon-mo Dec 27, 2018
33b2437
Fix script name
simon-mo Dec 27, 2018
66e4292
chmod
simon-mo Dec 27, 2018
dc3f29b
Make sure everyline is color printed
simon-mo Dec 27, 2018
1204a1c
remove all from waiting tasks
simon-mo Dec 27, 2018
342befe
Use -j unlimited
simon-mo Dec 27, 2018
3b943cf
Add final touches
simon-mo Dec 27, 2018
a502acf
Add some docs, create makefile for test
simon-mo Dec 28, 2018
31f2752
Optimizations in R container building; colorize output now clear escape
simon-mo Dec 28, 2018
eb436fc
Update makefile
simon-mo Dec 28, 2018
6a3f569
Redirect stderr to stdout
simon-mo Dec 28, 2018
fcf9fd4
Pipefail makefile, fix typo
simon-mo Dec 28, 2018
ae0ddd2
Resolve Makevars dir not found issue
simon-mo Dec 28, 2018
78e8fcc
Fix mkdir issue
simon-mo Dec 28, 2018
c2832d0
No need to make makrvars a dir
simon-mo Dec 28, 2018
f87ab7f
Don't prune, other wise there will be error
simon-mo Dec 28, 2018
8ea6dbf
Don't compile in unittests.sh, compile in container
simon-mo Dec 28, 2018
c99c0b4
Add correct entrypoint
simon-mo Dec 28, 2018
5136f87
Don't use bash -l, it will cause tty name issue
simon-mo Dec 28, 2018
95909c5
Quote test to run command, so bash -c will work
simon-mo Dec 28, 2018
7a47996
Fix shlex
simon-mo Dec 29, 2018
8e76ade
Fix the whitespace bash line
simon-mo Dec 29, 2018
85a74b5
Turn off pedantic warning
simon-mo Dec 29, 2018
3e81f1a
Fix rpc_container test
simon-mo Dec 29, 2018
6d6a803
Let the integration test use newest images
simon-mo Dec 29, 2018
7ba135c
Fix admin test, make it paralleizable
simon-mo Dec 29, 2018
a22ad8f
Moving R Containers out of the tests for now -> Unmaintained
simon-mo Dec 29, 2018
7ae0b32
Randomize multi-tenancy tests
simon-mo Dec 29, 2018
3287136
Serialize unittests
simon-mo Dec 29, 2018
24e1dc5
Reduce parallelism of the tests, does it reduce flakiness?
simon-mo Dec 29, 2018
93defb0
Do aggressive par; use retry
simon-mo Dec 30, 2018
48c2c9d
Add exit logic, fix metric docker test
simon-mo Dec 30, 2018
b8c5151
Disable prepull, don't linearize unittest
simon-mo Dec 30, 2018
f4a606a
Use k8s v1.10
simon-mo Dec 30, 2018
1ccc658
Use latest minikube
simon-mo Dec 30, 2018
3343667
Remove trailing \
simon-mo Dec 30, 2018
d036a08
rename binary
simon-mo Dec 30, 2018
ed03fa9
Fix minikube starting issue
simon-mo Dec 30, 2018
fd81058
Revert "Use k8s v1.10" -> " Fix minikube starting issue"
simon-mo Dec 30, 2018
b3f1cf6
Debug travis build
simon-mo Dec 30, 2018
a903a74
Add more debug info
simon-mo Dec 30, 2018
69db510
Fix bash syntax
simon-mo Dec 30, 2018
7a50e2d
Use retry for bash
simon-mo Dec 30, 2018
1a5bdbf
still print periodically, fix bash -c
simon-mo Dec 30, 2018
3e34f31
try adding a secret key, let ucbrise build
simon-mo Dec 30, 2018
7c02cab
Use timeout
simon-mo Dec 30, 2018
14aac5e
fix bash script
simon-mo Dec 30, 2018
a628735
Fix makefile path, no more docker login, use insecure-registry
simon-mo Dec 30, 2018
2d0b384
we are using docker daemon already
simon-mo Dec 30, 2018
6def3fe
fixing spacing
simon-mo Dec 30, 2018
af60d18
add pyclosure back to the k8s base images
simon-mo Dec 30, 2018
5921f47
do travis and jenkins check in both places
simon-mo Dec 30, 2018
918fe1d
fix previous
simon-mo Dec 30, 2018
6b049a3
Fix bash
simon-mo Dec 30, 2018
6e14ed8
Travis set it to ""
simon-mo Dec 30, 2018
48c604f
Fix it once more
simon-mo Dec 30, 2018
4d9d735
Fix Jenkins unbound var
simon-mo Dec 30, 2018
cd909ec
Bash
simon-mo Dec 30, 2018
eb889d7
use or
simon-mo Dec 30, 2018
ee396c9
Jenkins fix, now fixing travis
simon-mo Dec 30, 2018
f1a9a0d
add repush commands
simon-mo Dec 30, 2018
0e5daef
Don't assume env var,
simon-mo Dec 30, 2018
27ca454
IDK why travis is not using localhost as CLIPPER_REGISTRY
simon-mo Dec 30, 2018
8729483
Don't export CLIPPER_REGISTRY in shipyard
simon-mo Dec 30, 2018
1e64a61
Be nice to jenkins, let's clean it up
simon-mo Dec 30, 2018
cdeaa43
Revert back to clippertesting, the issue turns out to be hardcoding
simon-mo Dec 30, 2018
0b9a9c2
make jenkins script optional
simon-mo Dec 30, 2018
e67bfc1
does export help?
simon-mo Dec 30, 2018
96be8ae
Extend timeout
simon-mo Dec 30, 2018
bcd9f0d
Re-enable prepull optimization
simon-mo Dec 30, 2018
ea706fa
Fix the break conflict
simon-mo Dec 31, 2018
16cb244
bash break can't be wrapped in a paren
simon-mo Dec 31, 2018
9a75840
Add health check for admin as well
simon-mo Dec 31, 2018
3704a0b
Cleanup
simon-mo Jan 1, 2019
29cdba7
Push to clipper for timer and master branch build
simon-mo Jan 1, 2019
f6a845b
Fix bash conditional
simon-mo Jan 1, 2019
fdd9f8b
Bash conditional part deus
simon-mo Jan 1, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
*.swp
.color_coded
.vscode
.ycm_p
.ycm_extra_conf.py
*.pyc
Expand Down
45 changes: 45 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Maintainer: Simon Mo <xmo@berkeley.edu>
# - Clipper use Travis CI to run its Kubernetes test.
# - We will spin up minikube and start a docker registry at localhost:5000
# - Once all environment is ready, it will run shipyard to generate the Makefile
# - Travis will wait for all docker images related to k8s test to finish building
# - Then travis will run the test sequentially with retry-once logic.

# Travis will start the build in a VM when sudo is required
sudo: required

language: python

env:
matrix:
# This will make sure .minikube config resides in current user folder
- CHANGE_MINIKUBE_NONE_USER=true

before_script:
# Download kubectl and minikube
- curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/v1.9.0/bin/linux/amd64/kubectl
&& chmod +x kubectl && sudo mv kubectl /usr/local/bin/
- curl -Lo minikube https://storage.googleapis.com/minikube/releases/v0.25.2/minikube-linux-amd64
&& chmod +x minikube && sudo mv minikube /usr/local/bin/

# Setup minikube and docker registry
- sudo minikube start --vm-driver=none --kubernetes-version=v1.9.0 --insecure-registry localhost:5000
- docker run -d -p 5000:5000 --restart=always registry:2
- minikube update-context
- JSONPATH='{range .items[*]}{@.metadata.name}:{range @.status.conditions[*]}{@.type}={@.status};{end}{end}';
until kubectl get nodes -o jsonpath="$JSONPATH" 2>&1 | grep -q "Ready=True"; do
sleep 1; done
- kubectl cluster-info
- JSONPATH='{range .items[*]}{@.metadata.name}:{range @.status.conditions[*]}{@.type}={@.status};{end}{end}';
until kubectl -n kube-system get pods -lcomponent=kube-addon-manager -o jsonpath="$JSONPATH"
2>&1 | grep -q "Ready=True"; do sleep 1;echo "waiting for kube-addon-manager to
be available"; kubectl get pods --all-namespaces; done
- JSONPATH='{range .items[*]}{@.metadata.name}:{range @.status.conditions[*]}{@.type}={@.status};{end}{end}';
until kubectl -n kube-system get pods -lk8s-app=kube-dns -o jsonpath="$JSONPATH"
2>&1 | grep -q "Ready=True"; do sleep 1;echo "waiting for kube-dns to be available";
kubectl get pods --all-namespaces; done

script:
- cd clipper_admin; pip install -q -e .; cd ..
- bash ./bin/shipyard.sh
- bash ./bin/run_travis.sh
5 changes: 4 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ set_property(TARGET cityhash PROPERTY
INTERFACE_LINK_LIBRARIES ${CITYHASH_LIBRARIES})

# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic -Wextra -Werror -Wno-deprecated-declarations -Wno-unsupported-friend")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic -Wextra -Wno-deprecated-declarations")
# Note(simon):
# https://github.com/ucbrise/clipper/pull/595
# pedantic is turned off for now until we figure out a way to turn off dlib warnings
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-deprecated-declarations")
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unsupported-friend")
endif()
Expand Down
24 changes: 0 additions & 24 deletions Vagrantfile

This file was deleted.

21 changes: 17 additions & 4 deletions bin/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
# Description of CI process

The wonderful AMPlab Jenkins is responsible for running our integration test.
The wonderful AMPlab Jenkins and Travis CI is responsible for running our integration test.

## How does the CI process work
## How does the CI process work (version 2.0)
- There are three components of Clipper CI:
1. Shipyard: generate Makefiles for both building and testing.
2. Jenkins: build, push, and test containers. It will run all tests except kubernetes test.
3. Travis: run kubernetes test. Travis will wait for Jenkins finish building it's required containers, using `wait_kubernetes_containers` Makefile target.
- Rationale:
1. We want to build the images in parallel as much as we can, however, our images have complex dependencies. Makefile is our best bet. However, one does not simply write complex Makefile. We built our in-house, light-weight makefile generator _shipyard_ to provide a declarative and pythonic way to generate the file.
2. Jenkins is our main CI worker. It simply set up the environment and run whatever makefile provides.
3. One downside of Jenkins is that it only runs docker, not VM. Minikube is a scarce resource. For this reason, Travis is used because it provides a VM.
- Other tooling:
1. `colorize_output.py` script in the `bin/` directory is used to tag each line of the log output.
1. [A webapp](http://clipper-jenkins-viewer.herokuapp.com/) deployed at heroku can be used to disaggregate the logs and visualize Makefile dag.


## How does the CI process work (version 1.0)

0. Jenkins pull the PR.
1. Jenkins inject environment variables configured in admin page. Currently, we set the following environment variables
in Pull Request Builder:
Expand All @@ -24,6 +37,6 @@ in Pull Request Builder:
- It runs `run_unnitests.sh` to run all tests.
- (Only in Python3) It will only run the integration test part, which contains all the python tests and R tests

## Note on Minikube (WIP)
## Note on Minikube
- We are under the process of moving away from AWS EKS to Minikube in our CI process. Once the PR is in, there will be
more detail here.
more detail here.
14 changes: 14 additions & 0 deletions bin/cleanup_jenkins.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# This script will delete all testing containers and images
# available on this machine.

CLIPPER_REGISTRY=clippertesting

# best effort, ignore all errors
try_cleanup() {
(docker ps | grep "$@" | awk '{ print $1 }' | xargs docker kill) || true
(docker container ls | grep "$@" | awk '{ print $3 }' | xargs docker container rm) || true
(docker image ls | grep "$@" | awk '{ print $3 }' | xargs docker image rm -f) || true
}

try_cleanup CLIPPER_REGISTRY > /dev/null
try_cleanup shipyard > /dev/null
43 changes: 43 additions & 0 deletions bin/colorize_output.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
from random import shuffle
import sys
import argparse
import re

parser = argparse.ArgumentParser(description="Colorize stdin; (optionally) add a tag.")
parser.add_argument("--tag", type=str, help="Optional tag")
parser.add_argument("--no-color", action="store_true", help="Flag to force the output to be no color.")

args = parser.parse_args()
tag = "[{}]".format(args.tag) if args.tag else ""

ALL_COLORS = [
"\u001b[30m", # Black
"\u001b[31m", # Red
"\u001b[32m", # Green
"\u001b[33m", # Yellow
"\u001b[34m", # Blue
"\u001b[35m", # Magenta
"\u001b[36m", # Cyan
]
RESET = "\u001b[0m"

shuffle(ALL_COLORS)
COLOR = ALL_COLORS[0]

if args.no_color:
COLOR = ""
RESET = ""

# https://stackoverflow.com/questions/14693701/how-can-i-remove-the-ansi-escape-sequences-from-a-string-in-python
ansi_escape = re.compile(r'\x1B\[[0-?]*[ -/]*[@-~]')

for line in sys.stdin:
print(
"{begin_color} {tag} {line} {end_color}".format(
begin_color=COLOR,
tag=tag,
line=ansi_escape.sub('', line.strip()),
end_color=RESET, # Reset
)
)
sys.stdout.flush()
73 changes: 0 additions & 73 deletions bin/construct_kube_config.py

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
72 changes: 72 additions & 0 deletions bin/deprecated/construct_kube_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
from __future__ import print_function, absolute_import
import os
import yaml
import sys

cert_auth_env_var = "CLIPPER_K8S_CERT_AUTH"
client_cert_env_var = "CLIPPER_K8S_CLIENT_CERT"
client_key_env_var = "CLIPPER_K8S_CLIENT_KEY"
pw_env_var = "CLIPPER_K8S_PASSWORD"
required_vars = [cert_auth_env_var, client_cert_env_var, client_key_env_var, pw_env_var]


def write_config(dest_path):

for v in required_vars:
if v not in os.environ:
print("{} not defined. Cannot construct kube config".format(v))
sys.exit(1)

cert_auth_data = os.environ[cert_auth_env_var]
client_cert_data = os.environ[client_cert_env_var]
client_key_data = os.environ[client_key_env_var]
pw_data = os.environ[pw_env_var]

base_config = {
"kind": "Config",
"preferences": {},
"current-context": "jenkins.clipper-k8s-testing.com",
"contexts": [
{
"name": "jenkins.clipper-k8s-testing.com",
"context": {
"cluster": "jenkins.clipper-k8s-testing.com",
"user": "jenkins.clipper-k8s-testing.com",
},
}
],
"clusters": [
{
"cluster": {
"certificate-authority-data": cert_auth_data,
"server": "https://api.jenkins.clipper-k8s-testing.com",
},
"name": "jenkins.clipper-k8s-testing.com",
}
],
"apiVersion": "v1",
"users": [
{
"name": "jenkins.clipper-k8s-testing.com",
"user": {
"username": "admin",
"password": pw_data,
"client-key-data": client_key_data,
"client-certificate-data": client_cert_data,
},
},
{
"name": "jenkins.clipper-k8s-testing.com-basic-auth",
"user": {"username": "admin", "password": pw_data},
},
],
}
with open(dest_path, "w") as f:
yaml.dump(base_config, f)


if __name__ == "__main__":
config_path = sys.argv[1]
config_path = os.path.abspath(os.path.expanduser(config_path))
print("Writing kube config to {}".format(config_path))
write_config(config_path)
File renamed without changes.
File renamed without changes.
Loading