Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release-4.17] Get current ODF CSV for ROKS cluster from Install Plan #11112

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 16 additions & 9 deletions ocs_ci/ocs/resources/packagemanifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,15 @@ def get_current_csv(self, channel=None, csv_pattern=constants.OCS_CSV_PREFIX):
self.check_name_is_specified()
channel = channel if channel else self.get_default_channel()
channels = self.get_channels()
if self.subscription_plan_approval == "Manual":
managed_ibmcloud = (
config.ENV_DATA["platform"] == constants.IBMCLOUD_PLATFORM
and config.ENV_DATA["deployment_type"] == "managed"
)
if self.subscription_plan_approval == "Manual" or managed_ibmcloud:
try:
return self.get_installed_csv_from_install_plans(
pattern=csv_pattern,
approved_only=managed_ibmcloud,
)
except NoInstallPlanForApproveFoundException:
log.debug(
Expand All @@ -188,12 +193,13 @@ def get_current_csv(self, channel=None, csv_pattern=constants.OCS_CSV_PREFIX):
f"Channel: {channel} not found in available channels: " f"{channel_names}"
)

def get_installed_csv_from_install_plans(self, pattern):
def get_installed_csv_from_install_plans(self, pattern, approved_only=False):
"""
Get currently installed CSV out latest approved install plans.

Args:
patter (str): pattern of CSV name to look for.
approved_only (bool): it will ignore if there is no non approved install plan

Raises:
CSVNotFound: In case no CSV found from approved install plans.
Expand All @@ -203,13 +209,14 @@ def get_installed_csv_from_install_plans(self, pattern):
"""
install_plan = InstallPlan(namespace=self.install_plan_namespace)
install_plans = install_plan.get()["items"]
not_approved_install_plans = [
ip for ip in install_plans if not ip["spec"]["approved"]
]
if not not_approved_install_plans:
raise NoInstallPlanForApproveFoundException(
"No insall plan for approve found!"
)
if not approved_only:
not_approved_install_plans = [
ip for ip in install_plans if not ip["spec"]["approved"]
]
if not not_approved_install_plans:
raise NoInstallPlanForApproveFoundException(
"No insall plan for approve found!"
)
sorted_install_plans = sorted(
install_plans,
key=lambda ip: ip["metadata"]["creationTimestamp"],
Expand Down
Loading