-
Notifications
You must be signed in to change notification settings - Fork 170
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
Version details for DR operators #9956
Conversation
config._metadata["OCP DR Hub Operator"] = get_dr_hub_operator_version() | ||
config._metadata[ | ||
"ODF Multicluster Orchestrator" | ||
] = get_odf_multicluster_orchestrator_version() | ||
config._metadata["GitOps Operator"] = get_ocp_gitops_operator_version() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are those both on RDR and MDR setup as well?
If not we will need to have some conditions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the RDR and MDR are the same for versions @sidhant-agrawal correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, GitOps will be present for both
"OCP DR Cluster Operator" | ||
] = get_ocp_dr_cluster_operator_version() | ||
config._metadata["GitOps Operator"] = get_ocp_gitops_operator_version() | ||
config._metadata["VolSync Operator "] = get_volsync_operator_version() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same question about diff between RDR/MDR like above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All operators mentioned in my comment #7904 (comment) are valid for RDR setup.
afaik, MDR doesn't have Submariner operator, rest operators are same.
ocs_ci/utility/utils.py
Outdated
) | ||
for csv in csv_list: | ||
if "advanced-cluster-management" in csv["metadata"]["name"]: | ||
# extract version string | ||
return csv["spec"]["version"] | ||
|
||
|
||
def get_dr_hub_operator_version(namespace="openshift"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we all of those version related functions move to this modul?
https://github.com/red-hat-storage/ocs-ci/blob/master/ocs_ci/utility/version.py
I hope it will also resolve circular dependency so you will not need to have :
rom ocs_ci.ocs.resources.csv import get_csvs_start_with_prefix
in each of those functions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the issue reproduced when import get_csvs_start_with_prefix
function
I moved the new functions to version.py
E ImportError: cannot import name 'get_semantic_version' from partially initialized module 'ocs_ci.utility.version' (most likely due to a circular import) (/home/runner/work/ocs-ci/ocs-ci/ocs_ci/utility/version.py)
https://github.com/red-hat-storage/ocs-ci/actions/runs/9598093695/job/26468573010?pr=9956
@@ -432,6 +441,14 @@ def pytest_configure(config): | |||
check_clusters() | |||
if ocsci_config.RUN.get("cephcluster"): | |||
gather_version_info_for_report(config) | |||
if ocsci_config.MULTICLUSTER["acm_cluster"]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we are just running deployment of OCP - will this try to collect also those details there, then it will probably fail as we don't have yet the deployment done yet?
If there will be any exception it will lead I guess to fail whole pytest as pytest_configure hook is very sensitive for whatever error causing pytest fail with Fatal error IIRC.
So we will need to check this please if it will cause any issue for whole deployment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the get_version function returns None
if the operator does not exist
ocs_ci/utility/utils.py
Outdated
return csv["spec"]["version"] | ||
|
||
|
||
def get_ocp_dr_cluster_operator_version(namespace="openshift"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we will also need to add all of those values to test suite property via: record_testsuite_property
E.g. like we do record markers and other values:
0884315
See other usages of record_testsuite_property in code via git grep record_testsuite_property
please .
As main goal is have those values recorded in email, and report portal and xunit file as well.
record_testsuite_property("rp_ocs_build", get_ocs_build_number())
IIRC whatever we want to have in Report portal we need to prefix with rp_
than our script will remove rp_
prefix and report the attribute without this prefix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
XML examlpe:
|
ocs_ci/utility/version.py
Outdated
@@ -152,3 +153,115 @@ def compare_versions(expression): | |||
) | |||
v1, op, v2 = m.groups() | |||
return eval(f"get_semantic_version(v1, True){op}get_semantic_version(v2, True)") | |||
|
|||
|
|||
def get_dr_hub_operator_version(namespace="openshift"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is "openshift" namespace for DR ? don't make namespace as hardcode since we support multi namespace feature.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is "openshift" namespace for DR ? -> DR operator applies on all namespaces, so I choose "openshift" ns
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you keep ns as constant. All the NS are defined here https://github.com/red-hat-storage/ocs-ci/blob/master/ocs_ci/ocs/constants.py#L251
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
ocs_ci/utility/version.py
Outdated
return csv["spec"]["version"] | ||
|
||
|
||
def get_ocp_dr_cluster_operator_version(namespace="openshift"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is "openshift" namespace for DR ? don't make namespace as hardcode since we support multi namespace feature.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes. "openshift" ns exist on all ocp cluster
ocs_ci/utility/version.py
Outdated
|
||
def get_dr_hub_operator_version(namespace="openshift"): | ||
""" | ||
Get DR Hub Opertaor Version |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Get DR Hub Opertaor Version | |
Get DR Hub Operator Version |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
tests/conftest.py
Outdated
from ocs_ci.utility.version import ( | ||
get_dr_hub_operator_version, | ||
get_ocp_dr_cluster_operator_version, | ||
get_odf_multicluster_orchestrator_version, | ||
get_ocp_gitops_operator_version, | ||
get_submariner_operator_version, | ||
get_volsync_operator_version, | ||
) | ||
from ocs_ci.utility.utils import ( | ||
get_oadp_version, | ||
get_acm_version, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why its imported in the middle of function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
tests/conftest.py
Outdated
get_acm_version, | ||
) | ||
|
||
if ocsci_config.MULTICLUSTER["acm_cluster"]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is "acm_cluster" always loaded into MULTICLUSTER even normal deployment? I suggest to use get()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is configured in default_config.yaml
but I will change it ... https://github.com/red-hat-storage/ocs-ci/blob/master/ocs_ci/framework/conf/default_config.yaml#L347
tests/conftest.py
Outdated
gitops_operator_version = get_ocp_gitops_operator_version() | ||
if gitops_operator_version: | ||
record_testsuite_property("rp_gitops_version", gitops_operator_version) | ||
if ocsci_config.MULTICLUSTER["primary_cluster"]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use get method to avoid unnecessary failures
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
b4c1d49
to
1f60d1e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR validation
Cluster Name:
Cluster Configuration:
PR Test Suite: deployment
PR Test Path: tests/
Additional Test Params:
OCP VERSION: 4.16
OCS VERSION: 4.16
tested against branch: master
ocs_ci/ocs/acm/acm.py
Outdated
class RunWithConfigContext(object): | ||
def __init__(self, config_index): | ||
self.original_config_index = config.cur_index | ||
self.config_index = config_index | ||
|
||
def __enter__(self): | ||
config.switch_ctx(self.config_index) | ||
return self | ||
|
||
def __exit__(self, exc_type, exc_value, exc_traceback): | ||
config.switch_ctx(self.original_config_index) | ||
|
||
|
||
class RunWithAcmConfigContext(RunWithConfigContext): | ||
def __init__(self): | ||
acm_index = get_all_acm_indexes()[0] | ||
super().__init__(acm_index) | ||
|
||
|
||
class RunWithPrimaryConfigContext(RunWithConfigContext): | ||
def __init__(self): | ||
primary_index = get_primary_cluster_config() | ||
super().__init__(primary_index) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would rather see those in config class as those would be reused for other scenarios like provider/client mode.
https://github.com/red-hat-storage/ocs-ci/blob/master/ocs_ci/framework/__init__.py#L25
So user might access those like:
with config.RunWithAcmConfigContext: # or RunWithConfigContext directly or define new ones leveraging the generic one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
ocs_ci/ocs/utils.py
Outdated
bool: return True if it is rdr or mdr setup otherwise False | ||
|
||
""" | ||
for cluster in ocsci_config.clusters: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@OdedViner we don't have to iterate over all the clusters, since scenario would be passed as common conf in run-ci, it should be available in all contexts.
for cluster in ocsci_config.clusters: | |
if cluster.MULTICLUSTER['multicluster_mode'] in ("metro-dr", "regional-dr"): | |
return True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
tests/conftest.py
Outdated
@@ -1592,6 +1603,49 @@ def additional_testsuite_properties(record_testsuite_property, pytestconfig): | |||
# add markers as separated property | |||
markers = ocsci_config.RUN["cli_params"].get("-m", "").replace(" ", "-") | |||
record_testsuite_property("rp_markers", markers) | |||
if is_dr_scenario(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@OdedViner , looks like this block of code is mostly repetition of the block above https://github.com/red-hat-storage/ocs-ci/pull/9956/files#diff-715cca595e4d8f8493e6afe4e6605ebb2b8f91d3cb1be10495f2ec06e3826261R218, is it possible to optimize this ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Signed-off-by: oviner <[email protected]>
8afeb21
to
3106ab2
Compare
Signed-off-by: oviner <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR validation
Cluster Name:
Cluster Configuration:
PR Test Suite: deployment
PR Test Path: tests/
Additional Test Params:
OCP VERSION: 4.16
OCS VERSION: 4.16
tested against branch: master
Tested on MDR job: |
ocs_ci/ocs/resources/ocs.py
Outdated
@@ -205,7 +205,11 @@ def get_version_info(namespace=None): | |||
csv_name = package_manifest.get_current_csv(channel) | |||
csv_pre = CSV(resource_name=csv_name, namespace=namespace) | |||
info = get_images(csv_pre.get()) | |||
return info | |||
from ocs_ci.ocs.utils import get_dr_operator_versions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we move this to import sections
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since you updated this function, could we add doc string as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I got a Circular Import Error when i move to import section.
Added doc string.
ocs_ci/utility/version.py
Outdated
from ocs_ci.ocs.resources.csv import get_csvs_start_with_prefix | ||
|
||
csv_list = get_csvs_start_with_prefix( | ||
"openshift-gitops-operator", namespace=namespace |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"openshift-gitops-operator", namespace=namespace | |
constants.GITOPS_OPERATOR_NAME, namespace=namespace |
ocs_ci/utility/version.py
Outdated
"openshift-gitops-operator", namespace=namespace | ||
) | ||
for csv in csv_list: | ||
if "openshift-gitops-operator" in csv["metadata"]["name"]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if "openshift-gitops-operator" in csv["metadata"]["name"]: | |
if constants.GITOPS_OPERATOR_NAME in csv["metadata"]["name"]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
ocs_ci/ocs/utils.py
Outdated
versions_dic["oadp_version"] = oadp_operator_version | ||
ocp_dr_cluster_operator_version = get_ocp_dr_cluster_operator_version() | ||
if ocp_dr_cluster_operator_version: | ||
versions_dic["ocp_dr_cluster_version"] = ocp_dr_cluster_operator_version |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to dr_hub_version
, we can use dr_cluster_version
instead of ocp_dr_cluster_version
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Signed-off-by: oviner <[email protected]>
Signed-off-by: oviner <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Signed-off-by: oviner <[email protected]>
ocs_ci/utility/version.py
Outdated
return csv["spec"]["version"] | ||
|
||
|
||
def get_ocp_dr_cluster_operator_version(namespace=constants.OPENSHIFT_NAMESPACE): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
similar to get_dr_hub_operator_version
, can change to get_dr_cluster_operator_version
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Signed-off-by: oviner <[email protected]>
ocs_ci/utility/version.py
Outdated
|
||
def get_ocp_dr_cluster_operator_version(namespace=constants.OPENSHIFT_NAMESPACE): | ||
""" | ||
Get DR Hub Operator Version |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Get DR Hub Operator Version | |
Get DR Cluster Operator Version |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Signed-off-by: oviner <[email protected]>
New changes are detected. LGTM label has been removed. |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: OdedViner, petr-balogh, sidhant-agrawal The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
* Version details for all DR components Signed-off-by: oviner <[email protected]>
#7904