diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/ai/AiRouteServiceImpl.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/ai/AiRouteServiceImpl.java index dc7b065a..90237837 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/ai/AiRouteServiceImpl.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/ai/AiRouteServiceImpl.java @@ -114,6 +114,7 @@ public AiRouteServiceImpl(KubernetesModelConverter kubernetesModelConverter, @Override public AiRoute add(AiRoute route) { fillDefaultValues(route); + V1ConfigMap configMap = kubernetesModelConverter.aiRoute2ConfigMap(route); V1ConfigMap newConfigMap; try { @@ -126,6 +127,7 @@ public AiRoute add(AiRoute route) { } writeAiRouteResources(route); + writeAiRouteFallbackResources(route); return kubernetesModelConverter.configMap2AiRoute(newConfigMap); } @@ -168,6 +170,7 @@ public void delete(String routeName) { @Override public AiRoute update(AiRoute route) { fillDefaultValues(route); + V1ConfigMap configMap = kubernetesModelConverter.aiRoute2ConfigMap(route); V1ConfigMap updatedConfigMap; try { @@ -187,11 +190,29 @@ public AiRoute update(AiRoute route) { } private void fillDefaultValues(AiRoute route) { + fillDefaultWeights(route.getUpstreams()); AiModelPredicate modelPredicate = route.getModelPredicate(); if (modelPredicate != null && Boolean.TRUE.equals(modelPredicate.getEnabled()) && StringUtils.isEmpty(modelPredicate.getPrefix())) { modelPredicate.setPrefix(route.getName()); } + AiRouteFallbackConfig fallbackConfig = route.getFallbackConfig(); + if (fallbackConfig != null && Boolean.TRUE.equals(fallbackConfig.getEnabled())) { + fillDefaultWeights(fallbackConfig.getUpstreams()); + if (StringUtils.isEmpty(fallbackConfig.getFallbackStrategy())) { + fallbackConfig.setFallbackStrategy(AiRouteFallbackStrategy.RANDOM); + } + } + } + + private void fillDefaultWeights(List upstreams) { + if (upstreams == null || upstreams.size() != 1) { + return; + } + AiUpstream upstream = upstreams.get(0); + if (upstream != null) { + upstream.setWeight(100); + } } private void writeAiRouteResources(AiRoute aiRoute) { diff --git a/helm/templates/clusterrole.yaml b/helm/templates/clusterrole.yaml index 13b0a062..1d7e5444 100644 --- a/helm/templates/clusterrole.yaml +++ b/helm/templates/clusterrole.yaml @@ -25,4 +25,6 @@ rules: - apiGroups: ["extensions.higress.io"] resources: ["wasmplugins"] verbs: ["*"] - + - apiGroups: ["networking.istio.io"] + resources: ["envoyfilters"] + verbs: ["*"]