Commit Graph
1920 Commits
Author SHA1 Message Date
Wez Furlong dae3bee55d traffic-gen: show current rates during sending
This makes it a bit more user friendly
2024-05-02 18:08:34 -07:00
Wez Furlong 840b8a9488 localset: fix debug print when starting up
Use the correct name prefix
2024-05-02 16:06:10 -07:00
Wez Furlong 04307c5533 queue: lock scoping
It wasn't the first time and it won't be the last time that this
class of issue crops up :-/

This pattern:

```
match something.lock().pop() {
   ...
}
```

will hold the lock even after the first line has completed
and copied its data out.

This causes subtle and difficult to find issues where
the lock lifetime overlaps with some other operation.

The resoluion for this is to encapsulate the lock
operation inside a function to break the lifetime.
2024-05-02 16:01:59 -07:00
Wez Furlong e48bcd3b57 return 550 for relay_to=false, log_oob=true case
When `log_arf` or `log_oob` are set to true with `relay_to=false`, we
now return a 550 error response for messages that are not ARF or OOB
reports.  Previously, we would return a 250 response and silently drop
the message in this case, which gave the false impression that it was
accepted for relaying.

Expand integration test to explicitly assert that the right things
are allowed/denied/relayed/parsed.
2024-05-02 11:45:07 -07:00
Wez Furlong 25ef5fcf70 tsa_init.lua: remove debug bits
These were accidentally checked in as part of be80391239
2024-05-02 10:35:49 -07:00
Wez Furlong 138738bc4f egress_source: add more socks5 debug prints 2024-05-02 10:05:13 -07:00
Wez Furlong 12efb928c7 ready_queue: simplify the wait_for_message logic
The sleep and wait loop was a bit more awkward than
it needed to be, so simplify it.
2024-05-02 06:44:44 -07:00
Wez Furlong 4dad617d14 remove EgressPathConfig::suspended logic
When this was added, it was to enable TSA daemon to express
and convey that a given path should be suspended.

The implementation was objectively unpleasant, turning the
fast path of egress source assignment from a simple single
iteration of the weighted round robin logic to N (where N
is the number of sources in a pool) iterations to try
and figure out if a suspension is active.

Now that we have TSA subscriptions that update the admin
suspension information in realtime, we can now simply
rely on that source of information.

This commit removes the logic associated with the deprecated
suspended flag and tidies up the code, making that fast
path a little more fast, and making the code a bit easier
to reason about.
2024-05-02 06:18:14 -07:00
Wez Furlong a806b8648b ready_queue: maintain: minor refactor to reduce work in hot path
Avoid locking self.connections multiple times, avoid grabbing
the path_config reference multiple times. Avoid building
limit structure if the connection count is within the goal.
2024-05-02 06:09:07 -07:00
Wez Furlong 583ebab061 EgressPathConfig: impl PartialEq
This facilitates the removal of a slightly gross string comparison
that was performed each minute by the ready_queue maintainer,
making it slightly cheaper at the same time.
2024-05-02 05:54:46 -07:00
Wez Furlong aa64a7d0db ready_queue: simplify maintainer_task logic
The revised locking scheme means that we can safely hold onto the
queue handle outside the loop.

Fixup the timing of handling config refreshes; previously we would
only refresh if we were completely idle for at least 60 seconds.
That wasn't the intent: this commit fixes it up so that we refresh
every 60 seconds.
2024-05-01 22:36:26 -07:00
Wez Furlong 7c11f8cbc8 ready_queue: split notify into two separate notifiers
Previously, we overloaded the Notify instance to mean either:

* A new message has been inserted into the ready queue
* The maintainer should wake up

The two things were often the same, but this blended responsibility
meant that we had to always use notify_waiters and couldn't use
notify_one. Not being able to notify_one was the source of flakeyness
in the maintainer_task startup situation.

This commit splits the notify instance into two; one for waking
up the maintainer, and one for waking up any Dispatcher instances
that are waiting for a message.
2024-05-01 22:36:26 -07:00
Wez Furlong 246a0af70f ready_queue: infer last_change time from notify event
No need to get the current clock, lock and store the value;
we can avoid the contention and infer the time from the
wakeup event that we always send to the maintainer at
that time.
2024-05-01 22:36:26 -07:00
Wez Furlong 3e97cd3106 optimize the fast path for queue insertion
Avoid doing some work in the fast path, and accept that we might do
some redundant extra work in the slow path, in order to make the
fast path faster.
2024-05-01 22:36:26 -07:00
Wez Furlong 79f0701dd3 add dedicated localsets for queue and ready_queue 2024-05-01 22:36:25 -07:00
Wez Furlong c7bf0817f6 queue: make locking more granular
This reduces contention in a number of cases
2024-05-01 22:36:25 -07:00
Wez Furlong 50cc0c399e ready_queue: make locking more granular
This reduces contention in the insertion code path
2024-05-01 22:36:25 -07:00
Wez Furlong 6bce1d19cb ConfigHandle: can now be shared across threads 2024-05-01 22:36:09 -07:00
Wez Furlong 6e2143cd8e ready_queue: micro optimization: reduce scope of ReadyQueue lock
Doesn't materially change profiling, but it is obviously
better to hold locks for less time.
2024-05-01 22:35:05 -07:00
Wez Furlong 8246dec7db egress_source: add more debug diagnostics to socks5 auth 2024-05-01 13:05:51 -07:00
Wez Furlong 33b819e019 ready_queue: maintainer_task: fixup lock scoping
Welp, a4e4ea23f5 kept the lock alive
across a sleep, which is bad.

Fix that up!
2024-05-01 07:13:36 -07:00
ncai 24e2c14ed4 add ready_count metrics to remove on site reap 2024-05-01 06:18:03 -07:00
Wez Furlong a4e4ea23f5 ready_queue: maintainer_task: run a couple of times on startup
I've seen some flakey behavior in some of the low traffic integration
tests, where it looks like the maintainer isn't triggering to establish
connections.

This commit adjusts the logic in the maintainer_task to trigger
the maintainer a handful of times over the first few seconds of
its life to account for timing issues when setting up a new
ready queue on a busy server.
2024-05-01 06:15:09 -07:00
Wez Furlong 57565514d9 egress_source: add preliminary support for socks5 auth
This commit adds two new fields to the egress source definition:

* socks5_proxy_username - string
* socks5_proxy_password - keysource
  (https://docs.kumomta.com/reference/keysource/)

when present, the socks5 client will indicate that it is capable
of doing username/password authentication per
https://www.rfc-editor.org/rfc/rfc1928

The password is specified as a keysource, which allows it to
load credentials from a vault or a file in addition to a
string.

This is untested beyond compilation, so there are currently
no docs for this.
2024-05-01 06:15:08 -07:00
Tom Mairs 413590e22b add notes for starting and enabling tsa daemon 2024-04-30 23:45:10 +00:00
Wez Furlong 804d72dc5c throttle: add explicit error when attempting 0/sec rate
Limits must be non-zero; raise an error when trying to use
a limit of 0.
2024-04-30 14:17:03 -07:00
Wez Furlong afe326f01a smtp_dispatcher: improve error context for troubleshooting/diagnostics 2024-04-30 14:10:00 -07:00
Mike Hillyer 3ec640a1d4 Update FAQ to make it clear about directory access permissions. 2024-04-29 13:33:00 -04:00
Wez Furlong 9e95303e6b add kumo.available_parallelism()
This can be helpful for writing configuration files for systems
that scale to the available compute resources.
2024-04-29 08:23:27 -07:00
Wez Furlong 900721ceec deps: ensure data-encoding version is a workspace dep 2024-04-29 08:01:42 -07:00
dependabot[bot] 005f757339 build(deps): bump the all group across 1 directory with 8 updates
Bumps the all group with 8 updates in the / directory:

| Package | From | To |
| --- | --- | --- |
| [data-encoding](https://github.com/ia0/data-encoding) | `2.5.0` | `2.6.0` |
| [reqwest](https://github.com/seanmonstar/reqwest) | `0.12.3` | `0.12.4` |
| [serde](https://github.com/serde-rs/serde) | `1.0.198` | `1.0.199` |
| [async-recursion](https://github.com/dcchut/async-recursion) | `1.1.0` | `1.1.1` |
| [minijinja-contrib](https://github.com/mitsuhiko/minijinja) | `1.0.20` | `2.0.1` |
| [minijinja](https://github.com/mitsuhiko/minijinja) | `1.0.20` | `2.0.1` |
| [thiserror](https://github.com/dtolnay/thiserror) | `1.0.58` | `1.0.59` |
| [data-encoding-macro](https://github.com/ia0/data-encoding) | `0.1.14` | `0.1.15` |



Updates `data-encoding` from 2.5.0 to 2.6.0
- [Commits](https://github.com/ia0/data-encoding/commits)

Updates `reqwest` from 0.12.3 to 0.12.4
- [Release notes](https://github.com/seanmonstar/reqwest/releases)
- [Changelog](https://github.com/seanmonstar/reqwest/blob/master/CHANGELOG.md)
- [Commits](https://github.com/seanmonstar/reqwest/compare/v0.12.3...v0.12.4)

Updates `serde` from 1.0.198 to 1.0.199
- [Release notes](https://github.com/serde-rs/serde/releases)
- [Commits](https://github.com/serde-rs/serde/compare/v1.0.198...v1.0.199)

Updates `async-recursion` from 1.1.0 to 1.1.1
- [Release notes](https://github.com/dcchut/async-recursion/releases)
- [Commits](https://github.com/dcchut/async-recursion/compare/v1.1.0...v1.1.1)

Updates `minijinja-contrib` from 1.0.20 to 2.0.1
- [Release notes](https://github.com/mitsuhiko/minijinja/releases)
- [Changelog](https://github.com/mitsuhiko/minijinja/blob/main/CHANGELOG.md)
- [Commits](https://github.com/mitsuhiko/minijinja/compare/1.0.20...2.0.1)

Updates `minijinja` from 1.0.20 to 2.0.1
- [Release notes](https://github.com/mitsuhiko/minijinja/releases)
- [Changelog](https://github.com/mitsuhiko/minijinja/blob/main/CHANGELOG.md)
- [Commits](https://github.com/mitsuhiko/minijinja/compare/1.0.20...2.0.1)

Updates `thiserror` from 1.0.58 to 1.0.59
- [Release notes](https://github.com/dtolnay/thiserror/releases)
- [Commits](https://github.com/dtolnay/thiserror/compare/1.0.58...1.0.59)

Updates `data-encoding-macro` from 0.1.14 to 0.1.15
- [Commits](https://github.com/ia0/data-encoding/commits)

---
updated-dependencies:
- dependency-name: data-encoding
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: all
- dependency-name: reqwest
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: all
- dependency-name: serde
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: all
- dependency-name: async-recursion
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: all
- dependency-name: minijinja-contrib
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: all
- dependency-name: minijinja
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: all
- dependency-name: thiserror
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: all
- dependency-name: data-encoding-macro
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: all
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-29 07:58:54 -07:00
Wez Furlong e67eedb829 add comments to explain site_name situation with TSA
See also:
 47cda59f1b
 e461ec41b5

https://github.com/KumoCorp/kumomta/pull/175
2024-04-29 07:55:59 -07:00
Nathalie Caiandncai e461ec41b5 tsa - Extract site_name from record site (#175)
* extract site_name from record site

Co-authored-by: ncai <ncai@chapsvision.com>
2024-04-29 07:48:52 -07:00
Wez Furlong 850b64d48c fix: ready queue gets stuck when TSA suspends before MAIL FROM
This sequence of events:

1. Messages are flowing
2. The remote site starts to return a 421 for mail at connection
   time, prior to MAIL FROM, on new connections
3. The local site employs a TSA rule that suspends the corresponding
   ready queue

Could result in the contents of that ready_queue getting stuck.

Here's a representation of the logs:

```
Apr 24 19:03:44 maintain SITENAME: computed ideal connection count as 3
Apr 24 19:03:44 Error in Dispatcher::run for SITENAME: connect to ResolvedAddress { name: "smtp-in.orange.fr.", addr: 80.12.26.32 } port 25 and read initial banner: Command rejected Response { code: 421, enhanced_code: None, content: "XXXXX smtp.orange.fr XXXXX Service refuse. Veuillez essayer plus tard. Service refused, please try later. OFR_999 [999]", command: None } (consecutive_connection_failures=1)
Apr 24 19:03:45 maintain SITENAME: there are now 3 connections, suspended(via config)=false, suspended(admin)=false, queue_size=691
Apr 24 19:03:45 maintain SITENAME: computed ideal connection count as 3
Apr 24 19:03:45 maintain SITENAME: there are now 3 connections, suspended(via config)=false, suspended(admin)=true, queue_size=746
... the above repeats every minute for a while ...
Apr 24 19:03:45 maintain SITENAME: computed ideal connection count as 0
Apr 24 19:13:45 maintain SITENAME: there are now 3 connections, suspended(via config)=false, suspended(admin)=true, queue_size=746
Apr 24 19:13:45 maintain SITENAME: computed ideal connection count as 0
Apr 24 19:13:45 reaping site SITENAME
Apr 24 19:23:44 maintain SITENAME: there are now 0 connections, suspended(via config)=false, suspended(admin)=false, queue_size=1
```

There are two problems:

1. The main mechanism that acts to sweep the read queue into the
   scheduled queue is only triggered once we get past the initial
   connection phase, causing messages to be retained in the
   ready queue instead of moving back into the scheduled queue.
2. The is-reapable logic doesn't consider the number of messages
   that may be in the ready queue. It was written before we had
   a suspension concept and only considers that an ideal connection
   count of 0 implies that there are no messages.
   The result is, in combination with 1, is that we can reap the ready
   queue while it contains messages and forget about them until
   the server is restarted.

This commit resolves both of these issues:

1. The maintain routine will now act to sweep messages into the
   corresponding scheduled queue if an admin suspension is active.
   In addition, this same sweep is considered when we reap the
   ready queue, just in case some other logic bug manifests in
   the future with the same consequences.
2. The reap logic now also requires that the ready queue be empty.
2024-04-25 07:23:39 -07:00
Wez Furlong 16f34ff1bf ready_queue: add more trace diagnostics 2024-04-24 08:42:27 -07:00
Wez Furlong 49e4e25045 ci: remove arc runner test workflow 2024-04-20 15:35:09 -07:00
Wez Furlong 4272b4a316 ci: improve parallelism in build graph
We can overlap some of the cache operations; we were already
doing this in the ubuntu flow, but hadn't ported it over
to the other flows until now.
2024-04-20 15:25:44 -07:00
Wez Furlong 84c88f2eff ci: add sccache to builder image 2024-04-20 08:09:18 -07:00
Wez Furlong 1cc78033d7 ci: add jq to builder, build builder when builder changes 2024-04-20 07:24:59 -07:00
Wez Furlong a768c6dc79 update-openapi.sh: only run when jq is available
This script is triggered as part of `make test` which is not
really a great place for it.

Its purpose is to extract the auto-generated openapi spec
from the kumod and tsa binaries and update the snapshot
that is present in the docs.

It needs kumod and tsa-daemon to have been built in debug mode
to run successfully.

It piggy-backs on `make test` on the assumption that it will
cause the person who is making changes to it to include those
spec updates in their commit/PR.

Since `make test` invokes it, the various builders may try
and fail to execute jq in the `test` step.  This is mostly
harmless, but looks noisy in the logs.

The ideal situation for this would be:

* at PR time and push time: add a check that runs this script and that
  fails if the specs are updated for the docs and are not part of the PR
  itself. (eg: status is dirty after running it).
  This way it will be visible from the CI state that something is awry.
2024-04-20 07:17:02 -07:00
Wez Furlong c9d23346e4 ci: rebuild builder images on a weekly schedule 2024-04-20 00:27:26 -07:00
Wez Furlong 3daf65b383 ci: switch to ghcr.io builder images 2024-04-20 00:05:16 -07:00
Wez Furlong c3f2d1a584 ci: use matrix build for images 2024-04-20 00:02:41 -07:00
Wez Furlong 8fe05193e3 ci: fixup copypasta 2024-04-19 23:44:21 -07:00
Wez Furlong b5507e0caa ci: tweak docker publish for builder images 2024-04-19 23:42:17 -07:00
Wez Furlong 5a9d3eea1d ci: add builder image builder 2024-04-19 23:34:25 -07:00
Wez Furlong 4a59967ce5 ci: split build into test and (release) build 2024-04-19 21:22:48 -07:00
Wez Furlong 83204d8902 ci: arrange to clear build cache on cron
The idea is that we skip restoring from cache when
triggered from cron, so that we push a whole new
cache set to replace the old one.
2024-04-19 18:54:17 -07:00
Wez Furlong 3261d1517f redis: add connect_timeout option
closes: https://github.com/KumoCorp/kumomta/issues/168
2024-04-19 12:33:23 -07:00
Wez Furlong 8c2502a792 ci: constrain push to main branch
goal is to avoid dependabot branches getting build out
in addition to the PR
2024-04-19 11:56:07 -07:00