Skip to content

Network Protocol

Rohit Vighne edited this page Jan 23, 2021 · 5 revisions

Requirements

Client to Daemon (request)

  • Job identifier (unique)
  • Name of Docker image
  • Name of the Makefile target to build
  • Contents of Makefile
  • Input files needed for the target
  • Human-readable metadata
    • Name of the job

Daemon to Client (replies)

  • Job identifier (echoed)
  • Current job status
    • In progress (heartbeat)
    • Failed to execute, with cause
    • Finished with return code
  • Output files produced by the target
  • stdout and stdin

Implementation

SSH

ssh2 is a high-quality Node.js implementation of SSH. Both the client and the daemon would use this library, not OpenSSH. We are using SSH somewhat creatively as a platform on which to build our protocol, so quell any connotations regarding command execution as literal exec() on the server, or SFTP as direct filesystem access.

  • Detect unavailability: SSH has built-in heartbeat.
  • Transfer input files: client opens SFTP channel and writes files.
  • Transfer output files: client opens SFTP channel and reads files.
  • Trigger a job: command execution is essentially a remote procedure call (RPC).
    • Send job information as JSON over stdin.
    • Receive stdout and stderr directly from target execution.
  • Authentication of both daemon and client.
    • Opt-in: we can ignore this feature initially, but it's there when we need it.
  • Encryption and compression for free!

A few other advantages, which haven't been fully explored:

  • Easy debugging: we can use command-line ssh and sftp sharing a Unix socket as a mock client.
  • Extensible: we can open full-duplex streams for arbitrary data, if SFTP and command execution is not enough. This is essentially using SSH as SSL.