fix(capacity): 忽略未就绪的 Worker 节点
香港站点保留了已离线的旧 control-plane 节点标签,容量控制器仍尝试读取其 metrics,导致 404 并阻断 readiness。容量采集现在只纳入 Ready=True 的候选节点,实际 Worker Pod 所在的就绪节点继续参与容量计算。 验证:容量控制器聚焦测试与 API 全量 go test 均通过,并覆盖同站点 NotReady 旧节点与 Ready Worker 节点并存场景。
This commit is contained in:
@@ -178,6 +178,20 @@ func (client *KubernetesClient) SiteState(ctx context.Context, site string) (Kub
|
||||
if err := client.getJSON(ctx, nodePath, &nodes); err != nil {
|
||||
return KubernetesSiteState{}, err
|
||||
}
|
||||
readyNodes := nodes.Items[:0]
|
||||
for _, node := range nodes.Items {
|
||||
ready := false
|
||||
for _, condition := range node.Status.Conditions {
|
||||
if condition.Type == "Ready" && condition.Status == "True" {
|
||||
ready = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if ready {
|
||||
readyNodes = append(readyNodes, node)
|
||||
}
|
||||
}
|
||||
nodes.Items = readyNodes
|
||||
if len(nodes.Items) == 0 {
|
||||
// A zero-replica Deployment with no eligible nodes represents an
|
||||
// explicitly disabled site. It must remain visible to the planner, but it
|
||||
@@ -186,7 +200,7 @@ func (client *KubernetesClient) SiteState(ctx context.Context, site string) (Kub
|
||||
if state.CurrentReplicas == 0 {
|
||||
return state, nil
|
||||
}
|
||||
return KubernetesSiteState{}, fmt.Errorf("site %s has no matching nodes", site)
|
||||
return KubernetesSiteState{}, fmt.Errorf("site %s has no ready matching nodes", site)
|
||||
}
|
||||
var pods struct {
|
||||
Items []struct {
|
||||
|
||||
Reference in New Issue
Block a user