-
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
WIP: Create Cluster via ACM #8935
base: master
Are you sure you want to change the base?
WIP: Create Cluster via ACM #8935
Conversation
OdedViner
commented
Nov 26, 2023
•
edited
Loading
edited
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: OdedViner 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 |
|
||
|
||
@purple_squad | ||
@acm_import |
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.
Suppose to be acm_install and not import.
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
@@ -334,3 +334,18 @@ MULTICLUSTER: | |||
acm_cluster: False | |||
primary_cluster: False | |||
active_acm_cluster: False | |||
|
|||
ACM_CONFIG: | |||
ocp_image: "img4.14.3-multi-appsub" |
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 there an option to use 4.15? As master is default to 4.15.
Also I would move this option to OCP version config file.
Please document all of this values and section in the config/README.md
memoryMB: 65536 | ||
diskSizeGB: 120 | ||
replicas: 3 | ||
cluster_name: "cluster-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.
Should not be defined here but rather used from ENV_DATA["cluster_name"]
cpus: 16 | ||
coresPerSocket: 2 | ||
memoryMB: 65536 | ||
diskSizeGB: 120 | ||
replicas: 3 |
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.
This we already have in env_data section, we should not duplicate it here but rather use what we already have at's it's a per cluster configuration which will be loaded per cluster.
If you need extra different configuration for cluster being deployed via ACM I suggest to create extra config file for it which will be loaded for that specific cluster index . E.g. conf/deployment/vsphere/acm_1az_rhcos_vsan_3m_3w.yaml
You can also add flag in this config file like:
ENV_DATA:
amc_deployed: true
all_other_values like (worker_replicas, worker_num_cpus) # Follow same naming convention like we do in other vsphere config files: https://github.com/red-hat-storage/ocs-ci/blob/master/conf/deployment/vsphere/upi_1az_rhcos_vsan_3m_3w.yaml
Maybe you don't even need new ACM_CONFIG but you can just use ENV_DATA.
We should not put those values in default config but move to one specific mentioned above for this kind of deployment via ACM over vsphere for example.
ocs_ci/ocs/acm/acm.py
Outdated
@@ -41,6 +44,11 @@ | |||
from ocs_ci.ocs.resources.ocs import OCS | |||
from ocs_ci.helpers.helpers import create_project | |||
|
|||
# from ocs_ci.utility.retry import retry |
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.
Leftovers?
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
ocs_ci/ocs/acm/acm.py
Outdated
with open(constants.VSPHERE_CA_FILE_PATH, "r") as fp: | ||
self.vsphere_ca = fp.read() | ||
|
||
with open("/home/oviner/OCS-AP/ocs-ci/data/pull-secret", "r") as fp: |
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.
Don't forgot to read it from the framework constants/ defaults or config or where we have it defined.
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/acm/acm.py
Outdated
logging.info(f"Tmp file name: {manifest.name}") | ||
templating.dump_data_to_temp_yaml(data, manifest.name) | ||
self.file_paths.append(manifest.name) | ||
# run_cmd(f"oc apply -f {manifest.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.
I would store those manifests file under cluster_path/manifests/manifest-tmpX.yaml e.g. .
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.
@dahorak how to get access to the relevant path?
ocs_ci/ocs/acm/acm.py
Outdated
] = f"{self.cluster_name}-ssh-private-key" | ||
cluster_deployment["spec"]["provisioning"]["imageSetRef"][ | ||
"name" | ||
] = "img4.14.3-multi-appsub" |
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.
From config value
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/acm/acm.py
Outdated
ocp_obj = OCP(kind=constants.ACM_MANAGEDCLUSTER) | ||
ocp_obj.wait_for_resource( | ||
timeout=10, | ||
condition="True", | ||
column="AVAILABLE", | ||
resource_name=self.cluster_name, | ||
) | ||
ocp_obj.wait_for_resource( | ||
timeout=10, | ||
condition="True", | ||
column="JOINED", | ||
resource_name=self.cluster_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.
I suggest you to use the context manage (in python using with block) to make sure the context for this block of the code is running on the ACM hub.
In this context manager you need to do:
- Sore current config context - as you will need to return back to original config context after you finish this block of code
- Switch to ACM hub config object
- Do operations defined within with block
- Switch config context back to original stale - even though the code in the block will fail.
ocp_obj = OCP(kind=constants.ACM_MANAGEDCLUSTER) | |
ocp_obj.wait_for_resource( | |
timeout=10, | |
condition="True", | |
column="AVAILABLE", | |
resource_name=self.cluster_name, | |
) | |
ocp_obj.wait_for_resource( | |
timeout=10, | |
condition="True", | |
column="JOINED", | |
resource_name=self.cluster_name, | |
) | |
with acmHubContext(): | |
ocp_obj = OCP(kind=constants.ACM_MANAGEDCLUSTER) | |
ocp_obj.wait_for_resource( | |
timeout=10, | |
condition="True", | |
column="AVAILABLE", | |
resource_name=self.cluster_name, | |
) | |
ocp_obj.wait_for_resource( | |
timeout=10, | |
condition="True", | |
column="JOINED", | |
resource_name=self.cluster_name, | |
) |
Define context manager, see doc here: https://book.pythontips.com/en/latest/context_managers.html#implementing-a-context-manager-as-a-class
The same you will use the same in create cluster via acm as you need to run also from acm context.
I think we can have generic context manager like:
class RunWithConfigContext(object):
def __init__(self, config_index):
self.original_config_index = config.current_index
self.config_index = config_index
def __enter__(self):
config.switch_context(self.config_index)
def __exit__(self, type, value, traceback):
config.switch_context(self.original_config_index)
than you can have the specific one which will reuse the above but will make sure it will find the acm_hub_config_index for you.
class RunWithAcmConfigContext(RunWithConfigContext):
def __init__(self):
config_index = findAcmContext() # you will need to make sure here to automatically get the index for acm hub cluster
super(RunWithAcmConfigContext, self).__init__(config_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 created one class RunWithConfigContext
class RunWithConfigContext(object):
def __init__(self):
self.original_config_index = config.cur_index
self.acm_index = get_all_acm_indexes()[0]
def __enter__(self):
config.switch_ctx(self.acm_index)
return self
def __exit__(self, exc_type, exc_value, exc_traceback):
config.switch_ctx(self.original_config_index)
what do you think?
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
b162b0f
to
d6322b4
Compare
d6322b4
to
0afd2b2
Compare
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 30 days if no further activity occurs. |
Signed-off-by: oviner <[email protected]>
Signed-off-by: oviner <[email protected]>
1a8d546
to
4e822ab
Compare
Signed-off-by: oviner <[email protected]>
PR needs rebase. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 30 days if no further activity occurs. |