fix: complete logic audit — mark_completed on transfer, reset_state for interactive source, proper error propagation, user-visible commands

This commit is contained in:
2026-05-22 21:05:16 +04:00
parent 97b3623915
commit addbb3795f
5 changed files with 11 additions and 5 deletions

View File

@@ -62,7 +62,7 @@ class FSM:
except Exception as e:
msg = str(e)
cerror(f"Ошибка на шаге {step_name}: {msg}")
state.set_error(step_name, "", msg, suggestion="Исправьте проблему и запустите: ./migrate --resume")
state.set_error(step_name, "", msg, suggestion="Исправьте проблему и запустите: docker-migrate --resume")
raise
def _source_step(self, name):

View File

@@ -122,6 +122,7 @@ def main():
_handle_keyboard_interrupt()
if choice == "1":
from source.source import run_source_mode
state.reset_state(mode="source")
try:
run_source_mode()
except KeyboardInterrupt:

View File

@@ -329,9 +329,10 @@ def do_transfer_offer():
key_path = None
try:
key_path = pick_or_setup_ssh_key(host, user, port_int)
except RuntimeError:
# pick_or_setup уже дал инструкции, останавливаемся
return
except RuntimeError as exc:
# pick_or_setup уже дал инструкции, помечаем ошибку и выходим
state.set_error("ssh_key_setup", "", str(exc), suggestion="Настройте SSH-ключ и запустите: docker-migrate --resume")
raise
if key_path:
state.set_stage("TRANSFER", target_host=host, target_user=user, target_port=port_int, ssh_key=key_path)

View File

@@ -346,7 +346,7 @@ def do_verify():
step="nginx_config_check",
stdout=r.stdout,
stderr=r.stderr,
suggestion="Проверьте SSL-сертификаты, пути include, и конфликты listen. После исправления запустите: ./migrate --resume"
suggestion="Проверьте SSL-сертификаты, пути include, и конфликты listen. После исправления запустите: docker-migrate --resume"
)
raise RuntimeError("nginx -t failed")
success("nginx -t: OK")

View File

@@ -111,3 +111,7 @@ def do_transfer():
run(f"ssh {ssh_opts} {user}@{host} 'cd /opt/docker-migrate-tool && python3 core/main.py --mode=target --remote-dir={remote_dir}'", check=False)
else:
success(f"Архив передан. Запустите на target: python3 core/main.py --mode=target --remote-dir={remote_dir}")
# Transfer выполнен — отмечаем выполненным, чтобы resume не повторял
state.mark_completed("TRANSFER")
state.set_stage("DONE")