Separates the type of operation in the semantic check condition

The change made in [1] created a bug when creating a new storage
using a new tier, where the storageclass was not created.

This happened because when it is an operation of type
APP_EVALUATE_REAPPLY_OP, relative_timing is not sent in lifecycle,
and this caused an exception that was caught by the conductor:

ERROR sysinv.conductor.manager [-] Unexpected error during hook
for app platform-integ-apps, error: Cannot load 'relative_timing'
in the base class: NotImplementedError: Cannot load 'relative_timing'
in the base class.

To resolve this, the condition to check relative_timing only if the
operation is APP_APPLY_OP was corrected.

[1]: https://review.opendev.org/c/starlingx/platform-armada-app/+/907246

Test Plan:
  PASS: Apply pkg with this changes
  PASS: Create new storage using new tier

Closes-bug: 2054738

Change-Id: I6ff7180e339a55ac5dfe20e378cb301e52eaa6a3
Signed-off-by: Erickson Silva de Oliveira <Erickson.SilvadeOliveira@windriver.com>
This commit is contained in:
Erickson Silva de Oliveira 2024-02-22 17:44:16 -03:00
parent 99d4652354
commit d3048d0f04

View File

@ -40,9 +40,9 @@ class PlatformAppLifecycleOperator(base.AppLifecycleOperator):
# Semantic checks # Semantic checks
if hook_info.lifecycle_type == constants.APP_LIFECYCLE_TYPE_SEMANTIC_CHECK: if hook_info.lifecycle_type == constants.APP_LIFECYCLE_TYPE_SEMANTIC_CHECK:
if hook_info.mode == constants.APP_LIFECYCLE_MODE_AUTO and \ if hook_info.mode == constants.APP_LIFECYCLE_MODE_AUTO and \
hook_info.operation in [constants.APP_APPLY_OP, ((hook_info.operation == constants.APP_APPLY_OP and
constants.APP_EVALUATE_REAPPLY_OP] and \ hook_info.relative_timing == constants.APP_LIFECYCLE_TIMING_PRE) or
hook_info.relative_timing == constants.APP_LIFECYCLE_TIMING_PRE: hook_info.mode == constants.APP_EVALUATE_REAPPLY_OP):
return self.pre_auto_apply_check(conductor_obj) return self.pre_auto_apply_check(conductor_obj)
# Rbd # Rbd
@ -86,6 +86,9 @@ class PlatformAppLifecycleOperator(base.AppLifecycleOperator):
if not os.path.isfile(crushmap_flag_file): if not os.path.isfile(crushmap_flag_file):
raise exception.LifecycleSemanticCheckException( raise exception.LifecycleSemanticCheckException(
"Crush map not applied") "Crush map not applied")
if conductor_obj is None:
raise exception.LifecycleSemanticCheckException(
"Conductor object is None")
# conductor_obj._ceph (CephOperator) may not be initialized # conductor_obj._ceph (CephOperator) may not be initialized
# at this point, as it depends on ceph and system conditions # at this point, as it depends on ceph and system conditions
# to start the thread that initializes it # to start the thread that initializes it