fix: complete logic audit — mark_completed on transfer, reset_state for interactive source, proper error propagation, user-visible commands
This commit is contained in:
+1
-1
@@ -62,7 +62,7 @@ class FSM:
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
msg = str(e)
|
msg = str(e)
|
||||||
cerror(f"Ошибка на шаге {step_name}: {msg}")
|
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
|
raise
|
||||||
|
|
||||||
def _source_step(self, name):
|
def _source_step(self, name):
|
||||||
|
|||||||
@@ -122,6 +122,7 @@ def main():
|
|||||||
_handle_keyboard_interrupt()
|
_handle_keyboard_interrupt()
|
||||||
if choice == "1":
|
if choice == "1":
|
||||||
from source.source import run_source_mode
|
from source.source import run_source_mode
|
||||||
|
state.reset_state(mode="source")
|
||||||
try:
|
try:
|
||||||
run_source_mode()
|
run_source_mode()
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
|
|||||||
+4
-3
@@ -329,9 +329,10 @@ def do_transfer_offer():
|
|||||||
key_path = None
|
key_path = None
|
||||||
try:
|
try:
|
||||||
key_path = pick_or_setup_ssh_key(host, user, port_int)
|
key_path = pick_or_setup_ssh_key(host, user, port_int)
|
||||||
except RuntimeError:
|
except RuntimeError as exc:
|
||||||
# pick_or_setup уже дал инструкции, останавливаемся
|
# pick_or_setup уже дал инструкции, помечаем ошибку и выходим
|
||||||
return
|
state.set_error("ssh_key_setup", "", str(exc), suggestion="Настройте SSH-ключ и запустите: docker-migrate --resume")
|
||||||
|
raise
|
||||||
|
|
||||||
if key_path:
|
if key_path:
|
||||||
state.set_stage("TRANSFER", target_host=host, target_user=user, target_port=port_int, ssh_key=key_path)
|
state.set_stage("TRANSFER", target_host=host, target_user=user, target_port=port_int, ssh_key=key_path)
|
||||||
|
|||||||
+1
-1
@@ -346,7 +346,7 @@ def do_verify():
|
|||||||
step="nginx_config_check",
|
step="nginx_config_check",
|
||||||
stdout=r.stdout,
|
stdout=r.stdout,
|
||||||
stderr=r.stderr,
|
stderr=r.stderr,
|
||||||
suggestion="Проверьте SSL-сертификаты, пути include, и конфликты listen. После исправления запустите: ./migrate --resume"
|
suggestion="Проверьте SSL-сертификаты, пути include, и конфликты listen. После исправления запустите: docker-migrate --resume"
|
||||||
)
|
)
|
||||||
raise RuntimeError("nginx -t failed")
|
raise RuntimeError("nginx -t failed")
|
||||||
success("nginx -t: OK")
|
success("nginx -t: OK")
|
||||||
|
|||||||
@@ -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)
|
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:
|
else:
|
||||||
success(f"Архив передан. Запустите на target: python3 core/main.py --mode=target --remote-dir={remote_dir}")
|
success(f"Архив передан. Запустите на target: python3 core/main.py --mode=target --remote-dir={remote_dir}")
|
||||||
|
|
||||||
|
# Transfer выполнен — отмечаем выполненным, чтобы resume не повторял
|
||||||
|
state.mark_completed("TRANSFER")
|
||||||
|
state.set_stage("DONE")
|
||||||
|
|||||||
Reference in New Issue
Block a user