feat: default node name to hostname when NODE_NAME unset - #5659
Conversation
Fall back to the OS hostname when NODE_NAME is not configured, so node identity in audit/usage logs is populated automatically. In container and Kubernetes deployments the hostname equals the container ID or Pod name, which stays unique under autoscaling without any manual per-instance config.
WalkthroughIn ChangesNodeName Hostname Fallback
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Merge upstream changes including: - ClickHouse log database support (QuantumNous#5663) - System task for persistent log cleanup progress - Passive channel monitoring mode (QuantumNous#5592) - Channel test environment toggle - Node name defaults to hostname when NODE_NAME unset (QuantumNous#5659) - tsgo for web type checking - Refactored database type detection API (UsingMainDatabase/UsingLogDatabase) Conflict resolution: - AGENTS.md, CLAUDE.md: kept local Chinese version, added UsingMainDatabase/UsingLogDatabase docs - controller/channel-test.go: kept AIHubError naming, adopted allowDisable + localErr checks - docker-compose.yml: kept ai-hub naming, added ClickHouse config - model/redemption.go: kept local deletion (feature removed) - web/default/package.json: adopted upstream tsgo/oxlint/oxfmt toolchain - use-sidebar-data.ts: kept local (no redemption codes) - i18n locale files: kept local translations, added 8 new upstream keys
…#5659) Fall back to the OS hostname when NODE_NAME is not configured, so node identity in audit/usage logs is populated automatically. In container and Kubernetes deployments the hostname equals the container ID or Pod name, which stays unique under autoscaling without any manual per-instance config.
…#5659) Fall back to the OS hostname when NODE_NAME is not configured, so node identity in audit/usage logs is populated automatically. In container and Kubernetes deployments the hostname equals the container ID or Pod name, which stays unique under autoscaling without any manual per-instance config.
…#5659) Fall back to the OS hostname when NODE_NAME is not configured, so node identity in audit/usage logs is populated automatically. In container and Kubernetes deployments the hostname equals the container ID or Pod name, which stays unique under autoscaling without any manual per-instance config.
📝 变更描述 / Description
NodeName(写入审计/用量日志,用于标识执行节点)此前仅从NODE_NAME环境变量读取,未配置时为空字符串。本 PR 在未配置
NODE_NAME时回退到操作系统主机名:优先级为
NODE_NAME→ hostname → 空。显式配置始终优先,只在缺省时兜底,不改变已配置场景的行为。为什么这样改能生效: 在容器 / Kubernetes 部署中,容器主机名默认等于容器 ID 或 Pod 名,在自动扩容场景下每个实例天然唯一,因此日志能自动标识出是哪个实例执行,无需对每个动态实例手动配置
NODE_NAME。os.Hostname()出错时返回空串,退回原有行为,不会 panic。📸 运行证明 / Proof of Work
优化前:


优化后:
Summary by CodeRabbit