Skip to content

Commit

Permalink
Merge branch 'odh-main' into tarilabs-20240318-midstreamsync
Browse files Browse the repository at this point in the history
  • Loading branch information
tarilabs committed Mar 18, 2024
2 parents e9167d9 + ffa5c3f commit aa831d5
Show file tree
Hide file tree
Showing 11 changed files with 304 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .github/pull.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
version: "1"
rules:
- base: main
upstream: kubeflow:main
label: "tide/merge-method-merge"
21 changes: 21 additions & 0 deletions .github/workflows/build-image-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,24 @@ jobs:
env:
VERSION: ${{ steps.tags.outputs.tag }}
run: ./scripts/build_deploy.sh
- name: Start Kind Cluster
uses: helm/kind-action@v1.9.0
- name: Load Local Registry Test Image
env:
IMG: "quay.io/opendatahub/model-registry:${{ steps.tags.outputs.tag }}"
run: |
kind load docker-image -n chart-testing ${IMG}
- name: Deploy Operator With Test Image
env:
IMG: "quay.io/opendatahub/model-registry:${{ steps.tags.outputs.tag }}"
run: |
echo "Deploying operator from model-registry-operator branch ${BRANCH}"
kubectl apply -k "https://github.com/opendatahub-io/model-registry-operator.git/config/default?ref=${BRANCH}"
kubectl set env -n model-registry-operator-system deployment/model-registry-operator-controller-manager REST_IMAGE="${IMG}"
- name: Create Test Registry
run: |
kubectl apply -k "https://github.com/opendatahub-io/model-registry-operator.git/config/samples/postgres?ref=${BRANCH}"
kubectl get mr
- name: Wait for Test Registry Deployment
run: |
kubectl wait --for=condition=Available=true modelregistries/modelregistry-sample --timeout=5m
7 changes: 7 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,10 @@ jobs:
fi
- name: Unit tests
run: make test-cover
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4.0.1
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
files: coverage.txt
fail_ci_if_error: true
8 changes: 8 additions & 0 deletions .github/workflows/python-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@ jobs:
else
nox --python=${{ matrix.python }}
fi
- name: Upload coverage report
uses: codecov/codecov-action@v4.0.1
if: always() && matrix.session == 'tests'
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
files: coverage.xml
fail_ci_if_error: true
- name: Upload documentation
if: matrix.session == 'docs-build'
uses: actions/upload-artifact@v4
Expand Down
30 changes: 23 additions & 7 deletions OWNERS
Original file line number Diff line number Diff line change
@@ -1,9 +1,25 @@
# DO NOT EDIT; this file is auto-generated using https://github.com/openshift/ci-tools.
# Fetched from https://github.com/opendatahub-io/codeflare-operator root OWNERS
# If the repo had OWNERS_ALIASES then the aliases were expanded
# Logins who are not members of 'openshift' organization were filtered out
# See the OWNERS docs: https://git.k8s.io/community/contributors/guide/owners.md

approvers:
- andreyvelich
- ckadner
- tarilabs
- rareddy
- Tomcli
- zijianjoy
- dhirajsb
- isinyaaa
- lampajr
- nehachopra27
- rareddy
- rkubis
- tarilabs
- tonyxrmdavidson
options: {}
reviewers:
- andreyvelich
- dhirajsb
- isinyaaa
- lampajr
- nehachopra27
- rareddy
- rkubis
- tarilabs
- tonyxrmdavidson
2 changes: 1 addition & 1 deletion clients/python/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "model-registry"
version = "0.1.0"
version = "0.1.2"
description = "Client for Kubeflow Model Registry"
authors = ["Isabella Basso do Amaral <idoamara@redhat.com>"]
license = "Apache-2.0"
Expand Down
10 changes: 10 additions & 0 deletions openshift-ci/resources/opendatahub-catalogue-source.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: operators.coreos.com/v1alpha1
kind: CatalogSource
metadata:
name: model-registry-test-source
namespace: openshift-marketplace
spec:
displayName: ''
image: 'registry-proxy.engineering.redhat.com/rh-osbs/iib:688477'
publisher: ''
sourceType: grpc
38 changes: 38 additions & 0 deletions openshift-ci/resources/opendatahub-data-science-cluster.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
kind: DataScienceCluster
apiVersion: datasciencecluster.opendatahub.io/v1
metadata:
labels:
app.kubernetes.io/created-by: opendatahub-operator
app.kubernetes.io/instance: default
app.kubernetes.io/managed-by: kustomize
app.kubernetes.io/name: datasciencecluster
app.kubernetes.io/part-of: opendatahub-operator
name: default-dsc
spec:
components:
codeflare:
managementState: Removed
dashboard:
managementState: Managed
datasciencepipelines:
managementState: Managed
kserve:
managementState: Managed
serving:
ingressGateway:
certificate:
type: SelfSigned
managementState: Managed
name: knative-serving
kueue:
managementState: Removed
modelmeshserving:
managementState: Managed
modelregistry:
managementState: Managed
ray:
managementState: Removed
trustyai:
managementState: Managed
workbenches:
managementState: Managed
11 changes: 11 additions & 0 deletions openshift-ci/resources/opendatahub-operator-deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: operators.coreos.com/v1alpha1
kind: Subscription
metadata:
name: rhods-operator
namespace: openshift-operators
spec:
channel: odh-nightlies
installPlanApproval: Automatic
name: rhods-operator
source: model-registry-test-source
sourceNamespace: openshift-marketplace
4 changes: 4 additions & 0 deletions openshift-ci/scripts/colour_text_variables.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export RED='\033[0;31m'
export GREEN='\033[0;32m'
export NC='\033[0m'
export YELLOW='\033[0;33m'
176 changes: 176 additions & 0 deletions openshift-ci/scripts/oci-model-registry-deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
#!/bin/bash

# Define variables for ODH nightly deployment
OPENDATAHUB_CATALOGUE_SOURCE_CREATE="../resources/opendatahub-catalogue-source.yaml"
OPENDATAHUB_DEPLOY_MANIFEST="../resources/opendatahub-operator-deploy.yaml"
DATA_SCIENCE_CLUSTER_MANIFEST="../resources/opendatahub-data-science-cluster.yaml"
MODEL_REGISTRY_OPERATOR_GIT_URL="https://github.com/opendatahub-io/model-registry-operator.git"
source colour_text_variables.sh

# Function to deploy and wait for deployment
deploy_and_wait() {
local manifest=$1
local resource_name=$(basename -s .yaml $manifest)

echo "Deploying $resource_name from $manifest..."

if oc apply -f $manifest --wait=true --timeout=300s; then
echo "Deployment of $resource_name succeeded."
else
echo "Error: Deployment of $resource_name failed or timed out." >&2
return 1
fi
}

# Deploy resource and wait for readiness
deploy_resource() {
local manifest=$1
echo $manifest "deploying"
deploy_and_wait $manifest
}

# Function to clone a Git repository and deploy the appropriate
clone_deploy_model_registry_operator_crd_files() {
local url="temp_repo/config/samples/mysql/"
local files=("mysql-db.yaml" "modelregistry_v1alpha1_modelregistry.yaml")
# Clone the Git repository
git clone "$MODEL_REGISTRY_OPERATOR_GIT_URL" temp_repo

#Change the deployment serviceRoute to enabled
yq eval '.spec.rest.serviceRoute = "enabled"' -i "$url${files[1]}"

# Deploy the model-registry crd files
for file in "${files[@]}"; do
local path_and_file="$url$file"
oc apply -f "$path_and_file" --wait=true --timeout=300s >/tmp/oc_output 2>&1 && rm /tmp/oc_output
done

# Remove temp_repo
rm -rf temp_repo
}

check_deployment_availability() {
local namespace="$1"
local deployment="$2"
local timeout=300 # Timeout in seconds
local start_time=$(date +%s)

# Loop until timeout
while (( $(date +%s) - start_time < timeout )); do
# Get the availability status of the deployment
local deployment_status=$(oc get deployment "$deployment" -n "$namespace" --no-headers -o custom-columns=:.status.availableReplicas)

# Check if the deployment is available
if [[ $deployment_status != "" ]]; then
echo -e "${GREEN}✔ Success:${NC} Deployment $deployment is available"
return 0 # Success
fi

sleep 5 # Wait for 5 seconds before checking again
done

echo -e "${RED}X Fail:${NC} Timeout reached. Deployment $deployment did not become available within $timeout seconds"
return 1 # Failure
}

check_pod_status() {
local namespace="$1"
local pod_selector="$2"
local expected_ready_containers="$3"
local timeout=300 # Timeout in seconds
local start_time=$(date +%s)

# Loop until timeout
while (( $(date +%s) - start_time < timeout )); do
# Get the list of pods in the specified namespace matching the provided partial names
local pod_list=$(oc get pods -n $namespace $pod_selector --no-headers -o custom-columns=NAME:.metadata.name)

# Iterate over each pod in the list
while IFS= read -r pod_name; do
# Get the pod info
local pod_info=$(oc get pod "$pod_name" -n "$namespace" --no-headers)

# Extract pod status and ready status from the info
local pod_name=$(echo "$pod_info" | awk '{print $1}')
local pod_status=$(echo "$pod_info" | awk '{print $3}')
local pod_ready=$(echo "$pod_info" | awk '{print $2}')
local ready_containers=$(echo "$pod_ready" | cut -d'/' -f1)

# Check if the pod is Running and all containers are ready
if [[ $pod_status == "Running" ]] && [[ $ready_containers -eq $expected_ready_containers ]]; then
echo -e "${GREEN}✔ Success:${NC} Pod $pod_name is running and $ready_containers out of $expected_ready_containers containers are ready"
return 0 # Success
else
echo -e "${YELLOW}! Info:${NC} Pod $pod_name is not running or does not have $expected_ready_containers containers ready"
fi
done <<< "$pod_list"

sleep 5 # Wait for 5 seconds before checking again
done

echo -e "${RED}X Failure:${NC} Timeout reached. No pod matching '$pod_name_partial' became ready within $timeout seconds"
return 1 # Failure
}

check_route_status() {
local namespace="$1"
local route_name="$2"
local key="items"
local interval=5
local timeout=300
local start_time=$(date +%s)

while (( $(date +%s) - start_time < timeout )); do
# Get the route URL
local route=$(oc get route -n "$namespace" "$route_name" -o jsonpath='{.spec.host}')
local route_url="http://$route"

if [[ -z "$route_url" ]]; then
echo -e "${RED}X Fail:${NC} Route '$route_name' does not exist in namespace '$namespace'"
return 1
else
echo -e "${GREEN}✔ Success:${NC} Route '$route_name' exists in namespace '$namespace'"
fi

# Test if the route is live
local response=$(curl -s -o /dev/null -w "%{http_code}" "$route_url/api/model_registry/v1alpha2/registered_models")

# Check if the response status code is 200 OK or 404 Not Found
if [[ "$response" == "200" ]]; then
echo -e "${GREEN}✔ Success:${NC} Route server is reachable. Status code: 200 OK"
return 0
elif [[ "$response" == "404" ]]; then
echo -e "${GREEN}✔ Success:${NC} Route server is reachable. Status code: 404 Not Found"
return 0
else
echo -e "${RED}X Fail:${NC} Route server is unreachable. Status code: $response"
fi

sleep "$interval"
done

echo -e "${RED}X Fail:${NC} Timeout reached. Route '$route_name' did not become live within $timeout seconds."
return 1
}

# Run the deployment tests.
run_deployment_tests() {
check_deployment_availability default model-registry-db
check_deployment_availability default modelregistry-sample
check_pod_status default "-l name=model-registry-db" 1
check_pod_status default "-l app=modelregistry-sample" 2
check_route_status "default" "modelregistry-sample-http"
}

# Main function for orchestrating deployments
main() {
deploy_and_wait $OPENDATAHUB_CATALOGUE_SOURCE_CREATE
deploy_resource $OPENDATAHUB_DEPLOY_MANIFEST
deploy_resource $DATA_SCIENCE_CLUSTER_MANIFEST
check_pod_status "opendatahub" "-l component.opendatahub.io/name=model-registry-operator" 2
clone_deploy_model_registry_operator_crd_files
run_deployment_tests
}

# Execute main function
main

0 comments on commit aa831d5

Please sign in to comment.