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

Multi tenancy support #503

Merged
merged 68 commits into from
Jun 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
7397140
started impl, but need to dynamically set labels for prom and svcs
dcrankshaw May 11, 2018
82fa658
Added unbound port func, still debugging
simon-mo May 22, 2018
b79d36d
Remove all occurance of tmp in metrics
simon-mo May 22, 2018
1306a4a
Resolve hard coded prometheus path
simon-mo May 22, 2018
82974f2
Add label selection to replicas
simon-mo May 22, 2018
4e81a8e
Docker Multi-tenancy done
simon-mo May 28, 2018
2778c48
Add templating to config yamls; add cluster_name
simon-mo May 29, 2018
5cd53a7
Seperation of service done; need check conn
simon-mo May 29, 2018
a51eb61
Format Code
simon-mo May 29, 2018
33189bf
Add tests, fix label selector
simon-mo May 29, 2018
a2683ad
Format code
simon-mo May 29, 2018
dad441b
Don't connect after cleanup
simon-mo May 30, 2018
8bd5b3b
Format code
simon-mo May 30, 2018
7ecc8f2
Add debug line; tests pass locally; suspecting dangling containers
simon-mo May 30, 2018
f62922b
Checkout parallel build docker
simon-mo May 31, 2018
bcbda0b
Make persistent test less verbose
simon-mo May 31, 2018
b963d28
Make Unittest all parallel
simon-mo May 31, 2018
044d724
Make maven less verbose
simon-mo May 31, 2018
1c9c644
Change persistent_state_test 10->100
simon-mo May 31, 2018
3af90eb
Refactor tests to include cluster name
simon-mo Jun 1, 2018
ee71d06
Format code
simon-mo Jun 1, 2018
e10ff2e
Add logging support; push to test on ubuntu
simon-mo Jun 1, 2018
69c7f1b
Fix docker issue on ubuntu
simon-mo Jun 1, 2018
eabf428
Modify comment about prometheus
simon-mo Jun 1, 2018
7b0346d
Fix some kubernetes test
simon-mo Jun 1, 2018
ffeef95
Interpreable cluster name
simon-mo Jun 1, 2018
0548997
Format code
simon-mo Jun 1, 2018
94dfa14
Merge remote-tracking branch 'upstream/develop' into multi_tenancy_su…
simon-mo Jun 5, 2018
ebb5354
Remove temp_dir usage in deployer serialize func
simon-mo Jun 5, 2018
396ed5f
Address comment
simon-mo Jun 5, 2018
09bf075
Format code
simon-mo Jun 5, 2018
878a00f
Add more comments; shorten naming for cluster
simon-mo Jun 6, 2018
6f2fac5
Merge branch 'develop' into multi_tenancy_support
simon-mo Jun 6, 2018
134bfef
Merge branch 'develop' into multi_tenancy_support
simon-mo Jun 6, 2018
c7a5b3f
Fix proxy addr
simon-mo Jun 6, 2018
ebe5208
Format code
simon-mo Jun 6, 2018
2270c52
Wrap k8s metric test 2 in retry loop
simon-mo Jun 6, 2018
a7ccda2
Clean up test
simon-mo Jun 6, 2018
6ced033
Merge branch 'develop' of https://github.com/ucbrise/clipper into mul…
simon-mo Jun 6, 2018
3d37b5a
Format code
simon-mo Jun 6, 2018
caee0ba
Fix frontend exporter naming
simon-mo Jun 8, 2018
b447eb0
Add readme to CI process
simon-mo Jun 11, 2018
742d3da
Change testapp name for ekr
simon-mo Jun 11, 2018
83c7c67
Swap the python closure build step
simon-mo Jun 11, 2018
ffc321e
Add __registry__ argument
simon-mo Jun 13, 2018
105f0ef
Add registry to docker build process
simon-mo Jun 13, 2018
e5eae35
Add cluster info to image name
simon-mo Jun 13, 2018
17634b8
Merge branch 'develop' of https://github.com/ucbrise/clipper into mul…
simon-mo Jun 14, 2018
705394a
Format code
simon-mo Jun 14, 2018
4c2d8d2
Run unittests in clippertest
simon-mo Jun 14, 2018
eef8100
Address comment
simon-mo Jun 14, 2018
c0e53cd
fix clipper_docker_images location
simon-mo Jun 14, 2018
25f3ddc
Add set -x to debug "invalid reference format"
simon-mo Jun 14, 2018
9c5bb3b
Add debug lines
simon-mo Jun 15, 2018
ca1afd9
Fix the blank line issue in clipper_docker_images.txt
simon-mo Jun 15, 2018
db84d88
Don't pull ecr images
simon-mo Jun 15, 2018
1dc343a
Fix import
simon-mo Jun 15, 2018
1c3ba94
Set git hash length to at least 10 to prevent collision
simon-mo Jun 15, 2018
533acbe
Update registry in test
simon-mo Jun 15, 2018
855a307
Add version back to metrics
simon-mo Jun 18, 2018
99e2517
Remove CLIPPER_CONTAINER_REGISTRY constant in test
simon-mo Jun 18, 2018
d18d509
Revert "Remove CLIPPER_CONTAINER_REGISTRY constant in test"
simon-mo Jun 18, 2018
8a184ac
Add CLIPPER_CONTAINER_REGISTRY back
simon-mo Jun 18, 2018
1b70dd0
Format code
simon-mo Jun 19, 2018
9555086
Fix docker login in unnitest
simon-mo Jun 19, 2018
e5c2852
Fix image name in R test
simon-mo Jun 20, 2018
cd8d9d1
Fix CLIPPER_CONTAINER_REGISTRY in k8s metrics test
simon-mo Jun 20, 2018
0f58770
Refresh k8s metric tests;fix variable reuse
simon-mo Jun 21, 2018
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
29 changes: 29 additions & 0 deletions bin/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Description of CI process

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

## How does the CI process work


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:
- AWS_ACCESS_KEY_ID
- AWS_SECRET_ACCESS_KEY
- CLIPPER_K8S_CERT_AUTH
- CLIPPER_K8S_CLIENT_CERT
- CLIPPER_K8S_CLIENT_KEY
- CLIPPER_K8S_PASSWORD
- CLIPPER_TESTING_DOCKERHUB_PASSWORD
2. Jenkins will call `run_ci.sh`. It does three things:
- It calls `build_docker_images.sh` to build all the docker images
- Then it runs unittests docker container for python2 and python3
- Each unittest cotnainer will run `ci_checks.sh`
3. `ci_checks.sh` will run two things:
- (Only in Python2) It runs `check_foramt.sh` to run the linter for C++ and Python
- 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)
- 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.
20 changes: 13 additions & 7 deletions bin/build_docker_images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# pin their docker images to the minor version and get updates with new patches
# automatically.


set -x
set -e
set -u
set -o pipefail
Expand All @@ -31,7 +31,7 @@ cd $CLIPPER_ROOT

# Initialize tags
version_tag=$(<VERSION.txt)
sha_tag=`git rev-parse --verify --short HEAD`
sha_tag=`git rev-parse --verify --short=10 HEAD`

######## Utilities for managing versioning ############
# From https://github.com/cloudflare/semver_bash/blob/c1133faf0efe17767b654b213f212c326df73fa3/semver.sh
Expand Down Expand Up @@ -189,7 +189,11 @@ set_version_tag () {

set_version_tag

namespace="clipper"
namespace=$(docker info | grep Username | awk '{ print $2 }')

# Clear clipper_docker_images.txt for future write
rm -f $CLIPPER_ROOT/bin/clipper_docker_images.txt
touch $CLIPPER_ROOT/bin/clipper_docker_images.txt

# We build images with the SHA tag to try to prevent clobbering other images
# being built from different branches on the same machine. This is particularly
Expand All @@ -211,11 +215,15 @@ create_image () {


echo "Building $namespace/$image:$sha_tag from file $dockerfile"
time docker build --build-arg CODE_VERSION=$sha_tag $rpc_version -t $namespace/$image:$sha_tag \
time docker build --build-arg CODE_VERSION=$sha_tag --build-arg REGISTRY=$namespace $rpc_version -t $namespace/$image:$sha_tag \
-f dockerfiles/$dockerfile $CLIPPER_ROOT
docker tag $namespace/$image:$sha_tag $namespace/$image:$version_tag

echo "Image tag appended to CLIPPER_ROOT/bin/clipper_docker_images.txt"
echo "$namespace/$image:$sha_tag" >> $CLIPPER_ROOT/bin/clipper_docker_images.txt

if [ "$publish" = true ] && [ "$public" = true ] ; then
docker tag $namespace/$image:$sha_tag $namespace/$image:$version_tag

echo "Publishing $namespace/$image:$sha_tag"
docker push $namespace/$image:$sha_tag
echo "Publishing $namespace/$image:$version_tag"
Expand Down Expand Up @@ -285,7 +293,6 @@ build_images () {
create_image pyspark-container PySparkContainerDockerfile $public py &
create_image pyspark35-container PySparkContainerDockerfile $public py35 &
create_image pyspark36-container PySparkContainerDockerfile $public py36 &
wait

create_image tf-container TensorFlowDockerfile $public py &
create_image tf35-container TensorFlowDockerfile $public py35 &
Expand All @@ -295,7 +302,6 @@ build_images () {
create_image pytorch-container PyTorchContainerDockerfile $public py &
create_image pytorch35-container PyTorchContainerDockerfile $public py35 &
create_image pytorch36-container PyTorchContainerDockerfile $public py36 &
wait

# See issue #475
# create_image caffe2-onnx-container Caffe2OnnxDockerfile $public py
Expand Down
8 changes: 6 additions & 2 deletions bin/ci_checks.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env bash

set -x
set -e
set -u
set -o pipefail
Expand All @@ -26,10 +27,10 @@ tag=$(<VERSION.txt)
cd -

# Log in to Kubernetes Docker repo
$DIR/aws_docker_repo_login.sh
# $DIR/aws_docker_repo_login.sh

# Test docker login
docker pull 568959175238.dkr.ecr.us-west-1.amazonaws.com/clipper/query_frontend:$tag
# docker pull 568959175238.dkr.ecr.us-west-1.amazonaws.com/clipper/query_frontend:$tag

# Set up credentials for K8s testing cluster.
export KUBECONFIG=~/kubeconfig_$(date +"%Y%m%d%H%M%S")
Expand All @@ -51,6 +52,9 @@ kubectl get nodes
# Set kubectl proxy for k8s tests later
kubectl proxy --port 8080 &

# Login to clippertesting dockerhub here
docker login --username="clippertesting" --password=$CLIPPER_TESTING_DOCKERHUB_PASSWORD

if [[ $run_all = "true" ]]; then
$DIR/check_format.sh
$DIR/run_unittests.sh
Expand Down
24 changes: 16 additions & 8 deletions bin/run_ci.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env bash

set -x
set -e
set -u
set -o pipefail
Expand All @@ -21,12 +22,15 @@ tag=$(<VERSION.txt)
# Build docker images
./bin/build_docker_images.sh

# Tag and push the latest version of the Clipper Docker images to the container registry
# for the Kubernetes testing cluster
docker tag clipper/query_frontend:$tag 568959175238.dkr.ecr.us-west-1.amazonaws.com/clipper/query_frontend:$tag
docker push 568959175238.dkr.ecr.us-west-1.amazonaws.com/clipper/query_frontend:$tag
docker tag clipper/management_frontend:$tag 568959175238.dkr.ecr.us-west-1.amazonaws.com/clipper/management_frontend:$tag
docker push 568959175238.dkr.ecr.us-west-1.amazonaws.com/clipper/management_frontend:$tag
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't want the docker build images script to automatically push the images. Remember, that script is very useful during development for rebuilding images locally. Instead, let's change build_docker_images.sh to write the names of all the containers it builds to a file (something like clipper_docker_images.txt) and then you can push all those images with the following one-liner (from https://stackoverflow.com/a/13939059/814642):

while read in; do docker push "$in"; done < clipper_docker_images.txt

echo "Pushing the following images"
cat ./bin/clipper_docker_images.txt

# Push docker images
while read in; do docker push "$in"; done < ./bin/clipper_docker_images.txt


CLIPPER_REGISTRY=$(docker info | grep Username | awk '{ print $2 }')
sha_tag=$(git rev-parse --verify --short=10 HEAD)

# Run tests
docker run --rm --network=host -v /var/run/docker.sock:/var/run/docker.sock -v /tmp:/tmp \
Expand All @@ -36,7 +40,9 @@ docker run --rm --network=host -v /var/run/docker.sock:/var/run/docker.sock -v /
-e CLIPPER_K8S_PASSWORD=$CLIPPER_K8S_PASSWORD \
-e AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID \
-e AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY \
clipper/unittests:$tag
-e CLIPPER_REGISTRY=$CLIPPER_REGISTRY \
-e CLIPPER_TESTING_DOCKERHUB_PASSWORD=$CLIPPER_TESTING_DOCKERHUB_PASSWORD \
$CLIPPER_REGISTRY/unittests:$sha_tag

# Python 3 unittests
docker run --rm --network=host -v /var/run/docker.sock:/var/run/docker.sock -v /tmp:/tmp \
Expand All @@ -46,4 +52,6 @@ docker run --rm --network=host -v /var/run/docker.sock:/var/run/docker.sock -v /
-e CLIPPER_K8S_PASSWORD=$CLIPPER_K8S_PASSWORD \
-e AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID \
-e AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY \
clipper/py35tests:$tag
-e CLIPPER_REGISTRY=$CLIPPER_REGISTRY \
-e CLIPPER_TESTING_DOCKERHUB_PASSWORD=$CLIPPER_TESTING_DOCKERHUB_PASSWORD \
$CLIPPER_REGISTRY/py35tests:$sha_tag
21 changes: 16 additions & 5 deletions bin/run_unittests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ function run_jvm_container_tests {
echo "Running JVM container tests..."
cd $DIR
cd ../containers/jvm
mvn test
mvn test -q
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

}

function run_r_container_tests {
Expand Down Expand Up @@ -129,6 +129,10 @@ function run_frontend_tests {
function run_integration_tests {
echo -e "\nRunning integration tests\n\n"
cd $DIR

echo "GREPTHIS Docker State before:"
docker ps

python ../integration-tests/clipper_admin_tests.py
python ../integration-tests/many_apps_many_models.py 2 3
python ../integration-tests/deploy_pyspark_models.py
Expand All @@ -137,13 +141,20 @@ function run_integration_tests {
python ../integration-tests/kubernetes_integration_test.py
python ../integration-tests/kubernetes_multi_frontend.py
python ../integration-tests/deploy_tensorflow_models.py
python ../integration-tests/deploy_mxnet_models.py
python ../integration-tests/deploy_pytorch_models.py
python ../integration-tests/deploy_mxnet_models.py
python ../integration-tests/deploy_pytorch_models.py
# See issue #475
# python ../integration-tests/deploy_pytorch_to_caffe2_with_onnx.py
../integration-tests/r_integration_test/rclipper_test.sh
python ../integration-tests/clipper_metric_docker.py
python ../integration-tests/clipper_metric_kube.py
python ../integration-tests/clipper_metric_docker.py
python ../integration-tests/clipper_metric_kube.py
python ../integration-tests/multi_tenancy_test.py
python ../integration-tests/multi_tenancy_test.py --kubernetes
python ../integration-tests/kubernetes_namespace.py

echo "GREPTHIS Docker State After"
docker ps

echo "Exit code: $?"
echo "GREPTHIS Done running unit tests"
}
Expand Down
2 changes: 1 addition & 1 deletion clipper_admin/clipper_admin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
from .kubernetes.kubernetes_container_manager import KubernetesContainerManager
from .clipper_admin import *
from . import deployers
from .version import __version__
from .version import __version__, __registry__
from .exceptions import ClipperException, UnconnectedException
Loading