-
Notifications
You must be signed in to change notification settings - Fork 21
MGMT-21406 Switch from Gemini to Vertex AI #126
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,55 @@ | ||||||||||||||||||||||||||||||||||||||||
| #!/bin/bash | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| set -o nounset | ||||||||||||||||||||||||||||||||||||||||
| set -o errexit | ||||||||||||||||||||||||||||||||||||||||
| set -o pipefail | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| SECRETS_BASE_PATH="${SECRETS_BASE_PATH:-/var/run/secrets}" | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| oc create secret generic -n "$NAMESPACE" assisted-chat-ssl-ci --from-file=client_id=/var/run/secrets/sso-ci/client_id \ | ||||||||||||||||||||||||||||||||||||||||
| --from-file=client_secret=/var/run/secrets/sso-ci/client_secret | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+9
to
+11
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Make secret creation idempotent and use SECRETS_BASE_PATH consistently
Use apply-style creation and the base path: -oc create secret generic -n "$NAMESPACE" assisted-chat-ssl-ci --from-file=client_id=/var/run/secrets/sso-ci/client_id \
- --from-file=client_secret=/var/run/secrets/sso-ci/client_secret
+oc create secret generic -n "$NAMESPACE" assisted-chat-ssl-ci \
+ --from-file=client_id="${SECRETS_BASE_PATH}/sso-ci/client_id" \
+ --from-file=client_secret="${SECRETS_BASE_PATH}/sso-ci/client_secret" \
+ 2>/dev/null || oc -n "$NAMESPACE" create secret generic assisted-chat-ssl-ci --dry-run=client -o yaml \
+ --from-file=client_id="${SECRETS_BASE_PATH}/sso-ci/client_id" \
+ --from-file=client_secret="${SECRETS_BASE_PATH}/sso-ci/client_secret" | oc apply -f -📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||
| oc process -p IMAGE_NAME="$ASSISTED_CHAT_TEST" -p SSL_CLIENT_SECRET_NAME=assisted-chat-ssl-ci -f test/prow/template.yaml --local | oc apply -n "$NAMESPACE" -f - | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| sleep 5 | ||||||||||||||||||||||||||||||||||||||||
| oc get pods -n "$NAMESPACE" | ||||||||||||||||||||||||||||||||||||||||
| POD_NAME=$(oc get pods | tr -s ' ' | cut -d ' ' -f1 | grep assisted-chat-eval-tes) | ||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: querying pods without namespace and brittle parsing
Use -POD_NAME=$(oc get pods | tr -s ' ' | cut -d ' ' -f1 | grep assisted-chat-eval-tes)
+POD_NAME=$(oc get pods -n "$NAMESPACE" -o name | grep -m1 '^pod/assisted-chat-eval-tes' | cut -d/ -f2)
+if [[ -z "${POD_NAME:-}" ]]; then
+ echo "Pod matching prefix 'assisted-chat-eval-tes' not found in namespace ${NAMESPACE}" >&2
+ oc get pods -n "$NAMESPACE"
+ exit 1
+fi🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| TIMEOUT=600 | ||||||||||||||||||||||||||||||||||||||||
| ELAPSED=0 | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| while [ $ELAPSED -lt $TIMEOUT ]; do | ||||||||||||||||||||||||||||||||||||||||
| # Check if the pod's status is "Running" | ||||||||||||||||||||||||||||||||||||||||
| CURRENT_STATUS=$(oc get pod "$POD_NAME" -n "$NAMESPACE" -o=jsonpath='{.status.phase}') | ||||||||||||||||||||||||||||||||||||||||
| CURRENT_RESTARTS=$(oc get pod "$POD_NAME" -n "$NAMESPACE" -o=jsonpath='{.status.containerStatuses[0].restartCount}') | ||||||||||||||||||||||||||||||||||||||||
| if [[ $CURRENT_RESTARTS -gt 0 ]]; then | ||||||||||||||||||||||||||||||||||||||||
| echo "Pod ${POD_NAME} was restarted, so the tests should run at least once, exiting" | ||||||||||||||||||||||||||||||||||||||||
| oc logs -n "$NAMESPACE" "$POD_NAME" | ||||||||||||||||||||||||||||||||||||||||
| exit "$(oc get pod "$POD_NAME" -n "$NAMESPACE" -o=jsonpath='{.status.containerStatuses[0].lastState.terminated.exitCode}')" | ||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+21
to
+29
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Guard against missing containerStatuses to avoid integer comparison errors Immediately after pod creation, - CURRENT_RESTARTS=$(oc get pod "$POD_NAME" -n "$NAMESPACE" -o=jsonpath='{.status.containerStatuses[0].restartCount}')
- if [[ $CURRENT_RESTARTS -gt 0 ]]; then
+ CURRENT_RESTARTS=$(oc get pod "$POD_NAME" -n "$NAMESPACE" -o=jsonpath='{.status.containerStatuses[0].restartCount}')
+ CURRENT_RESTARTS=${CURRENT_RESTARTS:-0}
+ if (( CURRENT_RESTARTS > 0 )); then
echo "Pod ${POD_NAME} was restarted, so the tests should run at least once, exiting"
oc logs -n "$NAMESPACE" "$POD_NAME"
exit "$(oc get pod "$POD_NAME" -n "$NAMESPACE" -o=jsonpath='{.status.containerStatuses[0].lastState.terminated.exitCode}')"
fi📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||
| if [[ "$CURRENT_STATUS" == "Succeeded" ]]; then | ||||||||||||||||||||||||||||||||||||||||
| echo "Pod ${POD_NAME} is successfully completed, exiting" | ||||||||||||||||||||||||||||||||||||||||
| oc logs -n "$NAMESPACE" "$POD_NAME" | ||||||||||||||||||||||||||||||||||||||||
| exit 0 | ||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||
| if [[ "$CURRENT_STATUS" == "Completed" ]]; then | ||||||||||||||||||||||||||||||||||||||||
| echo "Pod ${POD_NAME} is successfully completed, exiting" | ||||||||||||||||||||||||||||||||||||||||
| oc logs -n "$NAMESPACE" "$POD_NAME" | ||||||||||||||||||||||||||||||||||||||||
| exit 0 | ||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| if [[ "$CURRENT_STATUS" == "Failed" ]]; then | ||||||||||||||||||||||||||||||||||||||||
| echo "Pod ${POD_NAME} is Failed, exiting" | ||||||||||||||||||||||||||||||||||||||||
| oc logs -n "$NAMESPACE" "$POD_NAME" | ||||||||||||||||||||||||||||||||||||||||
| exit "$(oc get pod "$POD_NAME" -n "$NAMESPACE" -o=jsonpath='{.status.containerStatuses[0].lastState.terminated.exitCode}')" | ||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| echo "Waiting for pod $POD_NAME to be ready..." | ||||||||||||||||||||||||||||||||||||||||
| sleep 1 | ||||||||||||||||||||||||||||||||||||||||
| ELAPSED=$((ELAPSED + 1)) | ||||||||||||||||||||||||||||||||||||||||
| done | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| oc logs -n "$NAMESPACE" "$POD_NAME" | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| echo "Timeout reached. Pod $POD_NAME did not become ready in time." | ||||||||||||||||||||||||||||||||||||||||
| exit 1 | ||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -4,32 +4,80 @@ set -o nounset | |||||||||
| set -o errexit | ||||||||||
| set -o pipefail | ||||||||||
|
|
||||||||||
| SECRETS_BASE_PATH="${SECRETS_BASE_PATH:-/var/run/secrets}" | ||||||||||
|
|
||||||||||
| #All the secret are expected to be mounted under /var/run/secrets by the ci-operator | ||||||||||
|
|
||||||||||
| #$ASSISTED_CHAT_IMG is not in repo/image:tag format but rather in repo/<image name>@sha256:<digest> | ||||||||||
| #The template needs the tag, and it references the image by <image name>:<tag> so splitting the variable by ":" works for now | ||||||||||
|
|
||||||||||
| echo $ASSISTED_CHAT_IMG | ||||||||||
| IMAGE=$(echo $ASSISTED_CHAT_IMG | cut -d ":" -f1) | ||||||||||
| TAG=$(echo $ASSISTED_CHAT_IMG | cut -d ":" -f2) | ||||||||||
| echo "$ASSISTED_CHAT_IMG" | ||||||||||
| IMAGE=$(echo "$ASSISTED_CHAT_IMG" | cut -d ":" -f1) | ||||||||||
| TAG=$(echo "$ASSISTED_CHAT_IMG" | cut -d ":" -f2) | ||||||||||
|
Comment on lines
+15
to
+16
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Make image parsing robust for registries with ports and digest references Splitting on the first colon breaks when the registry includes a port (e.g., quay.io:443/…), and it’s unnecessary for digest references. Split on the last colon instead. Apply this diff: -IMAGE=$(echo "$ASSISTED_CHAT_IMG" | cut -d ":" -f1)
-TAG=$(echo "$ASSISTED_CHAT_IMG" | cut -d ":" -f2)
+IMAGE="${ASSISTED_CHAT_IMG%:*}"
+TAG="${ASSISTED_CHAT_IMG##*:}"📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||
|
|
||||||||||
| # What secrets have we got? | ||||||||||
| ls -laR "$SECRETS_BASE_PATH" | ||||||||||
|
|
||||||||||
| if ! oc get secret -n "$NAMESPACE" vertex-service-account &>/dev/null; then | ||||||||||
| echo "Creating vertex-service-account secret in namespace $NAMESPACE" | ||||||||||
| oc create secret generic -n "$NAMESPACE" vertex-service-account --from-file=service_account="$SECRETS_BASE_PATH/vertex/service_account" | ||||||||||
| fi | ||||||||||
|
|
||||||||||
| if ! oc get secret -n "$NAMESPACE" insights-ingress &>/dev/null; then | ||||||||||
| echo "Creating insights-ingress secret in namespace $NAMESPACE" | ||||||||||
| oc create secret generic -n "$NAMESPACE" insights-ingress --from-literal=auth_token="dummy-token" | ||||||||||
| fi | ||||||||||
|
|
||||||||||
| if ! oc get secret -n "$NAMESPACE" llama-stack-db &>/dev/null; then | ||||||||||
| echo "Creating llama-stack-db secret with local postgres credentials in namespace $NAMESPACE" | ||||||||||
| oc create secret generic -n "$NAMESPACE" llama-stack-db \ | ||||||||||
| --from-literal=db.host=postgres-service \ | ||||||||||
| --from-literal=db.port=5432 \ | ||||||||||
| --from-literal=db.name=assistedchat \ | ||||||||||
| --from-literal=db.user=assistedchat \ | ||||||||||
| --from-literal=db.password=assistedchat123 \ | ||||||||||
| --from-literal=db.ca_cert="" | ||||||||||
| fi | ||||||||||
|
|
||||||||||
| if ! oc get secret -n "$NAMESPACE" postgres-secret &>/dev/null; then | ||||||||||
| echo "Creating postgres-secret in namespace $NAMESPACE" | ||||||||||
|
|
||||||||||
| oc create secret generic -n "$NAMESPACE" postgres-secret \ | ||||||||||
| --from-literal=POSTGRESQL_DATABASE=assistedchat \ | ||||||||||
| --from-literal=POSTGRESQL_USER=assistedchat \ | ||||||||||
| --from-literal=POSTGRESQL_PASSWORD=assistedchat123 | ||||||||||
| fi | ||||||||||
|
|
||||||||||
| oc create secret generic -n $NAMESPACE gemini-api-key --from-file=api_key=/var/run/secrets/gemini/api_key | ||||||||||
| oc create secret generic -n $NAMESPACE llama-stack-db --from-file=db.ca_cert=/var/run/secrets/llama-stack-db/db.ca_cert \ | ||||||||||
| --from-file=db.host=/var/run/secrets/llama-stack-db/db.host \ | ||||||||||
| --from-file=db.name=/var/run/secrets/llama-stack-db/db.name \ | ||||||||||
| --from-file=db.password=/var/run/secrets/llama-stack-db/db.password \ | ||||||||||
| --from-file=db.port=/var/run/secrets/llama-stack-db/db.port \ | ||||||||||
| --from-file=db.user=/var/run/secrets/llama-stack-db/db.user | ||||||||||
| if ! oc get deployment -n "$NAMESPACE" postgres &>/dev/null; then | ||||||||||
| echo "Creating postgres deployment in namespace $NAMESPACE" | ||||||||||
| oc create deployment -n "$NAMESPACE" postgres --image=quay.io/sclorg/postgresql-16-c9s:c9s | ||||||||||
| oc set env -n "$NAMESPACE" deployment/postgres --from=secret/postgres-secret | ||||||||||
| fi | ||||||||||
|
|
||||||||||
| patch template.yaml -i test/prow/template_patch.diff | ||||||||||
| echo "GEMINI_API_KEY=$(cat /var/run/secrets/gemini/api_key)" > .env | ||||||||||
| make generate | ||||||||||
| sed -i 's/user_id_claim: sub/user_id_claim: client_id/g' config/lightspeed-stack.yaml | ||||||||||
| sed -i 's/username_claim: preferred_username/username_claim: clientHost/g' config/lightspeed-stack.yaml | ||||||||||
| if ! oc get service -n "$NAMESPACE" postgres-service &>/dev/null; then | ||||||||||
| echo "Creating postgres service in namespace $NAMESPACE" | ||||||||||
| oc expose -n "$NAMESPACE" deployment/postgres --name=postgres-service --port=5432 | ||||||||||
| fi | ||||||||||
|
|
||||||||||
| oc process -p IMAGE=$IMAGE -p IMAGE_TAG=$TAG -p GEMINI_API_SECRET_NAME=gemini-api-key -p ASSISTED_CHAT_DB_SECRET_NAME=llama-stack-db -f template.yaml --local | oc apply -n $NAMESPACE -f - | ||||||||||
| if ! oc get routes -n "$NAMESPACE" &>/dev/null; then | ||||||||||
| # Don't apply routes on clusters that don't have routes (e.g. minikube) | ||||||||||
| FILTER='select(.kind != "Route")' | ||||||||||
| else | ||||||||||
| FILTER='.' | ||||||||||
| fi | ||||||||||
|
|
||||||||||
| oc process \ | ||||||||||
| -p IMAGE="$IMAGE" \ | ||||||||||
| -p IMAGE_TAG="$TAG" \ | ||||||||||
| -p VERTEX_API_SECRET_NAME=vertex-service-account \ | ||||||||||
| -p ASSISTED_CHAT_DB_SECRET_NAME=llama-stack-db \ | ||||||||||
| -p USER_ID_CLAIM=client_id \ | ||||||||||
| -p USERNAME_CLAIM=clientHost \ | ||||||||||
| -p LIGHTSSPEED_STACK_POSTGRES_SSL_MODE=disable \ | ||||||||||
| -p LLAMA_STACK_POSTGRES_SSL_MODE=disable \ | ||||||||||
| -f template.yaml --local | | ||||||||||
| jq '. as $root | $root.items = [$root.items[] | '"$FILTER"']' | | ||||||||||
| oc apply -n "$NAMESPACE" -f - | ||||||||||
|
|
||||||||||
| sleep 5 | ||||||||||
| POD_NAME=$(oc get pods -n $NAMESPACE | tr -s ' ' | cut -d ' ' -f1| grep assisted-chat) | ||||||||||
| oc wait --for=condition=Ready pod/$POD_NAME --timeout=300s | ||||||||||
| oc wait --for=condition=Available deployment/assisted-chat -n "$NAMESPACE" --timeout=300s | ||||||||||
Uh oh!
There was an error while loading. Please reload this page.