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

Added mce.py file for mce installation related methods #11038

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

amr1ta
Copy link
Contributor

@amr1ta amr1ta commented Dec 11, 2024

Added mce.py file for mce installation related methods and created libtest to check mce installation and hcp cluster creation without acm operator

@amr1ta amr1ta added the provider-client Provider-client solution label Dec 11, 2024
@amr1ta amr1ta requested a review from a team as a code owner December 11, 2024 15:09
@pull-request-size pull-request-size bot added the size/L PR that changes 100-499 lines label Dec 11, 2024
Copy link

openshift-ci bot commented Dec 11, 2024

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: amr1ta

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@@ -477,6 +488,8 @@ def deploy_dependencies(
self.deploy_lb()
if download_hcp_binary:
self.update_hcp_binary()
if deploy_mce:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should probably check, if deploy_acm_hub: True, leaving ACM as a general option

Suggested change
if deploy_mce:
if deploy_mce and not deploy_acm_hub:

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in latest commit.

Creates a catalogsource for mce operator.

"""
logger.info("Adding CatalogSource for MCE")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need to check if MCE catalogSource is not already installed. This way we insure, the Deployment can be rerun again from any installation stage.
In opposite if we do not do this check, job will abort with error

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in latest commit.

Raises:
CommandFailed: If the 'oc create' command fails.
"""
try:
Copy link
Contributor

@DanielOsypenko DanielOsypenko Dec 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is better to check if resource exist than using try-except, to not pollute logs with false-errors

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in latest commit.

"""
operatorgroup_yaml_file = templating.load_yaml(constants.MCE_OPERATOR_YAM)
operatorgroup_yaml = OCS(**operatorgroup_yaml_file)
try:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is better to check if resource exist than using try-except, to not pollute logs with false-errors

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in latest commit.

mce_subscription_yaml_data, mce_subscription_manifest.name
)
logger.info("Creating subscription for mce operator")
run_cmd(f"oc create -f {mce_subscription_manifest.name}")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please check if subscription exists in the beginning of the method; if exists skip execution of the method

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in latest commit.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Amrita. In case if subscription exists we will need to return True or something but not execute creation of the subscription second time.
I see you checked it here, but there is no else in this block, so it will be executed in any way

 if not self.subs.is_exist(resource_name=constants.MCE_OPERATOR):
            mce_subscription_yaml_data = templating.load_yaml(
                constants.MCE_SUBSCRIPTION_YAML
            )

"-n {self.namespace}"
)
cmd_res = exec_cmd(cmd, shell=True)
assert cmd_res.returncode == 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

overall it its better not use assert in deployments, but in tests. This way we'll have errors in log showing that deployment failed, instead of assertion signaling about a product bug

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in latest commit.

"]}}}' --type=merge"
)
cmd_res = exec_cmd(cmd, shell=True)
assert cmd_res.returncode == 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above, assertion on this would not mean Product bug;
we have module with ocs-ci exceptions ocs_ci.ocs.exceptions, please use existing or add another with description

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in latest commit.

namespace=constants.HYPERSHIFT_NAMESPACE,
)

assert configmaps_obj.is_exist(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we have module with ocs-ci exceptions ocs_ci.ocs.exceptions, please use existing or add another with description instead of using assert

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in latest commit.

@@ -386,6 +390,7 @@ def deploy_ocp(
deploy_acm_hub=True,
deploy_metallb=True,
download_hcp_binary=True,
deploy_mce=True,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we will need introduce this new parameter in configurations and .md file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in latest commit.

@amr1ta amr1ta force-pushed the create-hcp-cluster-without-acm branch 2 times, most recently from a42dd98 to d372a22 Compare December 12, 2024 14:37
amr1ta added 5 commits January 6, 2025 13:15
…btest to check mce installation and hcp cluster creation without acm operator

Signed-off-by: Amrita Mahapatra <[email protected]>
Signed-off-by: Amrita Mahapatra <[email protected]>
@amr1ta amr1ta force-pushed the create-hcp-cluster-without-acm branch from c26ce41 to c57871e Compare January 6, 2025 08:24
amr1ta added 5 commits January 6, 2025 14:56
Signed-off-by: Amrita Mahapatra <[email protected]>
Signed-off-by: Amrita Mahapatra <[email protected]>
Signed-off-by: Amrita Mahapatra <[email protected]>
Signed-off-by: Amrita Mahapatra <[email protected]>
Signed-off-by: Amrita Mahapatra <[email protected]>
@amr1ta amr1ta force-pushed the create-hcp-cluster-without-acm branch from 19c4efe to e68de9c Compare January 7, 2025 12:27
Signed-off-by: Amrita Mahapatra <[email protected]>
@amr1ta amr1ta force-pushed the create-hcp-cluster-without-acm branch from e68de9c to 2250b23 Compare January 8, 2025 05:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
provider-client Provider-client solution size/L PR that changes 100-499 lines
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants