From 9af0fa6aa9e0b92a1ad6c4587834880c778182ce Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Mon, 15 Feb 2010 10:27:59 +0100
Subject: [PATCH] Auto-enable early release for offline old nodes

In case the old node is offline, we won't be able to talk to it to
remove the storage, and in most cases the node is powered
off/unreachable.

In this case, it makes no sense to delay the storage release, so we
enable automatically early_release mode, gaining parallelism during node
evacuation.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>
---
 lib/cmdlib.py | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/lib/cmdlib.py b/lib/cmdlib.py
index 6a4e0dfaf..8d4adffc5 100644
--- a/lib/cmdlib.py
+++ b/lib/cmdlib.py
@@ -6715,6 +6715,14 @@ class TLReplaceDisks(Tasklet):
 
         _CheckNodeNotDrained(self.lu, remote_node)
 
+        old_node_info = self.cfg.GetNodeInfo(secondary_node)
+        assert old_node_info is not None
+        if old_node_info.offline and not self.early_release:
+          # doesn't make sense to delay the release
+          self.early_release = True
+          self.lu.LogInfo("Old secondary %s is offline, automatically enabling"
+                          " early-release mode", secondary_node)
+
       else:
         raise errors.ProgrammerError("Unhandled disk replace mode (%s)" %
                                      self.mode)
-- 
GitLab