From 7f37d8e7b5930913e7866db4cdd9de544f34a626 Mon Sep 17 00:00:00 2001 From: Lucas Fernandez Date: Wed, 1 Feb 2023 14:16:24 +0000 Subject: [PATCH] Fix issue in ServingRuntime ConfigMap enablement Fix issue with the deployment of the servingruntimes-config ConfigMap Fix https://issues.redhat.com/browse/RHODS-6779 --- deploy.sh | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/deploy.sh b/deploy.sh index d4d2494..0db7b9b 100755 --- a/deploy.sh +++ b/deploy.sh @@ -104,20 +104,30 @@ function oc::object::safe::to::apply() { function add_servingruntime_config() { # Get OpenVino image from latest CSV openvino_img=$(oc get csv -l operators.coreos.com/rhods-operator.redhat-ods-operator -n $ODH_OPERATOR_PROJECT -o=jsonpath='{.items[-1].spec.install.spec.deployments[?(@.name == "rhods-operator")].spec.template.spec.containers[?(@.name == "rhods-operator")].env[?(@.name == "RELATED_IMAGE_ODH_OPENVINO_IMAGE")].value}') + # Replace image sed -i "s||${openvino_img}|g" model-mesh/serving_runtime_config.yaml - exists=$(oc get -n $ODH_PROJECT configmap/servingruntimes-config -o name | grep configmap/servingruntimes-config || echo "false") - if [ "$exists" == "false" ]; then + # Check if the configmap exists + configmap_exists=$(oc get -n $ODH_PROJECT configmap/servingruntimes-config -o name | grep configmap/servingruntimes-config || echo "false") + + # Check if the key default-config exists + default_config_key_exists=$(oc get -n $ODH_PROJECT configmap/servingruntimes-config -o jsonpath='{.data}' | grep "default-config" || echo "false") + + if [ "$configmap_exists" == "false" ]; then + echo "ConfigMap servingruntimes-config doesn't exist, creating it with the default configuration" + oc apply -f model-mesh/serving_runtime_config.yaml -n $ODH_PROJECT + return 0 + elif [ "$default_config_key_exists" == "false" ]; then + echo "Key default-config doesn't exist in ConfigMap servingruntimes-config applying the key" + oc patch -n $ODH_PROJECT configmap/servingruntimes-config --patch-file model-mesh/serving_runtime_config.yaml return 0 else - openvino_exists=$(oc get -n $ODH_PROJECT configmap/servingruntimes-config -o jsonpath='{.data}' | grep "default-config" || echo "false") - if [ "$openvino_exists" != "false" ]; then - return 0 - fi + echo "Key default-config exists in ConfigMap servingruntimes-config, reverting the configuration to the initial state and updating openvino image" + oc patch -n $ODH_PROJECT configmap/servingruntimes-config --patch-file model-mesh/serving_runtime_config.yaml + return 0 fi return 1 - } ODH_PROJECT=${ODH_CR_NAMESPACE:-"redhat-ods-applications"} @@ -328,9 +338,8 @@ oc create -n ${ODH_PROJECT} -f model-mesh/etcd-secrets.yaml || echo "WARN: Model oc create -n ${ODH_PROJECT} -f model-mesh/etcd-users.yaml || echo "WARN: Etcd user secret was not created successfully." # Configure Serving Runtime resources -if add_servingruntime_config; then - oc apply -f model-mesh/serving_runtime_config.yaml -n $ODH_PROJECT -fi +echo "Creating Serving Runtime resources..." +add_servingruntime_config # Add segment.io secret key & configmap oc apply -n ${ODH_PROJECT} -f monitoring/segment-key-secret.yaml