exlab_wizard.sync.transports.rsync_ssh#

rsync-over-SSH transport driver. Backend Spec §7.1.3.

Shells out to rsync -avz --checksum --partial -e "ssh -i <key> -o BatchMode=yes" --bwlimit=<K> <local> <user>@<host>:<path>. SSH authentication is key-based only; the spec rejects password auth at config-validation time (see exlab_wizard.config.models.RsyncSshTransport).

The driver is intentionally thin: it calls the binary, captures stdout / stderr, and translates the exit-code + stderr-substring into one of the TransportErrorKind retry classes. Hash verification is the exlab_wizard.sync.verifier module’s responsibility, NOT this driver’s.

Classes

RsyncSshTransport(*[, binary])

rsync-over-SSH transport driver.

class exlab_wizard.sync.transports.rsync_ssh.RsyncSshTransport(*, binary='rsync')[source]#

Bases: object

rsync-over-SSH transport driver. Backend Spec §7.1.3.

Parameters:

binary (str)

async hashsum(ssh_target, ssh_key_path, remote_path)[source]#

Probe remote_path via ssh ... find ... sha256sum and parse.

Returns a {relative-path: sha256-hex} dict whose keys are stripped of the remote_path prefix so they match the local manifest’s relative-path convention (see exlab_wizard.sync.verifier.Verifier.compute_local_manifest()) on success (rc == 0). The dict may legitimately be empty if the remote subtree contains no files.

Failure modes are surfaced as TransportError with the classified error_kind so the caller (the verifier / queue worker) can route via the spec-correct §7.1.5 retry path:

  • AUTH – terminal FAILED.

  • NETWORK / UNKNOWN – backoff retry.

Spawn failure (binary missing) also raises TransportError but with error_kind=None so the worker treats it as a non-terminal failure (operator can install ssh and the job will retry rather than terminating).

Parameters:
  • ssh_target (str)

  • ssh_key_path (Path)

  • remote_path (str)

Return type:

dict[str, str]

async push(local, ssh_target, ssh_key_path, remote_path, *, bwlimit_kibps=None)[source]#

Run rsync -avz --checksum from local to ssh_target:remote_path.

ssh_target is <user>@<host>. ssh_key_path is forwarded via -e 'ssh -i <key> -o BatchMode=yes' so the driver never prompts for a password.

Returns a TransportResult. Raises TransportError when the rsync binary is missing (no retry will help).

Parameters:
Return type:

TransportResult