• David Johnson's avatar
    Attempt to safely work around systemd swap service on Ubuntu 16. · 7afd5f24
    David Johnson authored
    systemd.swap is one of its special builtin services.  Basically, swap
    devices are parsed out of fstab, or by examining a disk's GPT.  Any such
    devices are turned into instantiated units.  This happens via the
    systemd-fstab-generator.  Generators in systemd are almost
    uncontrollable.  They run immediately, prior to on-disk unit file
    parsing, and all you can do is disable or replace them.  You cannot
    express dependencies on the resulting units (unless you write your own
    generator).  Generators also run in an impoverished environment (think
    read-only /etc), so we cannot just add another generator that does
    basically what fixup-fstab-swaps does.  Finally, we cannot write a
    template unit file for all swap devices (we would use this to inject a
    blocking dependency so that these swap units don't conflict with us).
    Lennart has recognized the value in this, but thought the impl effort is
    pretty hard.  This makes sense, because the generators run prior to unit
    file load from disk (and presumably that would nix templates for
    generated units)... and I gather there are other problems as well.
    
    This is quite problematic for us because we rely on the ability to
    update /etc/fstab with the name of the real swap device, and to mkswap
    on it.  However, on machines with lots of cores, systemd is at its
    parallelizing best, and inevitably systemd tries to start up one of its
    instantiated swap device units at the same time as our fixup-fstab-swaps
    script is running.
    
    So I've done several things to try to deal with this situation.  First,
    this Ubuntu 16-specific version of fixup-fstab-swaps no longer adds a
    swap line to fstab with options=defaults -- instead it uses
    options=noauto,x-emulab-auto .  The noauto causes systemd's instantiated
    swap units to not automatically run on boot (don't worry, they become
    active if fixup-fstab-swaps swapons them, and thus they get swapped off
    prior to umount -- important that happens to avoid hangs); but our
    script will swapon the noauto,x-emulab-auto swap partitions as if they'd
    had options=default|auto.  What this does break is swapon/off -a --- but
    who cares.  The x-* comment option in fstab is something I didn't know
    about, I'll admit.
    
    Second, I've done is make emulab-fstab-fixup.service Conflict with
    swap.target, but also to be pulled in by swap.target!  The hope was that
    this would ensure that our service *always* runs successfully, even if
    it kills off swap.target to "handle" the conflict.  Well, the problem is
    that we need to Conflict with the instantiated swap unit files, not
    swap.target... so I think that isn't really working.  But I left it in
    -- maybe it is helping us win races.
    
    The one thing I cannot block is that systemd looks at the partition
    types of at least one of our hardware types (d820) and generates swap
    unit files by the partition UUID.  How it is doing this, I have no idea
    -- that behavior is only supposed to happen if your disk is GPT.  So we
    get failures on the d820s from the systemd instantiated swap units on
    first boot, but our scripts always do the right thing.
    7afd5f24
Name
Last commit
Last update
account Loading commit data...
apache Loading commit data...
apt Loading commit data...
assign Loading commit data...
autoconf Loading commit data...
autofs Loading commit data...
backend Loading commit data...
bugdb Loading commit data...
cdrom Loading commit data...
clientside Loading commit data...
collab Loading commit data...
daikon Loading commit data...
db Loading commit data...
delay Loading commit data...
dhcpd Loading commit data...
discvr Loading commit data...
doc Loading commit data...
event Loading commit data...
firewall Loading commit data...
flash Loading commit data...
fwrules Loading commit data...
hw_config Loading commit data...
hyperviewer Loading commit data...
image-test Loading commit data...
install Loading commit data...
ipod Loading commit data...
mobile Loading commit data...
mote Loading commit data...
named Loading commit data...
node_usage Loading commit data...
ntpd Loading commit data...
os Loading commit data...
patches Loading commit data...
pelab Loading commit data...
protogeni Loading commit data...
pxe Loading commit data...
rc.d Loading commit data...
robots Loading commit data...
rpms Loading commit data...
security Loading commit data...
sensors Loading commit data...
sql Loading commit data...
ssl Loading commit data...
sysadmin Loading commit data...
tbsetup Loading commit data...
testsuite Loading commit data...
tip Loading commit data...
tmcd Loading commit data...
tools Loading commit data...
utils Loading commit data...
vis Loading commit data...
wiki Loading commit data...
www Loading commit data...
xmlrpc Loading commit data...
.gitattributes Loading commit data...
.gitignore Loading commit data...
.gitmodules Loading commit data...
.loc-ignore Loading commit data...
AGPL-COPYING Loading commit data...
GNUmakefile.in Loading commit data...
GNUmakerules Loading commit data...
GPL-COPYING Loading commit data...
LGPL-COPYING Loading commit data...
MOVED-TO-WIKI Loading commit data...
Makeconf.in Loading commit data...
README Loading commit data...
TODO Loading commit data...
TODO.plab Loading commit data...
VERSION Loading commit data...
WEBtemplate.in Loading commit data...
config.h.in Loading commit data...
configure Loading commit data...
configure.ac Loading commit data...
defs-apt Loading commit data...
defs-cloudlab-clemson Loading commit data...
defs-cloudlab-utah Loading commit data...
defs-cloudlab-wisc Loading commit data...
defs-default Loading commit data...
defs-duerig-emulab Loading commit data...
defs-elabinelab Loading commit data...
defs-example Loading commit data...
defs-gtw-emulab Loading commit data...
defs-johnsond-emulab Loading commit data...
defs-kwebb-apt Loading commit data...
defs-kwebb-cloudlab Loading commit data...
defs-kwebb-emulab Loading commit data...
defs-mike-emulab Loading commit data...
defs-ricci-emulab Loading commit data...
defs-stoller-apt Loading commit data...
defs-stoller-emulab Loading commit data...
defs-stoller-home Loading commit data...
defs-stoller-lbsdb Loading commit data...
defs-uky Loading commit data...
defs-utahclient Loading commit data...
defs-wbsun-emulab Loading commit data...
defs-wide Loading commit data...
pnet-favicon.ico Loading commit data...