Skip to content

Commit

Permalink
Rely on CSV list to find pre-upgrade csvs rather than PackageManifest
Browse files Browse the repository at this point in the history
Signed-off-by: Shylesh Kumar Mohan <[email protected]>
  • Loading branch information
shylesh committed Oct 11, 2024
1 parent 4455e2a commit fc8d353
Showing 1 changed file with 46 additions and 10 deletions.
56 changes: 46 additions & 10 deletions ocs_ci/ocs/ocs_upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@
from ocs_ci.ocs.ocp import get_images, OCP
from ocs_ci.ocs.node import get_nodes
from ocs_ci.ocs.resources.catalog_source import CatalogSource, disable_specific_source
from ocs_ci.ocs.resources.csv import CSV, check_all_csvs_are_succeeded
from ocs_ci.ocs.resources.csv import (
CSV,
check_all_csvs_are_succeeded,
get_csvs_start_with_prefix,
)
from ocs_ci.ocs.resources.install_plan import wait_for_install_plan_and_approve
from ocs_ci.ocs.resources.pod import get_noobaa_pods, verify_pods_upgraded
from ocs_ci.ocs.resources.packagemanifest import (
Expand Down Expand Up @@ -60,6 +64,7 @@
from ocs_ci.ocs.exceptions import (
TimeoutException,
ExternalClusterRGWAdminOpsUserException,
CSVNotFound,
)
from ocs_ci.ocs.ui.base_ui import logger, login_ui
from ocs_ci.ocs.ui.views import locators, ODF_OPERATOR
Expand Down Expand Up @@ -358,26 +363,57 @@ def load_version_config_file(self, upgrade_version):
config.REPORTING["ocs_must_gather_image"] = must_gather_image
config.REPORTING["ocs_must_gather_latest_tag"] = must_gather_tag

# def get_csv_name_pre_upgrade(self, resource_name=OCS_OPERATOR_NAME):
# """
# Getting OCS operator name as displayed in CSV

# Returns:
# str: OCS operator name, as displayed in CSV

# """
# operator_selector = get_selector_for_ocs_operator()
# package_manifest = PackageManifest(
# resource_name=resource_name,
# selector=operator_selector,
# subscription_plan_approval=self.subscription_plan_approval,
# )
# if config.PREUPGRADE_CONFIG.get("DEPLOYMENT").get("ocs_csv_channel"):
# channel = config.PREUPGRADE_CONFIG.get("DEPLOYMENT").get("ocs_csv_channel")
# else:
# channel = config.DEPLOYMENT.get("ocs_csv_channel")

# return package_manifest.get_current_csv(channel)

def get_csv_name_pre_upgrade(self, resource_name=OCS_OPERATOR_NAME):
"""
Getting OCS operator name as displayed in CSV
Get pre-upgrade CSV name
Returns:
str: OCS operator name, as displayed in CSV
Ealier we used to depend on packagemanifest to find the pre-upgrade
csv name. Due to issues in catalogsource where csv names were not shown properly once
catalogsource for upgrade version has been created, we are taking new approach of
finding csv name from csv list and also look for pre-upgrade ocs version for finding out
the actual csv
"""

operator_selector = get_selector_for_ocs_operator()
package_manifest = PackageManifest(
resource_name=resource_name,
selector=operator_selector,
subscription_plan_approval=self.subscription_plan_approval,
)
csv_name = None
if config.PREUPGRADE_CONFIG.get("DEPLOYMENT").get("ocs_csv_channel"):
channel = config.PREUPGRADE_CONFIG.get("DEPLOYMENT").get("ocs_csv_channel")
else:
channel = config.DEPLOYMENT.get("ocs_csv_channel")

return package_manifest.get_current_csv(channel)
csv_list = get_csvs_start_with_prefix(resource_name, namespace=self.namespace)
log.info(f"resource name = {resource_name}")
log.info(f"csv list = {csv_list}")
log.info(f"VERSION = {config.PREUPGRADE_CONFIG.get('ENV_DATA').get('ocs_version')}")
for csv in csv_list:
if resource_name in csv.get("metadata").get("name"):
if config.PREUPGRADE_CONFIG.get("ENV_DATA").get("ocs_version") in csv:
csv_name = csv
if not csv_name:
raise CSVNotFound(f"No preupgrade CSV found for {resource_name}")
return csv_name

def get_pre_upgrade_image(self, csv_name_pre_upgrade):
"""
Expand Down

0 comments on commit fc8d353

Please sign in to comment.