From 873b51b34057d9d13c628289f57b10dec07b2060 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= <ludo@gnu.org>
Date: Tue, 2 Aug 2016 12:34:14 +0200
Subject: [PATCH] mapped-devices: Bail out when RAID sources don't show up.

* gnu/system/mapped-devices.scm (open-raid-device): Bail out after 20
loop iterations.
---
 gnu/system/mapped-devices.scm | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/gnu/system/mapped-devices.scm b/gnu/system/mapped-devices.scm
index 2a0706e50b0..ce0a78a2ad5 100644
--- a/gnu/system/mapped-devices.scm
+++ b/gnu/system/mapped-devices.scm
@@ -135,12 +135,16 @@ (define (open-raid-device sources target)
       (use-modules (srfi srfi-1) (ice-9 format))
 
       (let ((sources '#$sources))
-        (let loop ()
+        (let loop ((attempts 0))
           (unless (every file-exists? sources)
+            (when (> attempts 20)
+              (error "RAID devices did not show up; bailing out"
+                     sources))
+
             (format #t "waiting for RAID source devices~{ ~a~}...~%"
                     sources)
             (sleep 1)
-            (loop)))
+            (loop (+ 1 attempts))))
 
         (zero? (system* (string-append #$mdadm "/sbin/mdadm")
                         "--assemble" #$target sources)))))
-- 
GitLab