Skip to content
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

fix: Fix some bugs in AI console APIs #367

Merged
merged 1 commit into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ public AiRouteServiceImpl(KubernetesModelConverter kubernetesModelConverter,
@Override
public AiRoute add(AiRoute route) {
fillDefaultValues(route);

V1ConfigMap configMap = kubernetesModelConverter.aiRoute2ConfigMap(route);
V1ConfigMap newConfigMap;
try {
Expand All @@ -126,6 +127,7 @@ public AiRoute add(AiRoute route) {
}

writeAiRouteResources(route);
writeAiRouteFallbackResources(route);

return kubernetesModelConverter.configMap2AiRoute(newConfigMap);
}
Expand Down Expand Up @@ -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 {
Expand All @@ -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<AiUpstream> upstreams) {
if (upstreams == null || upstreams.size() != 1) {
return;
}
AiUpstream upstream = upstreams.get(0);
if (upstream != null) {
upstream.setWeight(100);
}
}

private void writeAiRouteResources(AiRoute aiRoute) {
Expand Down
4 changes: 3 additions & 1 deletion helm/templates/clusterrole.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,6 @@ rules:
- apiGroups: ["extensions.higress.io"]
resources: ["wasmplugins"]
verbs: ["*"]

- apiGroups: ["networking.istio.io"]
resources: ["envoyfilters"]
verbs: ["*"]
Loading