diff --git a/.github/workflows/scripts/e2e/gmc_test.sh b/.github/workflows/scripts/e2e/gmc_test.sh index 1491e7423..44f5171f4 100755 --- a/.github/workflows/scripts/e2e/gmc_test.sh +++ b/.github/workflows/scripts/e2e/gmc_test.sh @@ -7,6 +7,7 @@ USER_ID=$(whoami) LOG_PATH=/home/$(whoami)/logs MOUNT_DIR=/home/$USER_ID/charts-mnt IMAGE_REPO=${OPEA_IMAGE_REPO:-""} +CODEGEN_NAMESPACE="${APP_NAMESPACE}-codegen" function install_gmc() { # Make sure you have to use image tag $VERSION for microservice-connector installation @@ -29,11 +30,16 @@ function validate_gmc() { echo "validate chat-qna" validate_chatqna + echo "validate codegen" + validate_codegen + + get_gmc_controller_logs } function cleanup_gmc() { echo "clean up microservice-connector" kubectl delete ns $APP_NAMESPACE + kubectl delete ns $CODEGEN_NAMESPACE kubectl delete ns $SYSTEM_NAMESPACE kubectl delete crd gmconnectors.gmc.opea.io # clean up the images @@ -94,6 +100,54 @@ function validate_chatqna() { fi } +function validate_codegen() { + + # todo select gaudi or xeon + kubectl create ns $CODEGEN_NAMESPACE + sed -i "s|namespace: codegen|namespace: $CODEGEN_NAMESPACE|g" $(pwd)/config/samples/codegen.yaml + kubectl apply -f $(pwd)/config/samples/codegen.yaml + + # Wait until the router service is ready + echo "Waiting for the codegen router service to be ready..." + wait_until_pod_ready "codegen router" $CODEGEN_NAMESPACE "router-service" + output=$(kubectl get pods -n $CODEGEN_NAMESPACE) + echo $output + + + # deploy client pod for testing + kubectl create deployment client-test -n $CODEGEN_NAMESPACE --image=python:3.8.13 -- sleep infinity + + # wait for client pod ready + wait_until_pod_ready "client-test" $CODEGEN_NAMESPACE "client-test" + # giving time to populating data + sleep 60 + + kubectl get pods -n $CODEGEN_NAMESPACE + # send request to codegen + export CLIENT_POD=$(kubectl get pod -n $CODEGEN_NAMESPACE -l app=client-test -o jsonpath={.items..metadata.name}) + echo "$CLIENT_POD" + accessUrl=$(kubectl get gmc -n $CODEGEN_NAMESPACE -o jsonpath="{.items[?(@.metadata.name=='codegen')].status.accessUrl}") + kubectl exec "$CLIENT_POD" -n $CODEGEN_NAMESPACE -- curl $accessUrl -X POST -d '{"messages": "def print_hello_world():"}' -H 'Content-Type: application/json' > $LOG_PATH/gmc_codegen.log + exit_code=$? + if [ $exit_code -ne 0 ]; then + echo "chatqna failed, please check the logs in ${LOG_PATH}!" + exit 1 + fi + + echo "Checking response results, make sure the output is reasonable. " + local status=false + if [[ -f $LOG_PATH/gmc_codegen.log ]] && \ + [[ $(grep -c "print" $LOG_PATH/gmc_codegen.log) != 0 ]]; then + status=true + fi + if [ $status == false ]; then + echo "Response check failed, please check the logs in artifacts!" + exit 1 + else + echo "Response check succeed!" + fi +} + function init_gmc() { # Copy manifest into gmc mkdir -p $(pwd)/config/manifests @@ -128,6 +182,7 @@ function wait_until_pod_ready() { while ! is_pod_ready $2 $3; do if [ $retry_count -ge $max_retries ]; then echo "$1 is not ready after waiting for a significant amount of time" + get_gmc_controller_logs exit 1 fi echo "$1 is not ready yet. Retrying in 10 seconds..." @@ -151,6 +206,21 @@ function is_pod_ready() { fi } +function get_gmc_controller_logs() { + # Fetch the name of the pod with the app-name gmc-controller in the specified namespace + pod_name=$(kubectl get pods -n $SYSTEM_NAMESPACE -l control-plane=gmc-controller -o jsonpath='{.items[0].metadata.name}') + + # Check if the pod name was found + if [ -z "$pod_name" ]; then + echo "No pod found with app-name gmc-controller in namespace $SYSTEM_NAMESPACE" + return 1 + fi + + # Get the logs of the found pod + echo "Fetching logs for pod $pod_name in namespace $SYSTEM_NAMESPACE..." + kubectl logs $pod_name -n $SYSTEM_NAMESPACE +} + if [ $# -eq 0 ]; then echo "Usage: $0 " exit 1 diff --git a/microservices-connector/config/samples/codegen.yaml b/microservices-connector/config/samples/codegen.yaml index cc6432fac..ff750915d 100644 --- a/microservices-connector/config/samples/codegen.yaml +++ b/microservices-connector/config/samples/codegen.yaml @@ -13,10 +13,6 @@ spec: routerConfig: name: router serviceName: router-service - config: - no_proxy: ".codegen.svc.cluster.local" - http_proxy: "insert-your-http-proxy-here" - https_proxy: "insert-your-https-proxy-here" nodes: root: routerType: Sequence @@ -26,21 +22,11 @@ spec: internalService: serviceName: llm-service config: - no_proxy: ".codegen.svc.cluster.local" - http_proxy: "insert-your-http-proxy-here" - https_proxy: "insert-your-https-proxy-here" - tgi_endpoint: http://tgi-service.codegen.svc.cluster.local:9009 - gmcTokenSecret: gmc-tokens endpoint: /v1/chat/completions - name: Tgi internalService: serviceName: tgi-service config: - no_proxy: ".codegen.svc.cluster.local" - http_proxy: "insert-your-http-proxy-here" - https_proxy: "insert-your-https-proxy-here" - gmcTokenSecret: gmc-tokens - hostPath: /root/GMC/data/tgi - modelId: ise-uiuc/Magicoder-S-DS-6.7B + LLM_MODEL_ID: ise-uiuc/Magicoder-S-DS-6.7B endpoint: /generate isDownstreamService: true diff --git a/microservices-connector/internal/controller/gmconnector_controller.go b/microservices-connector/internal/controller/gmconnector_controller.go index 68a9862e3..0d5ba40aa 100644 --- a/microservices-connector/internal/controller/gmconnector_controller.go +++ b/microservices-connector/internal/controller/gmconnector_controller.go @@ -174,8 +174,10 @@ func reconcileResource(ctx context.Context, client client.Client, step string, n newEnvVars...) } //overwrite the managed fields is needed, we write this deployment twice here - deployment.ManagedFields = nil - + deployment.SetManagedFields(nil) + latest := &unstructured.Unstructured{} + latest.SetGroupVersionKind(deployment.GroupVersionKind()) + deployment.SetResourceVersion(latest.GetResourceVersion()) // Update the deployment using client.Client if err := client.Update(ctx, deployment); err != nil { return fmt.Errorf("Failed to update deployment: %v\n", err)