Skip to content

make_image: log systemd-repart *.conf files at the --debug level#3993

Merged
daandemeyer merged 1 commit intosystemd:mainfrom
marc-hb:log-partitions
Dec 16, 2025
Merged

make_image: log systemd-repart *.conf files at the --debug level#3993
daandemeyer merged 1 commit intosystemd:mainfrom
marc-hb:log-partitions

Conversation

@marc-hb
Copy link
Contributor

@marc-hb marc-hb commented Nov 11, 2025

As discussed in #3948, systemd-repart *.conf files have default values which is convenient until this fails with some dreaded "disk full" error - then it becomes very mysterious. To considerably speed up the investigation about what exactly is full, show the configuration files in use when using --debug.

@marc-hb marc-hb force-pushed the log-partitions branch 5 times, most recently from 243d634 to 5d5c828 Compare November 11, 2025 14:37
Comment on lines 3398 to 3401
lines = 0
for line in f:
logging.debug(line.strip())
lines += 1
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
lines = 0
for line in f:
logging.debug(line.strip())
lines += 1
for lines, line in enumerate(f):
logging.debug(line.strip())

though lines is then no longer a good name.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, you could write something like truncated to X lines in the message above saying from which file this is and instead of enumerating lines do

for line in itertools.islice(f, 100):

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.


As usual, QEMU from the Fedora ToolsTreeDistribution is hanging in 2 places.
https://github.com/systemd/mkosi/actions/runs/19315730637/job/55247012466?pr=3993

Last time I force-pushed and banged until they all passed but this is getting tedious :-(

Copy link
Contributor

Choose a reason for hiding this comment

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

Last time I force-pushed and banged until they all passed but this is getting tedious :-(

You really don't need to. Sometimes CI is flaky, e.g. due to distro-specific problems, and in a lot of cases it is clear that the CI failure is not related to the change in the PR.

for line in f:
logging.debug(line.strip())
lines += 1
if lines > 100:
Copy link
Contributor

Choose a reason for hiding this comment

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

That seems a bit arbitrary. Is the idea for it to be much longer than than all possible repart files? The number of directives for these files is about 40.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is arbitrary. Yes, the idea is for this to be longer than all "regular" repart files, as a safety to protect the debug logs and keep them usable, triggered only when something went terribly wrong. For instance: a wrong .conf file landing there by accident. Or some other bug. I can summarize this as a one-line comment in the source.

The number of directives for these files is about 40.

I don't get this sorry. Did you mean 40 lines? Is this an average?

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't get this sorry. Did you mean 40 lines? Is this an average?

That's just the rough amount of different directives for repart files. Even if you put multiple partitions in a file, which I've not seen done, to be honest, some of these directives are exclusive or dependent on others, so in general these files will be below 10 lines long.

@marc-hb
Copy link
Contributor Author

marc-hb commented Nov 13, 2025

Sample output:

=== /tmp/rq_mkosi_wspaces/mkosi-workspace-nkv888ul/repart-definitions/10-root.conf ===
‣ [Partition]
‣ Type=root
‣ Format=btrfs
‣ CopyFiles=/
‣ Minimize=guess
‣ 
 === /tmp/rq_mkosi_wspaces/mkosi-workspace-nkv888ul/repart-definitions/00-esp.conf ===
‣ [Partition]
‣ Type=esp
‣ Format=vfat
‣ CopyFiles=/boot:/
‣ CopyFiles=/efi:/
‣ === 00-esp.conf truncated to 5 lines ===  (after changing the constant in the script)

Comment on lines 3396 to 3405
logging.debug(f"\n === {c} ===")
with open(c) as f:
# Do not spam the logs in case something goes wrong
maxlines = 100
for line in itertools.islice(f, maxlines):
logging.debug(line.strip())

for anything_left in f:
logging.debug(f"=== {c.name} truncated to {maxlines} lines ===")
break
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's shorten this somewhat, the truncation will never really be a thing

Suggested change
logging.debug(f"\n === {c} ===")
with open(c) as f:
# Do not spam the logs in case something goes wrong
maxlines = 100
for line in itertools.islice(f, maxlines):
logging.debug(line.strip())
for anything_left in f:
logging.debug(f"=== {c.name} truncated to {maxlines} lines ===")
break
logging.debug(f"# {c} (truncated to 100 lines)")
with open(c) as f:
for line in itertools.islice(f, 100):
logging.debug(line.strip())

Using a # as the separator, makes these files still valid, when copied from screen.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

As discussed in systemd#3948, systemd-repart *.conf files have default values
which is convenient until this fails with some dreaded "disk full" error
- then it becomes very mysterious. To considerably speed up the
investigation about what exactly is full, show the configuration files
in use when using --debug.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
(cherry picked from commit 7040a6a)
Signed-off-by: Marc Herbert <marc.herbert@intel.com>
@daandemeyer daandemeyer merged commit 20009b7 into systemd:main Dec 16, 2025
40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants