SaltDns.Knot.Probe (Salt v1.0.0)

Checks connectivity to the Knot control socket.

This is deliberately limited to the M0 knotc status probe. Transactional Knot operations belong to the bridge in a later milestone.

The command is executed with an explicit argument list, never through a shell, so socket paths containing spaces or shell metacharacters stay one argument. A narrow runner can be injected for unit tests.

Summary

Functions

Runs one knotc command: knotc -s <socket> -t <seconds> <args...>.

Runs binary args... exactly as given, with the same argument-list, timeout and tagged-error behaviour as command/2 but without the -s <socket> -t <seconds> prefix. Used for keymgr, which reads the KASP database directly. :socket is ignored.

Probes the Knot daemon through its control socket.

Types

status_result()

@type status_result() :: {:ok, String.t()} | {:error, term()}

Functions

command(args, opts)

@spec command([String.t()], keyword()) :: status_result()

Runs one knotc command: knotc -s <socket> -t <seconds> <args...>.

args is a list of strings passed as separate arguments (never through a shell). Options are the same as for status/1. Returns the trimmed output on exit status 0, otherwise a tagged error ({:exit_status, status, output}, {:timeout, ms}, {:executable_not_found, binary}, ...).

run(args, opts)

@spec run([String.t()], keyword()) :: status_result()

Runs binary args... exactly as given, with the same argument-list, timeout and tagged-error behaviour as command/2 but without the -s <socket> -t <seconds> prefix. Used for keymgr, which reads the KASP database directly. :socket is ignored.

status(opts)

@spec status(keyword()) :: status_result()

Probes the Knot daemon through its control socket.

Options:

  • :binary - knotc executable or wrapper. Defaults to the :salt_dns, :knotc_binary application setting, then "knotc"
  • :socket - control socket path. Defaults to /run/knot/knot.sock
  • :timeout - control timeout in milliseconds (1..60000, default 5000). The same bound is passed to knotc -t in whole seconds
  • :runner - test seam with the shape (binary, args, runner_opts) -> {output, exit_status} | {:error, term()}

Returns the trimmed knotc status output on success. Missing executables, timeouts, invalid configuration, and nonzero exits are returned as tagged errors rather than raised.