The source cluster has to shut down an instance before it can be
exported. Doing so can take a while, but the default connection timeout
is only 60 seconds. Adding the shutdown timeout on the receiving cluster
should help.

Signed-off-by: Michael Hanselmann <[email protected]>
---
 lib/cmdlib.py  |    8 +++++++-
 lib/opcodes.py |    3 +++
 2 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/lib/cmdlib.py b/lib/cmdlib.py
index 5618579..f2641a6 100644
--- a/lib/cmdlib.py
+++ b/lib/cmdlib.py
@@ -6930,6 +6930,8 @@ class LUCreateInstance(LogicalUnit):
     ("source_handshake", None, ht.TOr(ht.TList, ht.TNone)),
     ("source_x509_ca", None, ht.TMaybeString),
     ("source_instance_name", None, ht.TMaybeString),
+    ("source_shutdown_timeout", constants.DEFAULT_SHUTDOWN_TIMEOUT,
+     ht.TPositiveInt),
     ("src_node", None, ht.TMaybeString),
     ("src_path", None, ht.TMaybeString),
     ("pnode", None, ht.TMaybeString),
@@ -7799,7 +7801,11 @@ class LUCreateInstance(LogicalUnit):
 
       elif self.op.mode == constants.INSTANCE_REMOTE_IMPORT:
         feedback_fn("* preparing remote import...")
-        connect_timeout = constants.RIE_CONNECT_TIMEOUT
+        # The source cluster will stop the instance before attempting to make a
+        # connection. In some cases stopping an instance can take a long time,
+        # hence the shutdown timeout is added to the connection timeout.
+        connect_timeout = (constants.RIE_CONNECT_TIMEOUT +
+                           self.op.source_shutdown_timeout)
         timeouts = masterd.instance.ImportExportTimeouts(connect_timeout)
 
         assert iobj.primary_node == self.pnode.name
diff --git a/lib/opcodes.py b/lib/opcodes.py
index 6cfffbe..4587afa 100644
--- a/lib/opcodes.py
+++ b/lib/opcodes.py
@@ -481,6 +481,8 @@ class OpCreateInstance(OpCode):
   @ivar source_handshake: Signed handshake from source (remote import only)
   @ivar source_x509_ca: Source X509 CA in PEM format (remote import only)
   @ivar source_instance_name: Previous name of instance (remote import only)
+  @ivar source_shutdown_timeout: Shutdown timeout used for source instance
+    (remote import only)
 
   """
   OP_ID = "OP_INSTANCE_CREATE"
@@ -498,6 +500,7 @@ class OpCreateInstance(OpCode):
     "source_handshake",
     "source_x509_ca",
     "source_instance_name",
+    "source_shutdown_timeout",
     ]
 
 
-- 
1.7.3.1

Reply via email to