mirror of
https://gitcode.com/JianFeeeee/ModelRouter.git
synced 2026-11-07 09:47:23 +00:00
fix(plugins): 分片 VM 拿不到插件配置
页面探测走的是 fanout(分片)路径,结果写回走共享 VM。分片 VM 从同一份
源码启动,但没有 state 文件、没有插件身份,所以 PLUGIN.prices(配置,不是
累计状态)在分片里是空的。
对只读累计状态的插件无所谓;对按配置分支的插件就是致命的。OpenDesign
适配器读 prices.control_key,未播种时它对每个主机都得出「未配置」并报
skip,而同一个调用走共享 VM 是好的。也就是说:生产上死、所有调共享 VM 的
测试全绿。
pool 在每次取用时推送配置(不只是首次启动时),并把配置变化也带给池中
复用的 VM;推送是拷贝,分片拿不到共享表的引用。
这条不是在写代码时想到的,是端到端验证时撞出来的:单元测试全过,隔离实例
打真上游时 vela 报「未配置」,而 control_key 明明写进去了。
(cherry picked from commit 65075b6d44)
This commit is contained in:
@ -152,6 +152,9 @@ func (sp *shardPool) acquire(code, name string) (*worker, func(), error) {
|
||||
w := sp.idle[n-1]
|
||||
sp.idle = sp.idle[:n-1]
|
||||
sp.mu.Unlock()
|
||||
// Re-seed on every checkout, not only on boot: the operator may have
|
||||
// changed the configuration since this VM was pooled.
|
||||
sp.ps.seedShardConfig(name, w)
|
||||
return w, func() { sp.release(w) }, nil
|
||||
}
|
||||
if sp.limit > 0 && sp.live >= sp.limit {
|
||||
@ -168,6 +171,9 @@ func (sp *shardPool) acquire(code, name string) (*worker, func(), error) {
|
||||
sp.mu.Unlock()
|
||||
return nil, nil, err
|
||||
}
|
||||
// A fresh shard has no state file and no plugin identity, so the shared
|
||||
// plugin's configuration has to be pushed onto it (see seedShardConfig).
|
||||
sp.ps.seedShardConfig(name, w)
|
||||
return w, func() { sp.release(w) }, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user