Open ilovedumplings opened 3 days ago
- 麻烦把 ai-quota 插件相关配置发一下,我看一下是否可以复现。
- ai-quota 插件需要配合 认证插件比如 key-auth、jwt-auth 等插件获取认证身份的 consumer 名称,同时需要配合 ai-statatistics 插件获取 AI Token 统计信息。 这个是配置的日志,统计信息也是开启了的,认证插件我使用的是basic-auth,还没有采用jwt和key auth
看了配置,refresh URL应该是 http://www.domain1.com:30296/v1/chat/completions/quota1/refresh
看了配置,refresh URL应该是 http://www.domain1.com:30296/v1/chat/completions/quota1/refresh
这个配置是我自己随便改的,我用quota也不行
看了配置,refresh URL应该是 http://www.domain1.com:30296/v1/chat/completions/quota1/refresh
我的quota只配置了路由级别的,我理解不需要在整个网关层启用的吧
我测试一下官方 ai-quota 插件,需要重新拉取一下最新 1.0.0 版本, 我测试下来没有问题。
测试 yaml 配置如下:
basic-auth 插件
apiVersion: extensions.higress.io/v1alpha1
kind: WasmPlugin
metadata:
name: basic-auth
namespace: higress-system
spec:
priority: 400
defaultConfig:
consumers:
- credential: hello:123
name: consumer1
- credential: admin:admin@123
name: consumer2
global_auth: false
matchRules:
- config:
allow:
- consumer1
- consumer2
ingress:
- qwen
url: oci://higress-registry.cn-hangzhou.cr.aliyuncs.com/plugins/basic-auth:1.0.0
ai-quota.yaml
apiVersion: extensions.higress.io/v1alpha1
kind: WasmPlugin
metadata:
name: ai-quota
namespace: higress-system
spec:
priority: 300
defaultConfig:
redis_key_prefix: "chat_quota:"
admin_consumer: consumer2
admin_path: /quota
redis:
service_name: redis-service.default.svc.cluster.local
service_port: 6379
timeout: 2000
defaultConfigDisable: false
url: oci://higress-registry.cn-hangzhou.cr.aliyuncs.com/plugins/ai-quota:1.0.0
imagePullPolicy: Always
这里用 imagePullPolicy: Always 重新拉取插件。
ai-statistic.yaml
apiVersion: extensions.higress.io/v1alpha1
kind: WasmPlugin
metadata:
name: ai-statistics
namespace: higress-system
spec:
priority: 200
defaultConfig:
enable: true
defaultConfigDisable: false
url: oci://higress-registry.cn-hangzhou.cr.aliyuncs.com/plugins/ai-statistics:1.0.0
imagePullPolicy: Always
同时可以打开 wasm 插件 DEBUG 日志,可以看到更加详细输出。
kubectl exec <higress-gateway pod> -n higress-system -- curl -X POST http://127.0.0.1:15000/logging?wasm=debug
这是refresh 测试结果如下:
(base) ➜ ~ curl -v -u admin:admin@123 http://127.0.0.1/api/openai/v1/chat/completions/quota/refresh -d "consumer=consumer1"a=10000"
* Trying 127.0.0.1:80...
* Connected to 127.0.0.1 (127.0.0.1) port 80 (#0)
* Server auth using Basic with user 'admin'
> POST /api/openai/v1/chat/completions/quota/refresh HTTP/1.1
> Host: 127.0.0.1
> Authorization: Basic YWRtaW46YWRtaW5AMTIz
> User-Agent: curl/8.1.2
> Accept: */*
> Content-Length: 30
> Content-Type: application/x-www-form-urlencoded
>
< HTTP/1.1 200 OK
< content-type: text/plain
< content-length: 24
< date: Sun, 29 Sep 2024 12:37:22 GMT
< server: istio-envoy
<
* Connection #0 to host 127.0.0.1 left intact
refresh quota successful%
ai-quota DEBUG 日志如下:
[Envoy (Epoch 0)] [2024-09-29 12:37:22.754][51][debug][wasm] wasm log higress-system.ai-quota: [ai-quota] onHttpRequestHeaders()
[Envoy (Epoch 0)] [2024-09-29 12:37:22.754][51][debug][wasm] wasm log higress-system.ai-quota: [ai-quota] chatMode:admin, adminMode:refresh, consumer:consumer2
[Envoy (Epoch 0)] [2024-09-29 12:37:22.754][51][debug][wasm] wasm log higress-system.ai-quota: [ai-quota] onHttpRequestBody()
[Envoy (Epoch 0)] [2024-09-29 12:37:22.755][51][debug][wasm] wasm log higress-system.ai-quota: redis call start, request-id: 43efd012-902f-4c82-ab38-5d47f9f73a0d, respQuery: KjMNCiQzDQpzZXQNCiQyMA0KY2hhdF9xdW90YTpjb25zdW1lcjENCiQ1DQoxMDAwMA0K
[Envoy (Epoch 0)] [2024-09-29 12:37:22.757][51][debug][wasm] wasm log higress-system.ai-quota: redis call end, request-id: 43efd012-902f-4c82-ab38-5d47f9f73a0d, respQuery: KjMNCiQzDQpzZXQNCiQyMA0KY2hhdF9xdW90YTpjb25zdW1lcjENCiQ1DQoxMDAwMA0K, respValue: K09LDQo=
[Envoy (Epoch 0)] [2024-09-29 12:37:22.757][51][debug][wasm] wasm log higress-system.ai-quota: [ai-quota] Redis set key = chat_quota:consumer1 quota = 10000
Console 默认用的应该是 latest 这个 tag。我刚刚把 1.0.0 同步到了 latest 上。你可以随便改一下插件配置让 Higress 重新拉取插件再试一下。 @ilovedumplings
If you are reporting any crash or any potential security issue, do not open an issue in this repo. Please report the issue via ASRC(Alibaba Security Response Center) where the issue will be triaged appropriately.
Ⅰ. Issue Description
ai-quota只能查询,无法刷新和增减配额,调用Post的时候超时
Ⅱ. Describe what happened
If there is an exception, please attach the exception trace:
Ⅲ. Describe what you expected to happen
Ⅳ. How to reproduce it (as minimally and precisely as possible)
Ⅴ. Anything else we need to know?
Ⅵ. Environment: