refactor: split CLI diagnosis and status rendering

This commit is contained in:
2026-08-22 15:58:37 +08:00
parent 3f13130b8a
commit 076167d3ad
2 changed files with 125 additions and 102 deletions
+5 -3
View File
@@ -28,6 +28,8 @@ const (
codeDeploymentConfigMismatch = "deployment_record_config_mismatch"
)
const inactiveSlotContainerMessage = "非活动槽位容器 "
// diagnoseContainer 对 container 后端做只读诊断。
// 事实来源是 backend_container_deployment 单例记录;现场状态由容器引擎与宿主 Nginx 提供。
func (d *Diagnoser) diagnoseContainer(ctx context.Context) (daemonapi.Diagnosis, error) {
@@ -143,7 +145,7 @@ func (d *Diagnoser) containerFindings(ctx context.Context, deployment transactio
findings = append(findings, finding{
level: daemonapi.DiagnosisLevelOK,
code: codeInactiveContainerOK,
message: "非活动槽位容器 " + inactiveSlot.ContainerName + " 不存在",
message: inactiveSlotContainerMessage + inactiveSlot.ContainerName + " 不存在",
})
case inactiveErr != nil:
return nil, fmt.Errorf("inspect inactive backend container %s: %w", inactiveSlot.ContainerName, inactiveErr)
@@ -151,13 +153,13 @@ func (d *Diagnoser) containerFindings(ctx context.Context, deployment transactio
findings = append(findings, finding{
level: daemonapi.DiagnosisLevelDrift,
code: codeInactiveContainerRunning,
message: "非活动槽位容器 " + inactiveSlot.ContainerName + " 意外处于运行状态",
message: inactiveSlotContainerMessage + inactiveSlot.ContainerName + " 意外处于运行状态",
})
default:
findings = append(findings, finding{
level: daemonapi.DiagnosisLevelFixable,
code: codeInactiveContainerResidual,
message: "非活动槽位容器 " + inactiveSlot.ContainerName + " 已停止,属于残留",
message: inactiveSlotContainerMessage + inactiveSlot.ContainerName + " 已停止,属于残留",
action: "移除残留的已停止容器 " + inactiveSlot.ContainerName,
fix: &fixAction{kind: fixRemoveContainer, container: inactiveSlot.ContainerName},
})