diff --git a/platform/app.py b/platform/app.py index c1cc5c5..2590420 100644 --- a/platform/app.py +++ b/platform/app.py @@ -193,6 +193,14 @@ def restore_page(): vm_backups=get_vm_backups(), restore_prefill=prefill, main_server=MAIN_SERVER_IP, + running_on_main_server=RUNNING_ON_MAIN_SERVER, + # Only meaningful when running as the standby: "restore on this + # server" is nonsensical there (no local cluster/kubectl at all), + # so pre-fill the remote-target fields with the tunnel back to the + # real main server instead of leaving the user to find these values. + tunnel_remote_ip=MAIN_SERVER_SSH_HOST, + tunnel_remote_port=MAIN_SERVER_SSH_PORT, + tunnel_ssh_key=MAIN_SERVER_KEY, active_page='restore', page_title='Restore', page_subtitle='backup → target' @@ -836,6 +844,12 @@ def restore_start(): return jsonify({'error': f'restore-k8s-apps.sh not found at {restore_script_local}'}), 500 if target == 'local': + if not RUNNING_ON_MAIN_SERVER: + return jsonify({ + 'error': 'This is the standby — there is no local cluster here to restore ' + 'into. Use "External Machine" to restore onto the real main server ' + 'over the tunnel instead.' + }), 400 hostname = os.uname().nodename os.makedirs('/root/tmp', exist_ok=True) session_dir = f"/root/tmp/restore-session-{uuid.uuid4().hex[:8]}" diff --git a/platform/static/js/platform.js b/platform/static/js/platform.js index 4b5b391..63a6db0 100644 --- a/platform/static/js/platform.js +++ b/platform/static/js/platform.js @@ -170,7 +170,10 @@ async function refreshSystemMetrics() { if (el('g-disk')) el('g-disk').style.width = Math.min(parseFloat(d.disk_pct) || 0, 100) + '%'; setText('uptime-chip', d.uptime); if (el('settings-uptime')) el('settings-uptime').value = d.uptime; - if (d.hostname && el('this-server-desc')) el('this-server-desc').textContent = d.hostname; + const localTargetRadio = document.querySelector('input[name="restore_target"][value="local"]'); + if (d.hostname && el('this-server-desc') && !(localTargetRadio && localTargetRadio.disabled)) { + el('this-server-desc').textContent = d.hostname; + } } catch (_) {} } diff --git a/platform/templates/pages/restore.html b/platform/templates/pages/restore.html index 2504e74..d7ce07a 100644 --- a/platform/templates/pages/restore.html +++ b/platform/templates/pages/restore.html @@ -63,26 +63,37 @@