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

[Sync] kserve/modelmesh-serving-v0.11.0-rc0 to main branch #107

Merged
merged 19 commits into from
Jun 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
50 changes: 0 additions & 50 deletions .github/workflows/build-and-push.yml

This file was deleted.

151 changes: 151 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
name: Build

on:
push:
branches: [master]
tags:
- 'v*'
paths-ignore:
- '.github/**'
- '.tekton/**'
- '**.md'
- 'docs/**'
- 'fvt/**'
- 'proto/**'
pull_request:
branches: [master]
paths-ignore:
- '.github/**'
- '.tekton/**'
- '**.md'
- 'docs/**'
- 'fvt/**'
- 'proto/**'

env:
IMAGE_NAME: "kserve/modelmesh-controller"
DEV_IMAGE_NAME: "kserve/modelmesh-controller-develop"

jobs:
build:
runs-on: ubuntu-latest
env:
CI: true
services:
registry:
image: registry:2
ports:
- 5000:5000
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup QEMU
uses: docker/setup-qemu-action@v2

- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v2
with:
driver-opts: network=host

- name: Login to DockerHub
if: github.event_name == 'push'
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_ACCESS_TOKEN }}

- name: Export docker build args
run: |
# see: scripts/build_devimage.sh
# see: scripts/build_docker.sh

# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')

# Generate PR tag from github.ref == "refs/pull/123/merge"
[ "$VERSION" == "merge" ] && VERSION=$(echo "${{ github.ref }}" | sed -e 's,refs/pull/\(.*\)/merge,pr-\1,')

# Use Docker `latest` tag convention
[ "$VERSION" == "main" ] && VERSION=latest

git_commit_sha="$(git rev-parse HEAD)"
DOCKER_TAG="$(git rev-parse --abbrev-ref HEAD)-$(date -u +"%Y%m%dT%H%M%S%Z")"

# generate dev image tag
DEV_DEPS="./scripts/build_devimage.sh Dockerfile.develop go.mod go.sum .pre-commit-config.yaml"
DEV_IMG_TAG=$(cat $(ls ${DEV_DEPS}) | sha1sum | head -c 16)

# In order for the controller image build to find the developer image
# we need to push the developer image to a registry since the docker
# exporter does not currently support exporting manifest lists.
# When running in a PR we need to use the local image registry service
# because the DockerHub push secret is not available on forked PRs.
# When pushing to main we do have access to the docker.io push secrets
# so we push to the public DockerHub registry.
# https://github.com/docker/buildx/issues/59#issuecomment-1189999088

DEV_IMAGE="docker.io/${{ env.DEV_IMAGE_NAME }}:$DEV_IMG_TAG"
DEV_IMAGE_EXISTS=false

# Check if the developer image already exists in the registry. The
# developer image doesn't change often and is costly to build. We want
# to avoid rebuilding it unnecessarily. If we need to build it and if
# this workflow is running on a forked PR, then we must use the local
# image registry.
if $(docker manifest inspect $DEV_IMAGE >/dev/null ); then
DEV_IMAGE_EXISTS=true
else
if [ "${{ github.event_name }}" == "pull_request" ]; then
DEV_IMAGE="localhost:5000/${{ env.DEV_IMAGE_NAME }}:$DEV_IMG_TAG"
fi
fi

# add env vars for following steps
echo "IMAGE_TAG=$VERSION" >> $GITHUB_ENV
echo "GIT_COMMIT_SHA=$git_commit_sha" >> $GITHUB_ENV
echo "IMAGE_VERSION=$DOCKER_TAG" >> $GITHUB_ENV
echo "DEV_IMAGE=$DEV_IMAGE" >> $GITHUB_ENV
echo "DEV_IMAGE_EXISTS=$DEV_IMAGE_EXISTS" >> $GITHUB_ENV

# print env vars for debugging
cat "$GITHUB_ENV"

- name: Build and push developer image
uses: docker/build-push-action@v4
if: env.DEV_IMAGE_EXISTS == 'false'
with:
platforms: linux/amd64
context: .
file: Dockerfile.develop
push: true
tags: ${{ env.DEV_IMAGE }}
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Set dev image for lint and test
run: |
docker run --rm ${{ env.DEV_IMAGE }} go version
echo -n "${{ env.DEV_IMAGE }}" > .develop_image_name

- name: Run lint
run: ./scripts/develop.sh make fmt

- name: Run unit test
run: ./scripts/develop.sh make test

- name: Build and push controller image
uses: docker/build-push-action@v4
with:
platforms: linux/amd64,linux/arm64,linux/ppc64le,linux/s390x
context: .
target: runtime
pull: true
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}
build-args: |
DEV_IMAGE=${{ env.DEV_IMAGE }}
IMAGE_VERSION=${{ env.IMAGE_VERSION }}
COMMIT_SHA=${{ env.GIT_COMMIT_SHA }}
cache-from: type=gha
cache-to: type=gha,mode=max
75 changes: 59 additions & 16 deletions .github/workflows/run-fvt.yml → .github/workflows/fvt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,41 @@ on:
- '**'
- '!.github/**'
- '!.tekton/**'
- '!docs/**'
- '!**.md'
- '.github/workflows/run-fvt.yml'
- '!docs/**'
- '.github/workflows/fvt.yml'

jobs:
test:
fvt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
- name: Free up disk space
run: |
# https://github.com/actions/runner-images/issues/2840#issuecomment-790492173
# du -sh /* 2> /dev/null | sort -rh 2> /dev/null | head
# du -h -d2 /usr 2> /dev/null | sort -rh 2> /dev/null | head
echo "Check free disk space before cleanup."
df -h
echo "Removing non-essential tools and libraries."
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
sudo rm -rf /opt/ghc
sudo rm -rf /usr/share/dotnet
sudo rm -rf /usr/local/share/boost
# delete libraries for Android (12G), PowerShell (1.3G), Swift (1.7G)
sudo rm -rf /usr/local/lib/android
sudo rm -rf /usr/local/share/powershell
sudo rm -rf /usr/share/swift
echo "Check free disk space after cleanup."
df -h

- name: Checkout
uses: actions/checkout@v3

- name: Setup go
uses: actions/setup-go@v4
with:
go-version: '1.18.7'
go-version: '1.19'

- name: Start Minikube
uses: medyagh/setup-minikube@v0.0.11
id: minikube
Expand All @@ -28,63 +51,83 @@ jobs:
kubernetes-version: v1.25.2
cpus: max
memory: max

- name: Check pods
run: |
sleep 30
kubectl get pods -n kube-system

- name: Set controller image tag
run: echo "IMAGE_TAG=$(date +'%Y%m%dT%H%M%S%Z')" >> $GITHUB_ENV

- name: Update configs
# Update the image tag and reduce some resource request amounts to allow FVTs to run
# on reduced resource environments. Also the RollingUpdate strategy for Runtime deployments
# is adjusted for these environments.
# Disable the torchserve ServingRuntime for now (insufficent resources to run them all).
# on reduced resource environments. The RollingUpdate strategy for Runtime deployments
# is also adjusted for these environments.
# Disable the torchserve ServingRuntime for now (insufficient resources to run them all).
run: |
sed -i 's/newTag:.*$/newTag: '"${{ env.IMAGE_TAG }}"'/' config/manager/kustomization.yaml
sed -i '0,/cpu:.*$/s/cpu:.*$/cpu: 100m/' \
config/default/config-defaults.yaml \
config/runtimes/mlserver-0.x.yaml \
config/runtimes/mlserver-1.x.yaml \
config/runtimes/triton-2.x.yaml \
config/runtimes/ovms-1.x.yaml
sed -i 's/memory:.*$/memory: 512Mi/g' \
config/runtimes/mlserver-0.x.yaml \
config/runtimes/mlserver-1.x.yaml \
config/runtimes/triton-2.x.yaml \
config/runtimes/ovms-1.x.yaml
sed -i 's/maxSurge:.*$/maxSurge: 0/' config/internal/base/deployment.yaml.tmpl
sed -i 's/maxUnavailable:.*$/maxUnavailable: 100%/' config/internal/base/deployment.yaml.tmpl
echo -e '\n disabled: true' >> config/runtimes/torchserve-0.x.yaml

- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Build Controller image
env:
DOCKER_BUILDKIT: 1
run: |
eval $(minikube -p minikube docker-env)
make build.develop
./scripts/build_docker.sh --target runtime --tag ${{ env.IMAGE_TAG }}

- name: Install ModelMesh Serving
run: |
kubectl create ns modelmesh-serving
./scripts/install.sh --namespace modelmesh-serving --fvt --dev-mode-logging
- name: Free up disk space

- name: Prune docker images
run: |
eval $(minikube -p minikube docker-env)
echo "Pruning images"
echo "Pruning docker images on GH action runner node"
docker image prune -a -f
docker system df
df -h

- name: Pre-pull runtime images
run: |
eval $(minikube -p minikube docker-env)
docker pull nvcr.io/nvidia/tritonserver:21.06.1-py3
docker pull seldonio/mlserver:0.5.2
docker pull nvcr.io/nvidia/tritonserver:23.04-py3
docker pull seldonio/mlserver:1.3.2
docker pull openvino/model_server:2022.2
<<<<<<< HEAD:.github/workflows/run-fvt.yml
# docker pull pytorch/torchserve:0.6.0-cpu
docker pull kserve/modelmesh:v0.11.0-alpha
docker pull kserve/modelmesh-runtime-adapter:v0.11.0-alpha
docker pull kserve/rest-proxy:v0.10.0
=======
# docker pull pytorch/torchserve:0.7.1-cpu
docker pull kserve/modelmesh-runtime-adapter
docker pull kserve/rest-proxy
docker pull kserve/modelmesh

>>>>>>> v0.11.0-rc0:.github/workflows/fvt.yml
- name: Check installation
run: |
eval $(minikube -p minikube docker-env)
docker images
kubectl get pods
kubectl get clusterservingruntimes

- name: Run FVTs
run: |
go install github.com/onsi/ginkgo/v2/ginkgo
Expand Down
9 changes: 8 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,16 @@ jobs:
runs-on: ubuntu-latest
env:
CI: true
DOCKER_BUILDKIT: 1
steps:
- uses: actions/checkout@v2
- name: Checkout
uses: actions/checkout@v3

- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Build develop image
run: make build.develop

- name: Run lint
run: ./scripts/develop.sh make fmt
19 changes: 14 additions & 5 deletions .github/workflows/unit-test.yml → .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,31 @@
name: Unit Test
name: Test

on:
pull_request:
branches: [master]
paths-ignore:
- 'docs/**'
- '**.md'
- '.github/**'
- '.tekton/**'
- '**.md'
- 'docs/**'
- 'fvt/**'
- 'proto/**'

jobs:
test:
runs-on: ubuntu-latest
env:
CI: true
DOCKER_BUILDKIT: 1
steps:
- uses: actions/checkout@v2
- name: Build develop image
- name: Checkout
uses: actions/checkout@v3

- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Build developer image
run: make build.develop

- name: Run unit tests
run: ./scripts/develop.sh make test
Loading