Skip to content

Commit

Permalink
Fix issue in ServingRuntime ConfigMap enablement
Browse files Browse the repository at this point in the history
Fix issue with the deployment of the servingruntimes-config ConfigMap
Fix https://issues.redhat.com/browse/RHODS-6779
  • Loading branch information
lucferbux committed Feb 2, 2023
1 parent 519809e commit 7f37d8e
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions deploy.sh
Expand Up @@ -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_image>|${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"}
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 7f37d8e

Please sign in to comment.