35 Commits

Author SHA1 Message Date
Wez Furlong 407379dd36 track sched->readyq fan in, clean up some internals
This commit removes the queue_name_for_config_change_purposes_only wart
from inside the readyq machinery.  This field had a bunch of caveats
and could in some cases become stale if the originating scheduled
queue had aged out.

It's been replaced by a HashSet of Weak refs back to the associated
scheduled queues so that it is now possible to walk the reverse of
the fan-in graph when we need to.
2026-06-25 13:41:01 +01:00
Wez Furlong 2a657f68fb included scheduled queue config in resolve-egress-path output
and also in resolve-shaping-domain, for consistency.

We can use the message rate from the scheduled queue config to refine
the computed ceilings/constraints too, which is nice.
2026-06-23 10:00:07 +01:00
Wez Furlong 49e1a62733 add resolve-egress-path API endpoint
This is conceptually equivalent to resolve-shaping-domain but operates
on a live instance, rather than loading up the policy offline.
2026-06-23 10:00:05 +01:00
Wez Furlong 0a72ce7f02 introduce EgressPathConfigConstraints concept
This can be computed for an EgressPathConfig and is useful to indicate
what the effective ceilings are for this egress path.

We return this from inspect-ready-q
2026-06-23 09:58:38 +01:00
Wez Furlong b9e677dd16 add abort-ready-q-conn and inspect-readyq endpoints/commands
These build on the infrastructure from the prior commit and improve
the observability of the system.

refs: https://github.com/KumoCorp/kumomta/issues/539
2026-06-23 09:58:36 +01:00
Wez Furlong 9987248313 spool: surface and handle rocksdb background errors
We recently investigated an issue where a rocksdb had been damaged by
corrupting/removing SST files (it sounded like this was accidentally
self-inflicted by some backup/orchestration infrastructure) leaving the
system in a silently-broken state: writes just wouldn't make progress
and there were no error messages.

Inspecting the `/var/spool/kumomta/data/LOG` log file (which is a
readable text file) revealed messages like:

```
2026/06/12-14:55:31.884227 2875746 [ERROR] [db/compaction/compaction.cc:262] Unable to load table properties for file 29704 --- IO error: No such file or directory: While open a file for random read: /var/spool/kumomta/data/029704.sst: No such file or directory
2026/06/12-14:55:31.884311 2875746 [ERROR] [db/db_impl/db_impl_compaction_flush.cc:3385] Waiting after background compaction error: IO error: No such file or directory: While open a file for random read: /var/spool/kumomta/data/029704.sst: No such file or directory, Accumulated background error counts: 6363
```

This commit improves the observability in this situation by proactively
checking for error conditions:

1. The store() and remove() operations now use our own polling within
   a deadline loop rather than spawning a blocking task and delegating
   to rocksdb's blocking interface.  This allows us to inspect the
   background error count and be cancellable, safely respecting and
   caller provided smtp max transaction duration.

2. All read and write operations check for IO and Corruption errors
   and immediately latch an error state

3. The metrics monitoring task inspects and track background error
   counts and latch us into an unhealthy state when the background
   error state appears unhealthy and persistent.

4. Additional metrics are exposed to help monitoring and alerting

While adding integration test coverage for this, I found a typo that
meant that spool errors were ignored in the message crate; they got
silently converted to `true` in all cases rather than just mapping
the success case to a `true`.

Integration tests handle the case where an SST file is corrupted
(truncated) during runtime, as well as starting up when an SST file
is missing.   These excercise both the foreground and background
error detection paths.
2026-06-23 09:11:48 +01:00
Wez Furlong d88fee2e0d docs: manually run cargo run -p jsonschematodocs
This somehow got missed in an earlier commit
2026-06-17 22:52:45 +01:00
Mike Hillyer d3d4a4d7c2 Final shuffle and updates prior to publish. 2026-06-11 15:25:53 -04:00
Harsh Jha 7cba56bc06 http injection: allow static per-recipient metadata
That metadata is accessible in to via msg:get_meta('extra')

closes: https://github.com/KumoCorp/kumomta/pull/516
Co-authored-by: Wez Furlong <wez@wezfurlong.org>
2026-05-12 14:25:46 +01:00
Wez Furlong 37236c40b1 docs: update for the 2026.04.09-ea3b2a9b release 2026-04-29 08:07:13 +01:00
Harsh Jha f08b184037 feat: pre-define to_header substitution in HTTP injection API
Pre-populate a `to_header` template substitution with the default
formatted `To` header for each recipient. Users can reference it via
`{{ to_header }}` and override it per-recipient in substitutions.

closes: https://github.com/KumoCorp/kumomta/pull/501
2026-04-01 08:17:12 +01:00
Mike Hillyer 8d2966727b Link tweak. 2026-03-27 12:50:40 -04:00
Mike Hillyer 6ac3df137d Updating API index in refman to reflect changes to ACL. 2026-03-27 12:48:28 -04:00
Wez Furlong 1c5221ba00 add /api/admin/task-dump api endpoint
This dumps out a trace of all tokio tasks.  It is quite expensive,
and currently unsettles the tokio runtime such that you need to
repeatedly call this endpoint in order for a subsequent graceful
shutdown to clock through and complete.
2026-03-11 15:19:23 +00:00
Wez Furlong 93e8e7dd01 docs: update since('dev') macros for stable release 2026-03-04 08:03:21 +00:00
Wez Furlong 04076707ec http injection: template errors are now reported with status 422
As part of this, we move template compilation to happen before
we queue up deferred generation; the compilation step should
be plenty fast enough that we can reasonably do that synchronously
and report any compilation errors back to the peer.
2026-02-25 14:25:38 +00:00
Wez Furlong b018f8f128 machine-info: add docs/examples to jsonschema 2026-02-24 13:59:18 +00:00
Wez Furlong 9bd3a5da23 introduce kumo-machine-info crate
This crate queries machine/system information which is intended
to be used in system monitoring.

This information is not centrally collected or retained by kumocorp,
merely reported via an API endpoint which is accessible only to trusted
IPs.

Machine info tries to interrogate information about the running/hosting
cloud platform for the major cloud providers, as well as indicate
whether it is running in a container of some kind.

The full cloud information is not re-exported via the API endpoint at
this time, but a fingerprint that encodes things like the instance-id is
included.
2026-02-24 12:19:53 +00:00
Wez Furlong 5efbc8d7c3 docs: link to metrics index from http metrics endpoint docs 2026-02-04 09:10:25 +00:00
Wez Furlong 5d8708daa9 docs: fix typo in the xfer injection endpoint docs 2026-02-03 08:29:11 +00:00
Wez Furlong a1014b952f docs: recurse into anyof elements in jsonschema
This allows showing eg: the XferProtocol::target field inline in the
xfer docs.
2026-02-03 08:29:11 +00:00
Wez Furlong b963a5b6a8 docs: clarify that api_xfer_inject_v1_post is an internal api 2026-02-02 13:28:00 +00:00
Wez Furlong 12c4a2f880 docs: change http generated doc disclaimer from note -> info 2026-02-02 10:32:02 +00:00
Wez Furlong 14eb3ef52e docs: relative-ize a couple of generated doc links 2026-02-02 08:17:32 +00:00
Wez Furlong b5fb4bd1f9 docs: replace manual http docs with generated docs
we now just have one section containing docs for the HTTP API,
which makes things a bit easier to reason about.
2026-02-02 08:17:20 +00:00
Wez Furlong 90e3c6c1be docs: improve the generated docs for the injection HTTP api 2026-02-02 07:59:38 +00:00
Wez Furlong d0278947ed docs: replace manual metrics docs with auto-generated ones
I factored out the sample outputs and used an include to pull
in that content.

In the future, we could automate creating those sample data files
based on the live instance, however, it will need some thought
as many metrics are instantiated dynamically.  That means that
simply launching the server to dump the initial counters could
miss a large number of the main production counters that are
the most interesting.  Likely we'll need something smarter than
that approach.  But that is an issue for the future!
2026-02-01 08:56:12 +00:00
Wez Furlong 70863b3090 docs: fixup absolute links in generated api docs
Rewrite them to work as relative markdown links so that the
docs are correctly linked in the standalone doc server.
2026-02-01 08:34:25 +00:00
Wez Furlong de9e55aef5 docs: remove some pages in favor of generated versions
A number of manually authored HTTP api docs can now be replaced
by the versions generated from code, making them more accurate
and less likely to drift away from the implementation as
future changes are made, so that's what this commit does.
2026-02-01 08:24:48 +00:00
Wez Furlong cebf0774f4 docs: define json schema tag for linking to kcli docs
Define, by convention, a tag like `kcli:bounce` to indicate that
a jsonschema path definition is linked to the `kcli bounce` subcommand.

This commit adds appropriate tags to each command, and teaches
the jsonschematodocs utility how to generate a boilerplate
paragraph containing the link.
2026-02-01 07:43:10 +00:00
Wez Furlong a8163b6e48 refactor http listener path registration
This commit changes how the various http endpoints are registered;
previously we had to define the handler function in one place,
then in another, explicitly register that handler with a path
and operation type with the router.  If we wanted to also export
documentation about that method, we would need to annotate the handler
with a duplicate of the path and method type.

There was a decent amount of boiler plate and it was very easy to omit
some of that registration information, or for it to potentially drift
or be mistranscribed.

This commit eliminates most of the boiler plate; now we require that
every endpoint be annotated with the utoipa::path macro, which
centralizes the handler, path and method type definition in one place.

To register the route and docs we now have a much simpler
`router_and_docs!` macro that can register both the with the axum router
and with the openapi docs machinery.
2026-02-01 07:30:07 +00:00
Wez Furlong b08179e08e refactor: tidy up jsonschema registration
DRY when it comes to listing out components, request and response
bodies.  We don't need to centrally list those if we're good
at annotating the path macros.

This commit removes a couple of schemas from the docs; that's
ok because the content of those was already inlined into the
respective endpoint docs anyway, so we're not losing anything,
just eliminating a redundant copy of the same information
on a second location.
2026-01-31 07:29:46 +00:00
Wez Furlong 255a3c66bc docs: flesh out more of the JSON Schema metadata 2026-01-30 16:23:46 +00:00
Wez Furlong 4bdbf4c58f remove dead code
This `Header` type was unused except for being exported into
the JSON schema, where it was also unreferenced.
2026-01-30 15:53:09 +00:00
Wez Furlong bd4e3f72c8 docs: add jsonschematodocs utility
We currently use a rather hacky embedding of rapidoc to provide a
generic browser around the jsonschema export from our API interface.

It's not great for a couple of reasons:

* The font sizes are tiny
* The documentation rapidoc produces is not indexable, being
  generated by javascript when the browser loads.  This also
  prevents making proper links to the various doc pages

This commit introduces a little utility that we can use during
the doc build to translate the schema into documentation files
that can then be processed as normal by the build.

This commit does this just for kumod at this time, but we could
also add tsa daemon in the future if we expand its API surface.
2026-01-30 15:43:09 +00:00