From 714826d1a27085ba2384ca495c876588d77f0d27 Mon Sep 17 00:00:00 2001
From: Lee Yarwood <lyarwood@redhat.com>
Date: Mon, 4 Oct 2021 18:07:17 +0100
Subject: [PATCH] nova: Ensure each compute uses a unique iSCSI initiator

The current initiator name embedded in our CI images is not unique at
present and can often cause failures during live migrations with
attached volumes. This change ensures the name is unique by running
iscsi-iname again and overwriting the existing name.

We could potentially do this during the image build process itself but
given that devstack systems are not supposed to be multi-purpose this
should be safe to do during the devstack run.

Closes-Bug: #1945983
Change-Id: I9ed26a17858df96c04be9ae52bf2e33e023869a5
---
 lib/nova | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lib/nova b/lib/nova
index f4f4797b86..bbb1039199 100644
--- a/lib/nova
+++ b/lib/nova
@@ -298,6 +298,9 @@ function configure_nova {
             fi
         fi
 
+        # Ensure each compute host uses a unique iSCSI initiator
+        echo InitiatorName=$(iscsi-iname) | sudo tee /etc/iscsi/initiatorname.iscsi
+
         if [[ ${ISCSID_DEBUG} == "True" ]]; then
             # Install an override that starts iscsid with debugging
             # enabled.