Commit Graph
954 Commits
Author SHA1 Message Date
Wez Furlong f22ba1df72 ci: apply brute force 2023-06-30 17:21:37 -07:00
Wez Furlong 761fe38da7 ci: install redis for "basic" rust workflow 2023-06-30 17:20:26 -07:00
Wez Furlong e85fa0d6f7 ci: maybe install redis for centos 7 2023-06-30 17:18:08 -07:00
Wez Furlong 67d7a105c9 rustfmt 2023-06-30 15:42:03 -07:00
Wez Furlong 84b78b2e51 cargo update 2023-06-30 15:40:54 -07:00
Wez Furlong d3ba5ccd2c connection_limit: implement using leases
To support distributed connection limits, adjust the way that
connection limits are handled.

Previously, we'd do a simple in-memory comparison with the limit to
guide whether we had reached the limit.

In a distributed/clustered scenario we need a shared understanding
of the state of the connections, so we're moving to a lease-based
model.

Each connection is associated with a UUID.
Each egress path maintains a set of connections and their UUIDs.

When attempting to make a new connection, we can only proceed if the
number of connections associated with an egress path is below the limit.

When a connection is closed, its UUID is removed from the associated
set.

To handle crashes, kills and netsplits, the path -> uuid association is
also accompanied by an expiration time beyond which it can be assumed
that the lease is no longer valid.  We compute that time based on the
worst case timeout value for a single message send on the given pathway.
Each time a connection is ready to obtain a new message, it will try
to extend its lease by that same duration.

This commit introduces these concepts and models them using an in-memory
store for the single node case, and using redis for the cluster case.
When your policy enables `kumo.configure_redis_throttles`, that same
redis configuration is used to back to the connection limiting
functionality.

refs: https://github.com/KumoCorp/kumomta/issues/41
2023-06-30 15:39:09 -07:00
Tom Mairs e45c82a3ec update Inject content example 2023-06-30 05:48:24 +00:00
Tom Mairs 861ed83a63 update MG example 2023-06-30 05:34:33 +00:00
Tom Mairs 2b617a8c65 fix typo 2023-06-30 05:20:35 +00:00
Wez Furlong 8ef0af7d45 fix from setting to header in http injection api 2023-06-29 09:51:32 -07:00
Wez Furlong 8fe0cb1d16 http injection: ensure that MIME-Version is set 2023-06-29 09:45:08 -07:00
Wez Furlong 26df91729d http: allow explicitly marking a parameter as a file upload
```lua
request:form_multipart_data {
  to = message:recipient().email,
  message = {
    data = message:get_data(),
    file_name = "mime.msg",
  }
}
```
2023-06-29 07:36:18 -07:00
Wez Furlong f65e985e64 docs: add since macro. document connection metadata object 2023-06-28 13:52:15 -07:00
Wez Furlong 2027220bcd check_relaying: adjust precedence of relay_to vs relay_from
Eagle-eyed viewers of https://www.youtube.com/watch?v=Q-5E1Q5LlTY
may have noticed that my claim that things were working right at
the end were false! I'd misread the final SMTP status, but didn't
notice until later reviewing the stream.

In poking around at this a bit more, the issue is not due to the
changes made to support the new connection metadata, but rather
due to the precedence of the sender-based relaying options vs.
the receipient-based relaying restriction.  We'd always take
the `relay_to` setting as authoritative before considering the
sender based options, which made it rather difficult to get a
working relaying policy.

This commit flips that around: if the sender based rules permit
relaying, then they will take precedence.  Otherwise, we consider
the recipient restrictions.

I suspect that this is the root of the issue described in
https://github.com/KumoCorp/kumomta/issues/63 but for which I
wasn't able to reproduce with a simple local configuration.
2023-06-28 08:39:27 -07:00
Wez Furlong 7a0dde1876 implement connection metadata for the smtp server
Coded live on YT! https://www.youtube.com/watch?v=Q-5E1Q5LlTY
2023-06-27 14:28:42 -07:00
Mike Hillyer d0a18bb22c Create FUNDING.yml
Adding Discord subscription as a sponsorship option.
2023-06-27 09:21:01 -04:00
Wez Furlong 46f83144b8 treat NoSources as a regular attempt and increment num_attempts 2023-06-24 10:29:11 -07:00
Wez Furlong d8174deb2d fix NXDOMAIN issue showing up as no non-zero-weighted sources
The suspension logic changed things so that we'd trip over a DNS
resolution earlier than normal, inside the round robin routine.

That isn't capable of reporting the domain resolution issue and
it would bubble up as NoSources and we'd miscategorize the failure.

This commit addresses that by allowing the round robin to pick a
source and then we can subsequently bubble up and handle the domain
resolution issue as normal.
2023-06-24 10:13:47 -07:00
Wez Furlong 3b681e6616 include round robin state in no-non-zero-weighted sources message 2023-06-24 10:04:20 -07:00
Wez Furlong 74b9fb2cb9 ready_queue: explain the "no answer from any hosts" transfail better 2023-06-24 08:28:26 -07:00
Wez Furlong 6514eaa6df delivery_metrics: DRY and encapsulate better
Make it more difficult to misuse and less boilerplate to use
2023-06-24 07:17:07 -07:00
Wez Furlong 7d4cc52d8d ready_queue: adjust trans and perm failure counters
In the all-connections failed and bulk ready queue operation cases,
we weren't updating the delivery metrics counters.

This commit addresses that.
2023-06-24 07:06:35 -07:00
Wez Furlong f294b6f65c ready_queue: increment attempts after exhausting connection candidates
Previously we'd just use the default error case and retry 1 minute
later, but for sites with broken tls where we can never make a
connection without changing our configuration to skip tls, we don't
want to keep retrying every minute and instead want to follow the
normal queue exponential backoff.
2023-06-24 06:58:43 -07:00
Wez Furlong f69709e34c smtp_dispatcher: improve post-starttls ehlo diagnostics
Some sites with broken tls can produce the following transient failure
log:

```
KumoMTA internal: failed to connect to any candidate hosts: EHLO: Not connected, EHLO: Not connected, EHLO: Not connected, EHLO: Not connected
```

which is very thin on actual context.

This commit adds in the useful context!

refs: https://github.com/KumoCorp/kumomta/issues/67
2023-06-24 06:54:54 -07:00
Wez Furlong 46c5f8cf98 rustfmt 2023-06-24 06:49:59 -07:00
Wez Furlong ee02c75583 really a WS only change that triggers a new build 2023-06-23 12:35:07 -07:00
Wez Furlong c8894586e8 whitespace only change to trigger a build with a new hash 2023-06-23 12:33:48 -07:00
Wez Furlong ca152156fe build-deb: include version number in filename
I suspect that using the same name on upload to openrepo
somehow collides with other versions that use the same uploaded
filename.

refs: https://github.com/openkilt/openrepo/issues/11
2023-06-23 11:52:15 -07:00
Wez Furlong b338347e34 ubuntus: add stable apt repo to sources.list 2023-06-23 11:13:08 -07:00
Wez Furlong eb6232f582 Add basic suspension of scheduled and ready queues
These are two different groups of queues, so there are two different
sets of things to manage them.

kcli now has `suspend(-list|cancel)?` and
`suspend-ready-q(-list|cancel)?` subcommands for establishing a
suspension, listing the suspensions and cancelling a suspension
in the scheduled-q and ready-q namespaces respectively.

The names of the ready queues can be derived from the metrics API:

```console
$ curl -s 'http://localhost:8000/metrics.json'  | jq .
...
  "ready_count": {
    "help": "number of messages in the ready queue",
    "type": "gauge",
    "value": {
      "service": {
        "smtp_client:source2->(in1-smtp|in2-smtp).messagingengine.com": 0.0
      }
    }
  },
...
```

From the above, `source2->(in1-smtp|in2-smtp).messagingengine.com` is
the name of the underlying ready queue.

We can and probably should add something to `kcli` to make that slightly
easier to review and manage for the operator.

refs: https://github.com/KumoCorp/kumomta/issues/51
2023-06-23 07:50:56 -07:00
Mike Hillyer c083bc44f0 Update the changelog for the new release. 2023-06-23 09:46:58 -04:00
Wez Furlong 51b72a8399 add selene linter config
This is relatively basic in that it can catch general lua lints,
but doesn't know about the set of functions available to kumo.

It doesn't appear as though selene is able to be extended to
know about those yet; that is tracked by
https://github.com/Kampfkarren/selene/issues/520

I've fixed the couple of lints in our policy and test files
as part of this commit.

You can install and run it like this:

```console
$ cargo install selene
```

Then:

```console
$ selene .
```
2023-06-22 13:50:51 -07:00
Wez Furlong 8b2584f0f3 simple_policy.lua: tweak data timeouts 2023-06-22 13:25:35 -07:00
Wez Furlong 5d39928acf add docs for new bounce APIs
and briefly show how to use `kcli` with them
2023-06-22 12:59:36 -07:00
Mike Hillyer 0ac94e3092 Automated doc formatting fix 2023-06-22 18:35:23 +00:00
Mike Hillyer 13f1617f47 Added reference to the DKIM policy helper. 2023-06-22 14:34:20 -04:00
Mike Hillyer b4fe119fdc Automated doc formatting fix 2023-06-22 18:23:39 +00:00
Mike Hillyer 02ac065ae5 Update TOC 2023-06-22 14:16:04 -04:00
Wez Furlong a2911ffd31 lifecycle: expand shutdown requested messaging
Explain a little bit more why we are waiting
2023-06-22 10:17:50 -07:00
Wez Furlong 9e83e72500 kcli: centralize request making and resolving, improve error messaging
Previously, an authentication issue could manifest as an opaque and
confusing error message like

```
Error: error decoding response body: expected value at line 1 column 1
```

now we show it like:

```
Error: request status 401: Unauthorized. Response body: Missing Authorization header
```
2023-06-22 09:55:59 -07:00
Mike Hillyer 8d843b3a51 Update shaping.toml
Little longer on the dot timeout.
2023-06-22 11:49:50 -04:00
Mike Hillyer 7166b38659 Update shaping.toml
Adding data timeout and data dot timeout to the default shaping file.
2023-06-22 11:45:44 -04:00
Wez Furlong 52e6424422 smtp_client: use data_dot timeout for the . response 2023-06-22 07:57:21 -07:00
Wez Furlong 4fe11e5f31 smtp client: ensure all reads and writes have a timeout
There were a few cases where client operations weren't wrapped
up in a timeout, which is a potential cause of hanging on shutdown:
if we're waiting an unbounded amount of time for a connection to
do something before we can shutdown, then we'll never finish.

The current timeouts struct really encodes the read timeout for
waiting for the result of a command.

What we also need is a duration to wait for sending data. We're
using the smaller of the per-command read timeout or 1 minute for
this.
2023-06-22 07:41:31 -07:00
Wez Furlong 27070388d4 fixup tokio-console
I've found the right combination to allow seeing the user-specified
log filter in the normal log output, while allowing tokio-console
to start with the appropriate filters when the `--tokio-console`
switch is used to start kumod.
2023-06-21 18:10:15 -07:00
Wez Furlong e96cd5284b bounce-list: report the bounce totals in the list
```
; ./target/debug/kcli --endpoint http://127.0.0.1:8000 bounce --everything --reason purge
{
  "id": "c8c3dc0b-084a-4dab-bf11-c44b5285554d",
  "bounced": {
    "gmail.com.mx-sink.wezfurlong.org": 1057,
    "aol.com.mx-sink.wezfurlong.org": 1079,
    "hotmail.com.mx-sink.wezfurlong.org": 1080,
    "yahoo.com.mx-sink.wezfurlong.org": 1156
  },
  "total_bounced": 4372
}
```

and follow up with the list command to see ongoing progress:

```
; ./target/debug/kcli --endpoint http://127.0.0.1:8000 bounce-list
[
  {
    "id": "c8c3dc0b-084a-4dab-bf11-c44b5285554d",
    "campaign": null,
    "tenant": null,
    "domain": null,
    "reason": "purge",
    "duration": "4m 54s 638ms 685us 58ns",
    "bounced": {
      "yahoo.com.mx-sink.wezfurlong.org": 14644,
      "hotmail.com.mx-sink.wezfurlong.org": 14515,
      "aol.com.mx-sink.wezfurlong.org": 14521,
      "gmail.com.mx-sink.wezfurlong.org": 14487
    },
    "total_bounced": 58167
  }
]
```
2023-06-21 15:36:24 -07:00
Wez Furlong d957da58b4 cargo update 2023-06-21 15:15:56 -07:00
Wez Furlong 04df1ecba9 minijinja: upgrade to 1.0.1
There's a small API change to deal with as part of moving
from 0.30 -> 1.0.

This change includes the raw block fix from the upstream.

closes: #60
2023-06-21 15:14:57 -07:00
Wez Furlong e0c47e2301 spool: allow up to 50% of cores for processing spool-in
In the future we could consider making this configurable.
For now, this does a reasonable job at getting messages
from the spool and into the queues to unblock receiving
new messages.

The degree to which this helps varies based on the number
of different scheduled and ready queues that arise from
the messages in the spool and the active configuration.
2023-06-21 13:47:42 -07:00
Wez Furlong dc071e63c0 spool: switch to flume for enumeration channel
This is mpmc which will allow parallelizing spool enumeration
in a following commit.
2023-06-21 13:47:42 -07:00