Skip to content

use a tempdir instead of the rpki output dir for rpki-client output#143

Merged
fjahr merged 2 commits into
asmap:masterfrom
jurraca:isolate-out-dir
Jun 7, 2026
Merged

use a tempdir instead of the rpki output dir for rpki-client output#143
fjahr merged 2 commits into
asmap:masterfrom
jurraca:isolate-out-dir

Conversation

@jurraca

@jurraca jurraca commented Jun 3, 2026

Copy link
Copy Markdown
Collaborator

a by-product of aee081e was the introduction of a writable directory explicitly in the rpki-client run command invocation, which now gets all rpki-client output written to it. This directory is intended for kartograf output, not rpki-client. It seems that systems with writable directories (non-Nix) write this data to a default directory managed by rpki-client, and Nix systems don't write the data at all, failing silently.

The better solution is to name an explicit, temporary directory for rpki-client output and pass it to the run command. The temporary directory is cleaned up automatically after the run finishes.

The run command defaults to writing -joBcm outputs, but we don't need the output. We add the -m flag to the run args, since it limits the output written to the smallest item (metrics, ~330K).

To summarize: we set an explicit, temporary output directory, we write a tiny bit of data to it, and it gets cleaned up automatically.

@fjahr

fjahr commented Jun 4, 2026

Copy link
Copy Markdown
Collaborator

This breaks the stable repos flag because, if used, the flag gets appended after the temp dir and then it is ignored (see the download time in the logs, it doesn't download anything, thats why it is so fast).

$ ./run map -irr -rv -s

--- Start Kartograf ---

Kartograf version: 0.4.13
Using rpki-client version 9.8 (recommended).
The epoch for this run is: 1780589799 (2026-06-04 16:16:39 UTC, local: 2026-06-04 18:16:39 CEST)

--- Resolving RouteViews URLs ---

Resolved RouteViews URLs:
  v4: https://publicdata.caida.org/datasets/routing/routeviews-prefix2as/2026/06/routeviews-rv2-20260603-1200.pfx2as.gz
  v6: https://publicdata.caida.org/datasets/routing/routeviews6-prefix2as/2026/06/routeviews-rv6-20260603-1200.pfx2as.gz

--- Fetching RPKI ---

Downloaded TAL for AFRINIC to afrinic.tal, file hash: 2838ef30ea27ce5705abf5f5adb131d8c35b1f50858338a2f3c84bb207c2fa35
Downloaded TAL for APNIC to apnic.tal, file hash: 472e551f7c551c2e999e582b7c9437d3bee4900fe53afff62aeb28d4940ade94
Downloaded TAL for ARIN to arin.tal, file hash: 1f8bdb03bcc30a3b8e11fd9a87102fba250c22137a3c8baa9c81b139cb412639
Downloaded TAL for LACNIC to lacnic.tal, file hash: d44bb9394ab009c8b53e5efebf2a1c9450bab61a27efe00de5a3e4587a3a2f6a
Downloaded TAL for RIPE to ripe.tal, file hash: 59ca27ef93f23682749fcefe7c6d70fbc723343549ff9e4d3996acaff79817fb
Downloading RPKI Data, this may take a while.
Using only stable RPKI repositories.
Downloaded RPKI Data, hash sum: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
...finished in 0:00:05.356664

…tput

Previously, the out/rpki folder was used only for output generated by
kartograf, not rpki-client. By adding the context's rpki_out_dir to the
command, rpki-client writes its output to it.
This isolates all rpki-client output to a temporary directory which is
cleaned up automatically after the run finishes.
We also add the '-m' flag to the run args, since it limits the output
written to the smallest item (metrics).
@jurraca jurraca force-pushed the isolate-out-dir branch from 22bb54a to 2a983f2 Compare June 4, 2026 17:37
@jurraca

jurraca commented Jun 4, 2026

Copy link
Copy Markdown
Collaborator Author

thanks, should have caught that. fixed with 2a983f2 by appending the tmpdir after the -s appending clause.

@fjahr fjahr left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logic looks good but I would like to see some more documentation here because it doesn't seem intuitive at all why this is being done the way it is. I will do some further manual testing. Then, with the added docs, should be good to go!

Comment thread kartograf/rpki/fetch.py
Comment on lines -86 to -89
# rpki-client requires a writable output directory as a positional
# argument. Without one it falls back to a compiled-in default that
# is not writable in some environments (e.g. nix), which makes it
# exit before emitting the CCR hashes.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this comment removed? It's still valid and valuable information IMO. Maybe also add a similar comment in parse. And I think this could be even more strongly worded that there is nothing written to the folder that we care about, which is why it's ok to use the temp folder here.

@jurraca jurraca Jun 7, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fair, brought it back with 1bf32c2. I duplicated the docs in rpki/fetch.py and rpki/parse.py.

Comment thread kartograf/rpki/fetch.py
parse_ccr_hashes(result.stdout.decode() if result.stdout else "")
with TemporaryDirectory(prefix="rpki-out-") as tmpdir:
tal_options = [item for path in data_tals(context) for item in ('-t', path)]
run_args = ["rpki-client", "-m", "-d", context.data_dir_rpki_cache,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if we really need the -m as optimization since we are deleting the files anyway. If you want to keep it, please add a small comment why it's there (also below). For the other parameters it seems intuitive why they are needed but for -m I'm not sure I will remember why it's there in a year ;)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it just reduces the amount of data we write before deleting, which is an optimization. there's no need to write data we won't need, so it makes sense imo.

@fjahr fjahr left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tACK 1bf32c2

Comment thread kartograf/rpki/fetch.py
since the default writes several hundred MB of data. The metrics
data is not used.
"""
# Download TALs and persist them in the RPKI data folder

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: This should have been part of the docstring

@fjahr fjahr merged commit deca9cb into asmap:master Jun 7, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants