diff --git a/CHANGELOG.md b/CHANGELOG.md index c59402b..2d70b4a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,16 @@ # Changelog +## 开发快照 0.1.406(备份主机状态不得由历史推断) + +### Fixed + +- 平台未挂载主机凭据时不再断言「定时计划不会执行」:改为无法确认当前主机计划, + 远端 cron 可能仍在执行;历史下发记录不能代替实时状态。 +- 「最后下发」明确标为历史记录,只证明当时下发过,不能代表当前主机计划或执行状态。 +- 未探测与探测失败分开:只读计划先返回时显示「尚未探测」,不误报「连接失败」; + 「与设置是否一致」只在真正读回主机计划后判定,未读到时显示无法比对。 +- 回归:无凭据但存在有效历史下发、已接线但尚未探测两例都不得出现执行断言。 + ## 开发快照 0.1.405(存储与备份:单页对齐真实接口) ### Added diff --git a/web/src/BackupScheduleSection.test.tsx b/web/src/BackupScheduleSection.test.tsx index 75a8e60..93dbc76 100644 --- a/web/src/BackupScheduleSection.test.tsx +++ b/web/src/BackupScheduleSection.test.tsx @@ -126,6 +126,8 @@ describe('BackupScheduleView', () => { it('策略区分主机生效状态与编辑草稿,保留期与时间仍是真实可保存字段', () => { const html = view({}, { timeDraft: '05:10', daysDraft: '14' }) expect(html).toContain('主机生效:每天 03:30 · 保留 7 天 · 每月 3 份 · 与设置已一致') + expect(html).toContain('最后下发(历史)') + expect(html).toContain('只记录当时下发结果,不能代表当前主机计划或执行状态') expect(html).toContain('编辑草稿:每天 05:10 · 保留 14 天') expect(html).toContain('有未保存修改,主机仍按生效计划执行') expect(html).toContain('type="time"') @@ -186,20 +188,37 @@ describe('BackupScheduleView', () => { expect(html).not.toContain('立即备份一次(整批') }) - it('未接线:显式说明缺少主机凭据,下发与立即备份不可点', () => { + it('无主机凭据:不能宣称远端计划停止,历史下发只作历史记录', () => { const html = view({ host_configured: false, host_reachable: false, host_error: '目标主机凭据未挂载(BACKUP_HOST_SSH_CONFIG / BACKUP_HOST_TARGET)', in_sync: false, }) - expect(html).toContain('未接线(缺少主机凭据)') - expect(html).toContain('待下发') + expect(html).toContain('平台未挂载主机凭据(远端状态未知)') + expect(html).toContain('无法确认当前主机计划') + expect(html).toContain('远端 cron 可能仍在执行') + expect(html).toContain('历史下发不能代替实时状态') + expect(html).toContain('最后下发(历史)') + expect(html).toContain('只记录当时下发结果,不能代表当前主机计划或执行状态') + expect(html).toContain('无法比对(未读取主机计划)') + expect(html).toContain('未探测(平台未挂载主机凭据)') expect(html).toContain('目标主机凭据未挂载') - expect(html).toContain('主机未接线:定时计划不会执行') + // 没读到主机就断言"不会执行"是同类误报。 + expect(html).not.toContain('不会执行') + expect(html).not.toContain('未接通备份执行主机') expect(html).toContain('disabled') }) + it('主机已接线但尚未探测:区分"连不上"与"还没读",不按设置推定', () => { + const html = view({ host_reachable: false, host_error: '', host_checked_at: '', in_sync: false }) + expect(html).toContain('weknora-test · 尚未探测') + expect(html).not.toContain('weknora-test · 连接失败') + expect(html).toContain('尚未探测当前主机计划:不能按设置或历史下发推定') + expect(html).toContain('尚未比对') + expect(html).toContain('尚未探测主机,无法确认下一次执行') + }) + it('连不上主机:报连接失败与拨号地址,脚本状态写未知而不是"缺失"', () => { const html = view({ host_reachable: false, @@ -214,6 +233,7 @@ describe('BackupScheduleView', () => { expect(html).toContain('未知(未连上主机,未执行主机侧脚本)') expect(html).not.toContain('缺失') expect(html).toContain('主机连不上:以下"主机生效"状态未知') + expect(html).toContain('无法比对(主机不可达)') }) it('已连上且脚本真的不在:这时才显示"缺失"', () => { diff --git a/web/src/BackupScheduleSection.tsx b/web/src/BackupScheduleSection.tsx index cfbc7ad..669037f 100644 --- a/web/src/BackupScheduleSection.tsx +++ b/web/src/BackupScheduleSection.tsx @@ -254,10 +254,24 @@ export function BackupScheduleView(props: BackupScheduleViewProps) { days !== schedule.retention_days || months !== schedule.retention_months const hostLine = !schedule.host_configured - ? '未接线(缺少主机凭据)' + ? '平台未挂载主机凭据(远端状态未知)' : schedule.host_reachable ? `${schedule.host_target} · 已连接` - : `${schedule.host_target} · 连接失败` + : schedule.host_checked_at || schedule.host_error + ? `${schedule.host_target} · 连接失败` + : `${schedule.host_target} · 尚未探测` + // 未探测与探测失败必须分开:只读计划先返回时 reachable=false 不代表连不上。 + const hostProbePending = + schedule.host_configured && !schedule.host_reachable && !schedule.host_checked_at && !schedule.host_error + const syncLine = !schedule.host_configured + ? '无法比对(未读取主机计划)' + : hostProbePending + ? '尚未比对' + : !schedule.host_reachable + ? '无法比对(主机不可达)' + : schedule.in_sync + ? '已一致' + : '待下发' // 只有真的连上并读回主机状态时,才能说脚本在不在;连不上是"未知"。 const scriptLine = !schedule.host_reachable ? '未知(未连上主机,未执行主机侧脚本)' @@ -295,7 +309,7 @@ export function BackupScheduleView(props: BackupScheduleViewProps) {

范围与读写方向

- {schedule.host_configured ? '主机已接线' : '主机未接线'} + {schedule.host_configured ? '平台已接主机凭据' : '平台未接主机凭据'}
@@ -475,14 +489,16 @@ export function BackupScheduleView(props: BackupScheduleViewProps) {

{!schedule.host_configured - ? '主机未接线:定时计划不会执行。' - : !schedule.host_reachable - ? '主机连不上:以下"主机生效"状态未知,不能按设置推定。' - : schedule.host_schedule_enabled - ? `主机生效:每天 ${schedule.host_schedule_time} · 保留 ${schedule.host_keep_days} 天 · 每月 ${schedule.host_keep_months} 份 · ${ - schedule.in_sync ? '与设置已一致' : '与设置不一致(待下发)' - }` - : '主机生效:定时备份已关闭(已有备份保留)'} + ? '平台未挂载主机凭据:无法读取当前主机计划,远端 cron 是否仍在执行未知(历史下发不能代替实时状态)。' + : hostProbePending + ? '尚未探测当前主机计划:不能按设置或历史下发推定。' + : !schedule.host_reachable + ? '主机连不上:以下"主机生效"状态未知,不能按设置推定。' + : schedule.host_schedule_enabled + ? `主机生效:每天 ${schedule.host_schedule_time} · 保留 ${schedule.host_keep_days} 天 · 每月 ${schedule.host_keep_months} 份 · ${ + schedule.in_sync ? '与设置已一致' : '与设置不一致(待下发)' + }` + : '主机生效:定时备份已关闭(已有备份保留)'} {schedule.host_next_run ? ` · 下次 ${schedule.host_next_run}` : ' · 下一次实际执行未由主机返回'}

@@ -656,7 +672,7 @@ export function BackupScheduleView(props: BackupScheduleViewProps) {

{schedule.last_run_error ? `最近一次结果读取失败:${schedule.last_run_error}` - : '还没有读到任何批次(主机未接线、连不上或尚未执行过);不能据此判断备份成功或失败。'} + : '还没有读到任何批次(平台未接主机凭据、主机连不上或尚未执行过);不能据此判断备份成功或失败。'}

)} @@ -665,7 +681,11 @@ export function BackupScheduleView(props: BackupScheduleViewProps) {

主机状态(读回)

- {schedule.host_checked_at ? `读取于 ${formatBackupMoment(schedule.host_checked_at)}` : '尚未探测'} + {!schedule.host_configured + ? '未探测(平台未挂载主机凭据)' + : schedule.host_checked_at + ? `读取于 ${formatBackupMoment(schedule.host_checked_at)}` + : '尚未探测'}
@@ -683,10 +703,12 @@ export function BackupScheduleView(props: BackupScheduleViewProps) { {schedule.host_next_run ? schedule.host_next_run : !schedule.host_configured - ? '未接通备份执行主机:当前计划不会执行' - : schedule.host_schedule_enabled - ? `已配置每日 ${schedule.host_schedule_time};尚未核验下一次实际执行(不以历史下发时间推算)` - : '未启用定时或未从主机读到计划'} + ? '无法确认当前主机计划:平台未挂载主机凭据,远端 cron 可能仍在执行(历史下发不能代替实时状态)' + : hostProbePending + ? '尚未探测主机,无法确认下一次执行' + : schedule.host_schedule_enabled + ? `已配置每日 ${schedule.host_schedule_time};尚未核验下一次实际执行(不以历史下发时间推算)` + : '未启用定时或未从主机读到计划'}
@@ -705,12 +727,12 @@ export function BackupScheduleView(props: BackupScheduleViewProps) { : '—'}
与设置是否一致
-
{schedule.in_sync ? '已一致' : '待下发'}
-
最后下发
+
{syncLine}
+
最后下发(历史)
{schedule.last_applied_at - ? `${formatBackupMoment(schedule.last_applied_at)}${schedule.last_applied_summary ? ` · ${schedule.last_applied_summary}` : ''}` - : '—'} + ? `${formatBackupMoment(schedule.last_applied_at)}${schedule.last_applied_summary ? ` · ${schedule.last_applied_summary}` : ''} · 只记录当时下发结果,不能代表当前主机计划或执行状态` + : '—(没有历史下发记录;不能据设置推定主机计划)'}