-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Switch to Production ACR (#252)
Switch off of existing AMR ACR for Production one PR also introduces a boolean "Run all e2e tests" which if checked will run e2e on all models, overriding whether supported_models.yaml was updated. This was necessary for importing models into the new prod ACR.
- Loading branch information
1 parent
37485fa
commit cc53389
Showing
6 changed files
with
153 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,11 @@ on: | |
types: | ||
- completed | ||
workflow_dispatch: | ||
inputs: | ||
force-run-all: | ||
type: boolean | ||
default: false | ||
description: "Test all models for E2E" | ||
|
||
env: | ||
GO_VERSION: "1.20" | ||
|
@@ -30,13 +35,17 @@ jobs: | |
submodules: true | ||
fetch-depth: 0 | ||
|
||
- name: Set FORCE_RUN_ALL Flag | ||
run: echo "FORCE_RUN_ALL=${{ github.event_name == 'workflow_dispatch' && github.event.inputs.force-run-all == 'true' }}" >> $GITHUB_ENV | ||
|
||
# This script should output a JSON array of model names | ||
- name: Determine Affected Models | ||
id: affected_models | ||
run: | | ||
PR_BRANCH=${{ env.BRANCH_NAME }} \ | ||
FORCE_RUN_ALL=${{ env.FORCE_RUN_ALL }} \ | ||
python3 .github/workflows/kind-cluster/determine_models.py | ||
- name: Print Determined Models | ||
run: | | ||
echo "Output from determine_models: ${{ steps.affected_models.outputs.matrix }}" | ||
|
@@ -97,15 +106,9 @@ jobs: | |
with: | ||
submodules: true | ||
fetch-depth: 0 | ||
|
||
- name: Install Azure CLI latest | ||
run: | | ||
if ! which az > /dev/null; then | ||
echo "Azure CLI not found. Installing..." | ||
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash | ||
else | ||
echo "Azure CLI already installed." | ||
fi | ||
|
||
- name: Set OSS Flag | ||
run: echo "MODEL_IS_OSS=${{ matrix.model.OSS }}" >> $GITHUB_ENV | ||
|
||
- name: 'Az CLI login' | ||
uses: azure/[email protected] | ||
|
@@ -114,16 +117,16 @@ jobs: | |
tenant-id: ${{ secrets.AZURE_TENANT_ID }} | ||
allow-no-subscriptions: true | ||
|
||
- name: 'Set subscription' | ||
- name: 'Set Prod Subscription' | ||
run: az account set --subscription ${{secrets.AZURE_SUBSCRIPTION_ID}} | ||
|
||
- name: 'Check if Image exists in Test ACR' | ||
id: check_test_image | ||
- name: 'Check if Image exists in Prod ACR' | ||
id: check_prod_image | ||
run: | | ||
ACR_NAME=${{ secrets.ACR_AMRT_USERNAME }} | ||
IMAGE_NAME=${{ matrix.model.name }} | ||
ACR_NAME=${{ secrets.PROD_ACR_USERNAME }} | ||
IMAGE_NAME=unlisted/aks/kaito/kaito-${{ matrix.model.name }} | ||
TAG=${{ matrix.model.tag }} | ||
# Use '|| true' to prevent script from exiting with an error if the repository is not found | ||
TAGS=$(az acr repository show-tags -n $ACR_NAME --repository $IMAGE_NAME --output tsv || true) | ||
|
@@ -138,11 +141,14 @@ jobs: | |
echo "Image $IMAGE_NAME:$TAG not found in $ACR_NAME." | ||
fi | ||
fi | ||
- name: 'Check if Image exists in Prod ACR' | ||
id: check_prod_image | ||
- name: 'Set Test Subscription' | ||
run: az account set --subscription ${{secrets.AZURE_SUBSCRIPTION_ID}} | ||
|
||
- name: 'Check if Image exists in Test ACR' | ||
id: check_test_image | ||
run: | | ||
ACR_NAME=${{ secrets.ACR_AMR_USERNAME }} | ||
ACR_NAME=${{ secrets.ACR_AMRT_USERNAME }} | ||
IMAGE_NAME=${{ matrix.model.name }} | ||
TAG=${{ matrix.model.tag }} | ||
|
@@ -345,23 +351,31 @@ jobs: | |
fi | ||
- name: Move from Test to Prod ACR | ||
if: steps.check_test_image.outputs.IMAGE_EXISTS == 'true' && steps.check_prod_image.outputs.IMAGE_EXISTS == 'false' && github.event_name == 'workflow_dispatch' | ||
if: steps.check_test_image.outputs.IMAGE_EXISTS == 'true' && steps.check_prod_image.outputs.IMAGE_EXISTS == 'false' && github.event_name == 'workflow_dispatch' && env.MODEL_IS_OSS == 'true' | ||
run: | | ||
# This should only run if: | ||
# This should only run if: | ||
# 1. All prior steps have succeeed (Given) | ||
# 2. Image exists in test ACR repo but not Prod | ||
# 3. Workflow was triggered manually (workflow_dispatch) | ||
# 4. Image is OSS (MIT/Apache2.0) | ||
az account set --subscription ${{secrets.PROD_ACR_SUB_ID}} | ||
TEST_ACR_NAME=${{ secrets.ACR_AMRT_USERNAME }} | ||
PROD_ACR_NAME=${{ secrets.ACR_AMR_USERNAME }} | ||
PROD_ACR_NAME=${{ secrets.PROD_ACR_USERNAME }} | ||
IMAGE_NAME=${{ matrix.model.name }} | ||
TAG=${{ matrix.model.tag }} | ||
# Formulate the source image reference | ||
SOURCE_IMAGE="$TEST_ACR_NAME.azurecr.io/$IMAGE_NAME:$TAG" | ||
SOURCE_IMAGE=$IMAGE_NAME:$TAG | ||
DEST_IMAGE=unlisted/aks/kaito/kaito-$IMAGE_NAME:$TAG | ||
# Import the image from Test ACR to Prod ACR | ||
az acr import --name $PROD_ACR_NAME --source $SOURCE_IMAGE --image $IMAGE_NAME:$TAG | ||
az acr import \ | ||
--name $PROD_ACR_NAME \ | ||
--source $SOURCE_IMAGE \ | ||
--image $DEST_IMAGE \ | ||
--registry /subscriptions/${{secrets.AZURE_SUBSCRIPTION_ID}}/resourceGroups/${{secrets.TEST_ACR_RG}}/providers/Microsoft.ContainerRegistry/registries/$TEST_ACR_NAME | ||
- name: Cleanup | ||
if: always() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,7 +51,6 @@ jobs: | |
echo "VERSION=${rand}" >> $GITHUB_ENV | ||
echo "CLUSTER_NAME=kaito${rand}" >> $GITHUB_ENV | ||
echo "RUN_LLAMA_13B=false" >> $GITHUB_ENV | ||
echo "AI_MODELS_IMAGE_VERSION=0.0.3" >> $GITHUB_ENV | ||
- uses: azure/[email protected] | ||
with: | ||
|
@@ -137,20 +136,13 @@ jobs: | |
REGISTRY: ${{ env.CLUSTER_NAME }}.azurecr.io | ||
VERSION: ${{ env.VERSION }} | ||
|
||
- name: Login to Private Presets ACR | ||
- name: Attach Private Presets ACR | ||
uses: azure/[email protected] | ||
with: | ||
inlineScript: | | ||
az acr login --name ${{ secrets.DOCKER_SERVER }} --expose-token | ||
az aks update -n ${{ env.CLUSTER_NAME }} -g ${{ env.CLUSTER_NAME }} --attach-acr ${{secrets.ACR_AIMODELSREGISTRY}} | ||
- name: Add Secret Credentials | ||
run: | | ||
kubectl create secret docker-registry ${{secrets.DOCKER_REGISTRY}} \ | ||
--docker-server=${{secrets.DOCKER_SERVER}} \ | ||
--docker-username=${{secrets.DOCKER_USERNAME}} \ | ||
--docker-password=${{secrets.DOCKER_PASSWORD}} | ||
az aks update -n ${{ env.CLUSTER_NAME }} -g ${{ env.CLUSTER_NAME }} \ | ||
--attach-acr ${{ secrets.ACR_AMRT_USERNAME }} | ||
- name: Log kaito-workspace | ||
run: | | ||
kubectl get pods -n kaito-workspace -o name | grep "^pod/kaito-workspace" | sed 's/^pod\///' | xargs -I {} kubectl logs -n kaito-workspace {} | ||
|
@@ -161,9 +153,7 @@ jobs: | |
env: | ||
AZURE_CLUSTER_NAME: ${{ env.CLUSTER_NAME }} | ||
RUN_LLAMA_13B: ${{ env.RUN_LLAMA_13B }} | ||
AI_MODELS_REGISTRY: ${{secrets.DOCKER_SERVER}} | ||
AI_MODELS_REGISTRY_SECRET: ${{ secrets.DOCKER_REGISTRY }} | ||
AI_MODELS_IMAGE_VERSION: ${{ env.AI_MODELS_IMAGE_VERSION }} | ||
AI_MODELS_REGISTRY: ${{secrets.ACR_AMRT_USERNAME}}.azurecr.io | ||
|
||
- name: Cleanup e2e resources | ||
if: ${{ always() }} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.