From 183ac04745ac69ce8c09877496cd36fd65f33313 Mon Sep 17 00:00:00 2001 From: David Sullivan Date: Mon, 2 Apr 2018 00:14:40 -0400 Subject: [PATCH] AIO-DX: Controller-1 unlock failed on first attempt after upgrade The sysinv data is not migrated to the N+1 version until after the sysinv agent is run. This prevents the sysinv agent from adding the UUID to the platform conf, which prevents compute huge from setting the correct Kernel boot arguments. We set the UUID during the data migration so compute huge can update the boot arguments when the node is unlocked which will prevent the extra reboot. Change-Id: Iecf03dd9e30b37419939f50677305066841a2fa8 Story: 2002886 Task: 22847 Signed-off-by: Jack Ding --- controllerconfig/centos/build_srpm.data | 2 +- .../controllerconfig/upgrades/controller.py | 38 +++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/controllerconfig/centos/build_srpm.data b/controllerconfig/centos/build_srpm.data index ee1536fa50..3513c6ef86 100755 --- a/controllerconfig/centos/build_srpm.data +++ b/controllerconfig/centos/build_srpm.data @@ -1,2 +1,2 @@ SRC_DIR="controllerconfig" -TIS_PATCH_VER=143 +TIS_PATCH_VER=144 diff --git a/controllerconfig/controllerconfig/controllerconfig/upgrades/controller.py b/controllerconfig/controllerconfig/controllerconfig/upgrades/controller.py index d0700b96f2..3524d806d5 100644 --- a/controllerconfig/controllerconfig/controllerconfig/upgrades/controller.py +++ b/controllerconfig/controllerconfig/controllerconfig/upgrades/controller.py @@ -1004,6 +1004,40 @@ def nova_fix_db_connect(packstack_config): LOG.info("Finished fixup of nova cells database connections.") +def get_controller_1_uuid(): + """ Read in the uuid from the sysinv db""" + conn = psycopg2.connect("dbname=sysinv user=postgres") + with conn: + with conn.cursor() as cur: + cur.execute("select uuid from i_host where hostname=" + "'controller-1';") + row = cur.fetchone() + if row is None: + LOG.error("Failed to fetch controller-1 uuid") + raise Exception("Error reading controller UUID") + + return row[0] + + +def update_platform_conf_file(uuid): + """ Update the platform conf file with the uuid + This is needed for the compute_huge script to update the CPU + allocations + """ + if os.path.isfile(PLATFORM_CONF_FILE): + # read the platform config file and check for UUID + with open(PLATFORM_CONF_FILE, "r") as fd: + for line in fd: + if line.find("UUID=") == 0: + LOG.info("Found UUID in platform.conf: %s" % line) + return + + # the UUID is not found, append it + LOG.info("Appending UUID to platform.conf. UUID: %s" % uuid) + with open(PLATFORM_CONF_FILE, "a") as fd: + fd.write("UUID=" + uuid + "\n") + + def upgrade_controller(from_release, to_release): """ Executed on the release N+1 side upgrade controller-1. """ @@ -1112,6 +1146,10 @@ def upgrade_controller(from_release, to_release): utils.execute_migration_scripts( from_release, to_release, utils.ACTION_MIGRATE) + uuid = get_controller_1_uuid() + + update_platform_conf_file(uuid) + # Stop postgres server try: subprocess.check_call(['sudo',