Remove unnecessary code for stx.10.0

This commit removes code from the lifecycle script that was only
needed for stx.8.0 -> stx.9.0 upgrades.

The purpose of the code was to update the user overrides of
'classes' (when existing) to 'storageClasses', a change
that occurred in the version of platform-integ-apps
from stx.8.0 to stx.9.0.

Since the platform upgrade to stx.10.0 will only be allowed from
stx.9.0, and the platform-integ-apps of both versions will have
'storageClasses', the code is no longer necessary.

In addition to no longer needing the code, it caused an issue.
In a scenario where there were user overrides of 'classes'
before the app update, every time there is an apply with new
overrides after the update, the value to be considered
returned to the 'classes' overrides of the old app version
just with the name change. In other words, after the update in
this scenario, it is not possible to use new overrides for
'storageClasses'. Removing the code fixes this.

Closes-bug: 2076461

Test Plan:
 PASS: Build a new app package with the code changes
 PASS: Successfully execute upload, apply, remove, update and delete
       operations for 'platform-integ-apps' on both AIO-SX and
       AIO-DX environments.
 PASS: Using an old app version, create user overrides for 'classes'.
       Then, update the application to the master version (without
       the current changes, this update will change 'classes' to
       'storageClasses'). Next, update the app to the version built
       with the changes from this review and test the use of new
       user overrides for 'storageClasses'.

Change-Id: Ia3d8cd2bdeb3a60bf97e005e56899d1a0965042c
Signed-off-by: Gabriel de Araújo Cabral <gabriel.cabral@windriver.com>
This commit is contained in:
Gabriel de Araújo Cabral 2024-08-09 16:56:31 -03:00
parent e49ef87109
commit 162653536f

View File

@ -18,10 +18,8 @@ from sysinv.common import constants
from sysinv.common import exception
from sysinv.common import kubernetes
from sysinv.common import utils as cutils
from sysinv.db import api as dbapi
from sysinv.helm import lifecycle_base as base
from sysinv.helm import lifecycle_utils as lifecycle_utils
from k8sapp_platform.common import constants as app_constants
LOG = logging.getLogger(__name__)
@ -114,9 +112,7 @@ class PlatformAppLifecycleOperator(base.AppLifecycleOperator):
def pre_apply(self, app_op, app, hook_info):
"""Pre Apply actions
Creates the local registry secret and rename user overrides from
'classes' to 'storageClasses' in the rbd and cephfs charts if
necessary.
This function creates the local registry secret.
:param app_op: AppOperator object
:param app: AppOperator.Application object
@ -125,47 +121,6 @@ class PlatformAppLifecycleOperator(base.AppLifecycleOperator):
"""
lifecycle_utils.create_local_registry_secrets(app_op, app, hook_info)
# TODO: The code below is for stx.8.0 -> stx.9.0 updates.
# It may be removed in the stx.10.0 release cycle
dbapi_instance = dbapi.get_instance()
# get most recently created inactive app
inactive_db_apps = dbapi_instance.kube_app_get_inactive(
app.name, limit=1, sort_key='created_at', sort_dir='desc')
if not inactive_db_apps:
# user overrides will not be updated because there is no
# inactive platform-integ-apps entry in the database
return
from_db_app = inactive_db_apps[0]
to_db_app = dbapi_instance.kube_app_get(app.name)
charts = [
app_constants.FLUXCD_HELMRELEASE_CEPH_FS_PROVISIONER,
app_constants.FLUXCD_HELMRELEASE_RBD_PROVISIONER,
]
# update of user overrides due to changing 'classes' to 'storageClasses'
# to improve understanding. The namespace of both charts are the same
for chart in charts:
user_overrides = self._get_helm_user_overrides(
dbapi_instance,
from_db_app,
chart,
app_constants.K8S_CEPHFS_PROVISIONER_DEFAULT_NAMESPACE)
if 'classes:' in user_overrides:
user_overrides = user_overrides.replace("classes:", "storageClasses:")
self._update_helm_user_overrides(
dbapi_instance,
to_db_app,
chart,
app_constants.K8S_CEPHFS_PROVISIONER_DEFAULT_NAMESPACE,
user_overrides,
)
LOG.debug("User overrides of 'classes' updated to 'storageClasses'"
" in {} chart from {}".format(chart, app.name))
def delete_csi_drivers(self, app):
""" Delete CSI drivers