Skip to content

Commit

Permalink
Handle reload of the configs during upgrades
Browse files Browse the repository at this point in the history
Signed-off-by: Shylesh Kumar Mohan <shmohan@redhat.com>
  • Loading branch information
shylesh authored and amr1ta committed Oct 8, 2024
1 parent 2e394da commit c7eb756
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ocs_ci/framework/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ class Config:
COMPONENTS: dict = field(default_factory=dict)
# Used for multicluster only
MULTICLUSTER: dict = field(default_factory=dict)
# Use this variable to store any arbitrary key/values related
# to the upgrade context. Applicable only in the multicluster upgrade
# scenario
PREUPGRADE_CONFIG = field(default_factory=dict)

def __post_init__(self):
self.reset()
Expand Down
22 changes: 22 additions & 0 deletions ocs_ci/ocs/ocs_upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from pkg_resources import parse_version
from tempfile import NamedTemporaryFile
import time
import yaml

from selenium.webdriver.common.by import By
from ocs_ci.framework import config
Expand Down Expand Up @@ -305,6 +306,18 @@ def get_parsed_versions(self):

return parsed_version_before_upgrade, parsed_upgrade_version

def store_pre_upgrade_ctx(self):
"""
Store pre upgrade ctx values in config.upgrade_ctx
"""
version_config_file = os.path.join(
constants.OCS_VERSION_CONF_DIR, f"ocs-{self.version_before_upgrade}.yaml"
)
buf = yaml.safe_load(version_config_file)



def load_version_config_file(self, upgrade_version):
"""
Loads config file to the ocs-ci config with upgrade version
Expand All @@ -326,6 +339,15 @@ def load_version_config_file(self, upgrade_version):
version_config_file = os.path.join(
constants.OCS_VERSION_CONF_DIR, f"ocs-{upgrade_version}.yaml"
)
if config.multicluster:
# In case of multicluster upgrade
# we need to preserve the old config values so that
# any following tests will not read overwritten values
# we want to do it only once and the first test which hits this function
# will have the responsibility to store the previous config values
# TODO: CHANGE THIS TO STORE THE CONTEXT IN THE RESPECTIVE
# CONFIG CLASS DURING INITIAL STAGES OF THE UPGRADE RUN
self.save_pre_upgrade_ctx(version_config_file)
log.info(f"Reloading config file for OCS/ODF version: {upgrade_version}.")
load_config_file(version_config_file)
else:
Expand Down

0 comments on commit c7eb756

Please sign in to comment.