Fix NFD-related errors in application-apply

In this commit, fix the error "Application-apply rejected: string
indices must be integers". This code raises "Node Feature Discovery
(NFD) Application is required." error if NFD is not installed and
user_overrides contains "None" or "nfd-required: true".

It raises "Node Feature Discovery (NFD) Application is required
nfd-required must be True." error if NFD is not installed and
user_overrides contains "nfd-required: false"

It will only allow application-apply when Node Feature Discovery
(NFD) Application is installed.

TEST CASES:

PASSED: Build process is successful with creation of debian package.
        After package extraction confirmed the helm tar file is present.
PASSED: Tested application upload/apply/remove/delete in AIO-SX.
PASSED: Error raised "Node Feature Discovery (NFD) Application is
        required." when intel-device-plugins-operator application is
        applied without NFD installed and user_overrides contains
        "None" or "nfd-required: true".
PASSED: Error raised "Node Feature Discovery (NFD) Application is
        required and nfd-required must be True." when
        intel-device-plugins-operator application is applied without
        NFD installed and user_overrides contains "nfd-required: false"
PASSED: Label will not be removed when node-feature-discovery app is
        deleted.

Story: 2010604
Task: 50599

Change-Id: Ife494fce7035339bc933d4f01455fdf2ead74776
Signed-off-by: Md Irshad Sheikh <mdirshad.sheikh@windriver.com>
This commit is contained in:
Md Irshad Sheikh
2024-07-18 02:27:15 -04:00
parent a2805c156d
commit 5a14570691

View File

@@ -1,5 +1,5 @@
#
# Copyright (c) 2023 Wind River Systems, Inc.
# Copyright (c) 2023-2024 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
@@ -89,19 +89,23 @@ class IntelDevicePluginsAppLifecycleOperator(base.AppLifecycleOperator):
app = dbapi_instance.kube_app_get(
app_constants.HELM_APP_INTEL_DEVICE_PLUGINS_OPERATOR)
db_app_id = dbapi_instance.kube_app_get(app.name).id
# user_overrides = self._get_user_overrides(app, dbapi)
charts = self._get_charts_enabled(dbapi_instance, db_app_id)
for chart in charts:
# Loading user-overrides
user_overrides = chart['user_overrides']
if user_overrides and app_constants.HELM_NFD_REQUIRED_PARAM in user_overrides:
if isinstance(user_overrides[app_constants.HELM_NFD_REQUIRED_PARAM], bool):
val = user_overrides[app_constants.HELM_NFD_REQUIRED_PARAM]
LOG.error(f"The value of parameter "
f"{app_constants.HELM_NFD_REQUIRED_PARAM} must be "
"true or false.")
if user_overrides:
dict_chart_overrides = yaml.safe_load(user_overrides)
value = dict_chart_overrides.get(app_constants.HELM_NFD_REQUIRED_PARAM)
if isinstance(value, bool):
if not value:
raise exception.LifecycleSemanticCheckException(
"Node Feature Discovery (NFD) Application is required and "
f"{app_constants.HELM_NFD_REQUIRED_PARAM} must be True.")
else:
LOG.error(f"The value of parameter "
f"{app_constants.HELM_NFD_REQUIRED_PARAM} must be "
"true or false.")
except exception.KubeAppNotFound as e:
LOG.error("Failed to access app info "