Ema has submitted this change and it was merged.

Change subject: Workaround for mdadm boot-time race condition
......................................................................


Workaround for mdadm boot-time race condition

The boot-time race condition assembling raid devices reported in T131961
can be avoided by sleeping a few seconds in initramfs-tools' local-top
stage, after which the root device is expected to be present.

See FAQ 26. in /usr/share/doc/mdadm/FAQ.gz.

This patch introduces a new puppet module called initramfs, allowing to
define initramfs hooks and scripts.

Bug: T131961
Change-Id: I12db18dee30c67f98f7dd567e7527d43c134c5a7
---
M modules/base/manifests/init.pp
A modules/base/manifests/initramfs.pp
A modules/base/templates/initramfs_sleep.erb
A modules/initramfs/manifests/hook.pp
A modules/initramfs/manifests/init.pp
A modules/initramfs/manifests/script.pp
6 files changed, 60 insertions(+), 0 deletions(-)

Approvals:
  Ema: Verified; Looks good to me, approved
  BBlack: Looks good to me, but someone else must approve



diff --git a/modules/base/manifests/init.pp b/modules/base/manifests/init.pp
index 5f2dc11..5135102 100644
--- a/modules/base/manifests/init.pp
+++ b/modules/base/manifests/init.pp
@@ -34,6 +34,10 @@
     include base::kernel
     include base::debdeploy
 
+    if os_version('debian >= jessie') {
+        include base::initramfs
+    }
+
     # include base::monitor::host.
     # if contactgroups is set, then use it
     # as the monitor host's contact group.
diff --git a/modules/base/manifests/initramfs.pp 
b/modules/base/manifests/initramfs.pp
new file mode 100644
index 0000000..ddfc517
--- /dev/null
+++ b/modules/base/manifests/initramfs.pp
@@ -0,0 +1,6 @@
+class base::initramfs($localtop_sleep = '5s') {
+    initramfs::script { 'mdadm-sleep':
+        boot_stage => 'local-top',
+        content    => template('base/initramfs_sleep.erb'),
+    }
+}
diff --git a/modules/base/templates/initramfs_sleep.erb 
b/modules/base/templates/initramfs_sleep.erb
new file mode 100644
index 0000000..d64aae7
--- /dev/null
+++ b/modules/base/templates/initramfs_sleep.erb
@@ -0,0 +1,11 @@
+#!/bin/sh
+#
+# Workaround for boot-time race condition assembling raid arrays:
+# https://phabricator.wikimedia.org/T131961
+#
+# This file is managed by Puppet.
+
+echo "Waiting <%= @localtop_sleep -%> for disks to show up (T131961)"
+sleep <%= @localtop_sleep -%>
+
+exit 0
diff --git a/modules/initramfs/manifests/hook.pp 
b/modules/initramfs/manifests/hook.pp
new file mode 100644
index 0000000..033c480
--- /dev/null
+++ b/modules/initramfs/manifests/hook.pp
@@ -0,0 +1,11 @@
+define initramfs::hook($content='') {
+    include initramfs
+
+    file { "/etc/initramfs-tools/hooks/${title}":
+        owner   => 'root',
+        group   => 'root',
+        mode    => '0544',
+        content => $content,
+        notify  => Exec['update-initramfs'],
+    }
+}
diff --git a/modules/initramfs/manifests/init.pp 
b/modules/initramfs/manifests/init.pp
new file mode 100644
index 0000000..962eff6
--- /dev/null
+++ b/modules/initramfs/manifests/init.pp
@@ -0,0 +1,12 @@
+class initramfs {
+    package { 'initramfs-tools':
+        ensure => installed,
+    }
+
+    exec { 'update-initramfs':
+        refreshonly => true,
+        command     => 'update-initramfs -u -k all',
+        path        => '/bin:/usr/bin:/sbin:/usr/sbin',
+        require     => Package['initramfs-tools'],
+    }
+}
diff --git a/modules/initramfs/manifests/script.pp 
b/modules/initramfs/manifests/script.pp
new file mode 100644
index 0000000..8c094eb
--- /dev/null
+++ b/modules/initramfs/manifests/script.pp
@@ -0,0 +1,16 @@
+define initramfs::script($boot_stage='', $content='') {
+    include initramfs
+
+    case $boot_stage {
+        'init-bottom', 'init-premount', 'init-top', 'local-bottom', 
'local-premount', 'local-top', 'nfs-bottom', 'nfs-premount', 'nfs-top', 
'panic': {}
+        default: { fail("Unsupported initramfs stage: ${boot_stage}") }
+    }
+
+    file { "/etc/initramfs-tools/scripts/${boot_stage}/${title}":
+        owner   => 'root',
+        group   => 'root',
+        mode    => '0544',
+        content => $content,
+        notify  => Exec['update-initramfs'],
+    }
+}

-- 
To view, visit https://gerrit.wikimedia.org/r/283459
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I12db18dee30c67f98f7dd567e7527d43c134c5a7
Gerrit-PatchSet: 4
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Ema <[email protected]>
Gerrit-Reviewer: BBlack <[email protected]>
Gerrit-Reviewer: Ema <[email protected]>
Gerrit-Reviewer: Faidon Liambotis <[email protected]>
Gerrit-Reviewer: Filippo Giunchedi <[email protected]>
Gerrit-Reviewer: Gehel <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to