From 90c8e6aaf9b1b2cc5edebc696ac7c82aa69a20c7 Mon Sep 17 00:00:00 2001 From: Jorge Saffe Date: Tue, 28 Mar 2023 12:35:38 -0400 Subject: [PATCH] Replay of bootstrap playbook fails providing initial system config During system bootstrap, after bootstrap ansible playbook starts, if it fails after completing persist-config step and before k8s service is started, the installation will fail again when trying to replay the bootstrap ansible playbook. Test Plan: PASS: Start fresh install with Debian AIO-SX. PASS: Stop bootstrap ansible playbook after persist-config step. PASS: Replay bootstrap ansible playbook and complete the installation. PASS: Add extra-volumes during runtime, apply changes and delete. Closes-Bug: 2013103 Signed-off-by: Jorge Saffe Change-Id: I59f08b587c45c405a4ce1afc88913efd7befe8f9 --- .../sysinv/api/controllers/v1/service_parameter.py | 11 ++++++++++- tsconfig/tsconfig/tsconfig/tsconfig.py | 3 +++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/sysinv/sysinv/sysinv/sysinv/api/controllers/v1/service_parameter.py b/sysinv/sysinv/sysinv/sysinv/api/controllers/v1/service_parameter.py index 9baa917e65..b1da3a090e 100644 --- a/sysinv/sysinv/sysinv/sysinv/api/controllers/v1/service_parameter.py +++ b/sysinv/sysinv/sysinv/sysinv/api/controllers/v1/service_parameter.py @@ -1,4 +1,4 @@ -# Copyright (c) 2015-2022 Wind River Systems, Inc. +# Copyright (c) 2015-2023 Wind River Systems, Inc. # # SPDX-License-Identifier: Apache-2.0 # @@ -39,6 +39,8 @@ from sysinv.common import service_parameter from sysinv.common import utils as cutils from sysinv.openstack.common.rpc import common as rpc_common +from tsconfig.tsconfig import INITIAL_K8S_CONFIG_COMPLETE + LOG = log.getLogger(__name__) k8s_volumes_sections = [ @@ -63,6 +65,13 @@ def delete_k8s_configmap(parameter, kube_operator): """ _volume, _noConfigMap = service_parameter.parse_volume_string_to_dict(parameter) + # only removes the configmaps if k8s has been initialized + # this case is only valid during the bootstrap scenario. When the ansible + # playbook fails before the k8s service is initialized, during a replay + # it will fail when trying to remove configmaps that don't exist yet. + if not os.path.isfile(INITIAL_K8S_CONFIG_COMPLETE): + return + # only delete configmaps for 'File' type since # 'DirectoryorCreate' type has no associated configmaps pathType = _volume['pathType'] diff --git a/tsconfig/tsconfig/tsconfig/tsconfig.py b/tsconfig/tsconfig/tsconfig/tsconfig.py index db3c926690..0b6a0db6ee 100644 --- a/tsconfig/tsconfig/tsconfig/tsconfig.py +++ b/tsconfig/tsconfig/tsconfig/tsconfig.py @@ -201,6 +201,9 @@ PLATFORM_BACKUP_PATH = '/opt/platform-backup' # Set after the first application of controller manifests INITIAL_CONTROLLER_CONFIG_COMPLETE = os.path.join( PLATFORM_CONF_PATH, ".initial_controller_config_complete") +# Set after initial K8s config is completed +INITIAL_K8S_CONFIG_COMPLETE = os.path.join( + PLATFORM_CONF_PATH, ".initial_k8s_config_complete") # Set after each application of controller manifests VOLATILE_CONTROLLER_CONFIG_COMPLETE = os.path.join( VOLATILE_PATH, ".controller_config_complete")