hanzhenfang commented on issue #13456:
URL: https://github.com/apache/apisix/issues/13456#issuecomment-4706703515

   Hi @Baoyuantop ,I have also reproduced this locally on APISIX 3.16.0 with a 
mock OpenAI-compatible upstream.
   
   The issue reproduction process is roughly as follows:
   ```text
   Route uses plugin_config_id
   ↓
   PluginConfig contains ai-proxy-multi with 2+ instances
   ↓
   ai-proxy-multi enters pick_target()
   ↓
   pick_target() calls 
resource.fetch_latest_conf(conf._meta.parent.resource_key)
   ↓
   parent.resource_key points to /plugin_configs/<id>
   ↓
   resource.lua rejects plugin_configs
   ↓
   503 failed to fetch the parent config
   ```
   
   Environment:
   
   ```text
   APISIX image: apache/apisix:3.16.0-debian
   apisix version: 3.16.0
   config provider: yaml standalone
   ```
   
   Minimal config shape:
   
   ```yaml
   plugin_configs:
     - id: 1345601
       plugins:
         ai-proxy-multi:
           instances:
             - name: mock-a
               provider: openai-compatible
               weight: 1
               auth:
                 header:
                   Authorization: Bearer mock-key-a
               options:
                 model: mock-model-a
               override:
                 endpoint: http://llm-mock:1980/a/v1/chat/completions
             - name: mock-b
               provider: openai-compatible
               weight: 1
               auth:
                 header:
                   Authorization: Bearer mock-key-b
               options:
                 model: mock-model-b
               override:
                 endpoint: http://llm-mock:1980/b/v1/chat/completions
   
   routes:
     - id: 1345601
       uri: /plugin-config-multi/v1/chat/completions
       methods:
         - POST
       plugins: {}
       plugin_config_id: 1345601
   ```
   
   Failing request:
   
   ```sh
   curl -sS -i http://127.0.0.1:19456/plugin-config-multi/v1/chat/completions \
     -H 'Content-Type: application/json' \
     -d '{"messages":[{"role":"user","content":"ping"}]}'
   ```
   
   Observed response:
   
   ```text
   HTTP/1.1 503 Service Temporarily Unavailable
   Server: APISIX/3.16.0
   
   failed to fetch the parent config
   ```
   
   Observed APISIX log:
   
   ```text
   resource.lua:63: fetch_latest_conf(): unsupported resource type: 
plugin_configs
   plugin.lua:1224: run_plugin(): ai-proxy-multi exits with http status code 503
   ```
   
   Controls:
   
   ```text
   PluginConfig + ai-proxy-multi with 1 instance -> HTTP 200
   Route inline ai-proxy-multi with 2 instances -> HTTP 200
   ```
   
   So the failure seems specific to this combination:
   
   ```text
   PluginConfig parent resource
   +
   ai-proxy-multi multi-instance picker path
   ```
   
   The code path I traced is:
   
   ```text
   apisix/plugin_config.lua
     sets plugin _meta.parent from the PluginConfig object
   
   apisix/plugins/ai-proxy-multi.lua
     pick_target() calls 
resource.fetch_latest_conf(conf._meta.parent.resource_key)
   
   apisix/resource.lua
     supports upstreams/routes/services/stream_routes, but not plugin_configs
   ```
   
   This makes `resource.fetch_latest_conf("/plugin_configs/<id>")` return nil, 
and
   `ai-proxy-multi` then returns `failed to fetch the parent config`.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to