Skip to content

feat: auto-select plugin registry based on timezone#239

Merged
johnlanni merged 1 commit into
mainfrom
feat/auto-select-plugin-registry
Feb 2, 2026
Merged

feat: auto-select plugin registry based on timezone#239
johnlanni merged 1 commit into
mainfrom
feat/auto-select-plugin-registry

Conversation

@johnlanni
Copy link
Copy Markdown
Contributor

Summary

Auto-detect timezone and select the geographically closest plugin registry for faster WASM plugin downloads.

Problem

Currently, all plugin OCI URLs are hardcoded to use the Hangzhou registry (higress-registry.cn-hangzhou.cr.aliyuncs.com), which causes slow downloads for users in other regions.

Solution

Auto-detect timezone and select optimal registry:

Region Timezone Examples Selected Registry
China & nearby Asia/Shanghai, Asia/Hong_Kong, etc. higress-registry.cn-hangzhou.cr.aliyuncs.com
Southeast Asia Asia/Singapore, Asia/Jakarta, etc. higress-registry.ap-southeast-7.cr.aliyuncs.com
North America America/, US/, Canada/* higress-registry.us-west-1.cr.aliyuncs.com
Others Default fallback higress-registry.cn-hangzhou.cr.aliyuncs.com

Changes

1. Script Updates (get-ai-gateway.sh)

Add detectPluginRegistry() function:

  • Detects timezone using timedatectl or /etc/timezone
  • Selects optimal registry based on geographic region
  • Supports manual override via PLUGIN_REGISTRY environment variable
  • Prints selected registry for visibility

Add DEFAULT_PLUGIN_REGISTRY constant:

  • Defaults to Hangzhou registry
  • Used as fallback when auto-detection fails

Update resetEnv() function:

  • Calls detectPluginRegistry() during initialization
  • Sets PLUGIN_REGISTRY variable

Update config file generation:

  • Write PLUGIN_REGISTRY to default.cfg
  • Makes registry available to container scripts

2. Template Updates

scripts/config-template/ai-gateway.sh:

  • Replace hardcoded oci://higress-registry.cn-hangzhou.cr.aliyuncs.com with oci://${PLUGIN_REGISTRY:-higress-registry.cn-hangzhou.cr.aliyuncs.com}
  • Applies to:
    • ai-proxy plugin
    • ai-statistics plugin
    • model-router plugin

scripts/config-template/ai-proxy.sh:

  • Replace hardcoded ai-proxy plugin URL with variable

Usage

Auto-detection (default):

./get-ai-gateway.sh start --non-interactive --dashscope-key sk-xxx
# Output:
# Auto-detected timezone: Asia/Shanghai
# Selected plugin registry: higress-registry.cn-hangzhou.cr.aliyuncs.com

Manual override:

PLUGIN_REGISTRY="higress-registry.ap-southeast-7.cr.aliyuncs.com" \
  ./get-ai-gateway.sh start --non-interactive --dashscope-key sk-xxx

Benefits

  • Faster plugin downloads in non-China regions
  • Transparent - auto-detects without user intervention
  • Flexible - supports manual override
  • Visible - prints selected registry to console
  • Backward compatible - defaults to Hangzhou registry if detection fails

Testing

  • Script syntax validation (bash -n)
  • Auto-detection logic for different timezones
  • Manual override via PLUGIN_REGISTRY env var
  • Plugin URL substitution in all templates

Related

Improves deployment experience for the higress-clawdbot-integration skill, which currently documents manual IMAGE_REPO selection for the all-in-one container image. Now plugins also benefit from the same geographic optimization.

Auto-detect timezone and select the geographically closest plugin
registry for faster plugin downloads.

Changes:
1. Add detectPluginRegistry() function to auto-select registry:
   - Asia/Shanghai & China → Hangzhou mirror
   - Southeast Asia → Singapore mirror
   - Americas → North America mirror
   - Default → Hangzhou mirror

2. Add PLUGIN_REGISTRY to config file generation

3. Update plugin templates to use PLUGIN_REGISTRY variable:
   - scripts/config-template/ai-gateway.sh (ai-proxy, ai-statistics, model-router)
   - scripts/config-template/ai-proxy.sh

4. Support manual override via PLUGIN_REGISTRY environment variable

Available registries:
- higress-registry.cn-hangzhou.cr.aliyuncs.com (default)
- higress-registry.ap-southeast-7.cr.aliyuncs.com (Southeast Asia)
- higress-registry.us-west-1.cr.aliyuncs.com (North America)
@johnlanni johnlanni requested a review from CH3CHO as a code owner February 2, 2026 03:05
@lingma-agents
Copy link
Copy Markdown

lingma-agents Bot commented Feb 2, 2026

🔍 代码审查进行中

⏳ 正在审查

⏰️ 剩余时间:约需数分钟

🔄 分支流向: feat/auto-select-plugin-registrymain

📦 提交: 审查当前PR从25bb17d844fadd的提交。


📒 文件清单 (3 个文件)
📝 变更: 3 个文件

📝 变更文件:

  • all-in-one/get-ai-gateway.sh
  • all-in-one/scripts/config-template/ai-gateway.sh
  • all-in-one/scripts/config-template/ai-proxy.sh

johnlanni added a commit to higress-group/higress that referenced this pull request Feb 2, 2026
Update higress-clawdbot-integration skill to reflect automatic
timezone-based registry selection for both container images and
WASM plugins.

Changes:
- Simplify Step 3 (remove manual timezone detection)
- Document automatic IMAGE_REPO and PLUGIN_REGISTRY selection
- Update Environment Variables section with both variables
- Add manual override examples
- Update all examples to show auto-detection output
- Renumber steps (Step 3→4→5→6 become 3→4→5→6)

Related: higress-group/higress-standalone#239
@johnlanni johnlanni merged commit 123aa03 into main Feb 2, 2026
3 of 4 checks passed
@lingma-agents
Copy link
Copy Markdown

lingma-agents Bot commented Feb 2, 2026

CodeReview流程已终止

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant