TSA Auto Start in Docker Container

Hi Folks

Can anyone perhaps confirm if the tsa-daemon will autostart in the docker container?

From what I can see, only init.lua is started with the docker-runner.sh script. I had to manually bring it up with the following command in the container:

root@a585b6081922:/opt/kumomta/sbin# ./tsa-daemon --policy /opt/kumomta/etc/policy/tsa_init.lua to stop this error when running:

kumo-sink  | TSA Error, will retry in 30 seconds        false   callback error
kumo-sink  | stack traceback:
kumo-sink  |    [C]: in local 'poll'
kumo-sink  |    [string "?"]:5: in field 'connect_websocket'
kumo-sink  |    /opt/kumomta/share/policy-extras/shaping.lua:184: in function </opt/kumomta/share/policy-extras/shaping.lua:180>
kumo-sink  |    [C]: in function 'pcall'
kumo-sink  |    /opt/kumomta/share/policy-extras/shaping.lua:206: in function </opt/kumomta/share/policy-extras/shaping.lua:200>
kumo-sink  | caused by: IO error: Connection refused (os error 111)

The TSA daemon is not a mandatory component to a KumoMTA install (albeit a common one) and so it is not started automatically.

Thanks @yearning-hyena - What is the preferred way to start the TSA Daemon? Perhaps an environment variable that can be set?

Good question. I’ll discuss and see what we could do going forward, till then it’s up to the user.

tsa daemon should be a separate container instance when using docker or k8s. You can launch it from the same image, but explicitly run the daemon executable.

Take a look at the example compose file: kumomta/examples/single-node-docker/compose.yaml at main · KumoCorp/kumomta · GitHub

@free-spirited-yorksh - thank you very much for this :folded_hands:t2:

I did not think to search for docker in the repo. I followed the documenation and just looked into the docker folder.. On the right path now. Thanks again!

Hi @free-spirited-yorksh _ I’ve only managed to pick this up again today. When using the example file - I get the following when starting the stack:

kumo-tsa   | Caused by:
kumo-tsa   |     runtime error: [string "/opt/kumomta/etc/policy/tsa_init.lua"]:3: module 'docker_utils' not found:

This is my docker-compose snippet for TSA (copy paste from git):

  tsa:
    container_name: kumo-tsa
    hostname: tsa # The kumod policy scripts rely on this name
    image: ghcr.io/kumocorp/kumomta-dev:latest
    command: runuser -u kumod -- /opt/kumomta/sbin/tsa-daemon --policy /opt/kumomta/etc/policy/tsa_init.lua
    volumes:
      - /data/appdata/kumomta/policy:/opt/kumomta/etc/policy
    restart: unless-stopped

This is the tsa_init.lua contents (also copied from git):

local tsa = require 'tsa'
local kumo = require 'kumo'
local docker_utils = require 'docker_utils'

local DOCKER_NETWORK = docker_utils.resolve_docker_network()

kumo.on('tsa_init', function()
  tsa.start_http_listener {
    listen = '0.0.0.0:8008',
    trusted_hosts = { '127.0.0.0/24', '::1', DOCKER_NETWORK },
  }
end)

local cached_load_shaping_data = kumo.memoize(kumo.shaping.load, {
  name = 'tsa_load_shaping_data',
  ttl = '5 minutes',
  capacity = 4,
})

kumo.on('tsa_load_shaping_data', function()
  local shaping = cached_load_shaping_data {
    '/opt/kumomta/share/policy-extras/shaping.toml',
    '/opt/kumomta/etc/policy/shaping.toml',
  }
  return shaping
end)

to confirm - the docker_utils.lua file is in the policy directory / volume that’s mounted.

look again at the example directory in the repo; it includes a set of sample files to use as a base

Thanks. I have the base working and will start adjusting configs from here.