Commit 354d0fed by feitianbubu Committed by GitHub

feat: default node name to hostname when NODE_NAME unset (#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.
parent efd6c445
......@@ -82,7 +82,9 @@ func InitEnv() {
DebugEnabled = os.Getenv("DEBUG") == "true"
MemoryCacheEnabled = os.Getenv("MEMORY_CACHE_ENABLED") == "true"
IsMasterNode = os.Getenv("NODE_TYPE") != "slave"
NodeName = os.Getenv("NODE_NAME")
// NodeName 优先用 NODE_NAME,未配置时回退主机名(容器下=容器 ID/Pod 名,自动扩容天然唯一)。
hostname, _ := os.Hostname()
NodeName = GetEnvOrDefaultString("NODE_NAME", hostname)
TLSInsecureSkipVerify = GetEnvOrDefaultBool("TLS_INSECURE_SKIP_VERIFY", false)
if TLSInsecureSkipVerify {
if tr, ok := http.DefaultTransport.(*http.Transport); ok && tr != nil {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment