Skip to content

Commit

Permalink
Add ignition-virtio-dump.service
Browse files Browse the repository at this point in the history
Debugging failures in the initrd is annoying; this code
looks for a virtio-serial port named `com.coreos.ignition.journal`,
and runs as part of `emergency.target`.

I plan to change mantle to set up this port by default, so if
something fails in the initramfs we'll at least reliably get
the journal in a sane parsable format.

This is a special targeted subset of
coreos/ignition#585
  • Loading branch information
cgwalters committed Jan 4, 2020
1 parent c4790bc commit 554e8af
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
13 changes: 13 additions & 0 deletions dracut/99emergency-timeout/ignition-virtio-dump.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[Unit]
Description=Ignition (virtio dump)
Documentation=https://github.com/coreos/ignition
ConditionPathExists=/etc/initrd-release
DefaultDependencies=false
After=basic.target

[Service]
Type=oneshot
RemainAfterExit=yes
EnvironmentFile=/run/ignition.env
ExecStart=/usr/bin/virtio-dump

12 changes: 12 additions & 0 deletions dracut/99emergency-timeout/module-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,22 @@
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh

install_unit_wants() {
local unit="$1"; shift
local target="$1"; shift
local instantiated="${1:-$unit}"; shift
inst_simple "$moddir/$unit" "$systemdsystemunitdir/$unit"
mkdir -p "$initdir/$systemdsystemunitdir/$target.wants"
ln_r "../$unit" "$systemdsystemunitdir/$target.wants/$instantiated"
}

install() {
inst_multiple \
cut \
date

inst_hook emergency 99 "${moddir}/timeout.sh"

inst_script "$moddir/virtio-dump.sh" "/usr/bin/virtio-dump"
install_unit_wants ignition-virtio-dump.service emergency.target
}
11 changes: 11 additions & 0 deletions dracut/99emergency-timeout/virtio-dump.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
set -euo pipefail

port=/dev/virtio-ports/com.coreos.ignition.journal
if [ -e "${port}" ]; then
journalctl -o json > "${port}"
# And this signals end of stream
echo '{}' > "${port}"
else
echo "Didn't find virtio port ${port}"
fi

0 comments on commit 554e8af

Please sign in to comment.