Implement SSH user data handling and adjust volume size
- Added functions to generate SSH user data in cloud-config format and encode it in Base64 for server creation. - Updated the `create_gpu_server` function to include public key handling for SSH access. - Adjusted the default boot volume size from 40GB to 30GB in `os_client.py`. - Enhanced the `cmd_up` function to manage SSH key injection and server state more effectively. - Improved logging for SSH connection attempts and error handling in `wait_ssh` to provide clearer feedback on authentication issues.
This commit is contained in:
+16
-2
@@ -40,6 +40,7 @@ def wait_ssh(cfg: Config, host: str, timeout: float = 900.0) -> None:
|
||||
key = str(cfg.ssh_private_key_path)
|
||||
last = None
|
||||
attempt = 0
|
||||
auth_fails = 0
|
||||
while time.time() < deadline:
|
||||
attempt += 1
|
||||
client = paramiko.SSHClient()
|
||||
@@ -59,13 +60,26 @@ def wait_ssh(cfg: Config, host: str, timeout: float = 900.0) -> None:
|
||||
return
|
||||
except Exception as exc:
|
||||
last = exc
|
||||
name = type(exc).__name__
|
||||
if "Authentication" in name or "Authentication" in str(exc):
|
||||
auth_fails += 1
|
||||
try:
|
||||
client.close()
|
||||
except Exception:
|
||||
pass
|
||||
if attempt == 1 or attempt % 6 == 0:
|
||||
# Progress without paramiko traceback spam.
|
||||
print(f"жду SSH {cfg.ssh_user}@{host}… ({type(exc).__name__})", flush=True)
|
||||
print(f"жду SSH {cfg.ssh_user}@{host}… ({name})", flush=True)
|
||||
# Key never injected (boot-from-volume): don't burn full timeout.
|
||||
if auth_fails >= 8:
|
||||
raise CloudError(
|
||||
f"SSH {cfg.ssh_user}@{host}: ключ отклонён (AuthenticationException). "
|
||||
"Nova keypair не попал в authorized_keys при boot-from-volume. "
|
||||
"Останови up (Ctrl+C), затем снова: gpu-rent up --yes "
|
||||
"(create теперь с config_drive + user_data). "
|
||||
"Или в консоли панели (root): "
|
||||
f"добавь содержимое {cfg.ssh_private_key_path}.pub в "
|
||||
f"/home/{cfg.ssh_user}/.ssh/authorized_keys"
|
||||
) from exc
|
||||
time.sleep(8)
|
||||
raise CloudError(
|
||||
f"SSH {cfg.ssh_user}@{host} не принял ключ за {int(timeout)} с ({last}). "
|
||||
|
||||
Reference in New Issue
Block a user