From 87e634dee1dfaec80b428cad459d174d65ce1b68 Mon Sep 17 00:00:00 2001
From: Dmitry Tantsur <dtantsur@protonmail.com>
Date: Tue, 27 Oct 2020 08:45:20 +0100
Subject: [PATCH] CI: increase cleaning timeout and tie it to PXE boot timeout

We're seeing cases where cleaning barely manages to finish after
a 2nd PXE retry, failing a job.

Also make the PXE retry timeout consistent between the CI and
local devstack installations.

Change-Id: I6dc7a91d1a482008cf4ec855a60a95ec0a1abe28
---
 devstack/lib/ironic     | 12 ++++++++----
 zuul.d/ironic-jobs.yaml |  1 -
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/devstack/lib/ironic b/devstack/lib/ironic
index b0280f3fbb..4661084669 100644
--- a/devstack/lib/ironic
+++ b/devstack/lib/ironic
@@ -97,7 +97,7 @@ IRONIC_CALLBACK_TIMEOUT=${IRONIC_CALLBACK_TIMEOUT:-}
 
 # Timeout before retrying PXE boot. Set low to help the CI.
 if [[ "$IRONIC_IS_HARDWARE" == False ]]; then
-    IRONIC_PXE_BOOT_RETRY_TIMEOUT=${IRONIC_PXE_BOOT_RETRY_TIMEOUT:-600}
+    IRONIC_PXE_BOOT_RETRY_TIMEOUT=${IRONIC_PXE_BOOT_RETRY_TIMEOUT:-900}
 else
     IRONIC_PXE_BOOT_RETRY_TIMEOUT=${IRONIC_PXE_BOOT_RETRY_TIMEOUT:-}
 fi
@@ -665,9 +665,13 @@ fi
 
 # Timeout for "manage" action. 2 minutes is more than enough.
 IRONIC_MANAGE_TIMEOUT=${IRONIC_MANAGE_TIMEOUT:-120}
-# Timeout for "provide" action. This involves cleaning. Generally, 15 minutes
-# should be enough, but real hardware may need more.
-IRONIC_CLEANING_TIMEOUT=${IRONIC_CLEANING_TIMEOUT:-1200}
+# Timeout for "provide" action. This involves cleaning.
+if [[ -n "$IRONIC_PXE_BOOT_RETRY_TIMEOUT" ]]; then
+    IRONIC_DEFAULT_CLEANING_TIMEOUT=$(( $IRONIC_PXE_BOOT_RETRY_TIMEOUT * 2 ))
+else
+    IRONIC_DEFAULT_CLEANING_TIMEOUT=1800
+fi
+IRONIC_CLEANING_TIMEOUT=${IRONIC_CLEANING_TIMEOUT:-$IRONIC_DEFAULT_CLEANING_TIMEOUT}
 
 IRONIC_CLEANING_DELAY=10
 IRONIC_CLEANING_ATTEMPTS=$(( $IRONIC_CLEANING_TIMEOUT / $IRONIC_CLEANING_DELAY ))
diff --git a/zuul.d/ironic-jobs.yaml b/zuul.d/ironic-jobs.yaml
index 0c9c5c77b7..a48b88a83f 100644
--- a/zuul.d/ironic-jobs.yaml
+++ b/zuul.d/ironic-jobs.yaml
@@ -39,7 +39,6 @@
         IRONIC_BAREMETAL_BASIC_OPS: True
         IRONIC_BUILD_DEPLOY_RAMDISK: False
         IRONIC_CALLBACK_TIMEOUT: 1800
-        IRONIC_PXE_BOOT_RETRY_TIMEOUT: 900
         IRONIC_DEPLOY_DRIVER: ipmi
         IRONIC_INSPECTOR_BUILD_RAMDISK: False
         IRONIC_INSPECTOR_TEMPEST_INTROSPECTION_TIMEOUT: 1200