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

Set cluster_kubeconfig based on the type of resource available in provider cluster only #10172

Merged
merged 1 commit into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
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
37 changes: 37 additions & 0 deletions ocs_ci/ocs/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,43 @@
PROVIDER_CLIENT_DEPLOYMENT_DIR, "native_storage_client.yaml"
)

PROVIDER_CLUSTER_RESOURCE_KINDS = [
"cephblockpoolradosnamespaces",
"cephblockpoolradosnamespace",
"cephblockpools",
"cephblockpool",
"cephclients",
"cephclient",
"cephclusters",
"cephcluster",
"cephfilesystems",
"cephfilesystem",
"cephfilesystemsubvolumegroups",
"cephfilesystemsubvolumegroup",
"cephobjectstores",
"cephobjectstore",
"cephobjectstoreusers",
"cephobjectstoreuser",
"localvolumediscoveries",
"localvolumediscovery",
"localvolumediscoveryresults",
"localvolumediscoveryresult",
"localvolumes",
"localvolume",
"localvolumesets",
"localvolumeset",
"storageclusters",
"storagecluster",
"storageconsumers",
"storageconsumer",
"storageprofiles",
"storageprofile",
"storagerequests",
"storagerequest",
"storagesystems",
"storagesystem",
]

OCS_CLIENT_OPERATOR_CONTROLLER_MANAGER_PREFIX = "ocs-client-operator-controller-manager"
OCS_CLIENT_OPERATOR_CONSOLE = "ocs-client-operator-console"
STORAGE_CLIENT_NAME = "storage-client"
Expand Down
25 changes: 24 additions & 1 deletion ocs_ci/ocs/ocp.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,33 @@ def __init__(
self._data = {}
self.selector = selector
self.field_selector = field_selector
self.cluster_kubeconfig = cluster_kubeconfig
# In provider mode multicluster run, certain kind of resources are available in the provider cluster only.
# Setting cluster_kubeconfig of provider cluster in such cases will enable running "oc" commands seamlessly even
# when dealing with two instances of this class simultaneously despite the cluster context. This is achievable
# because all the methods use "exec_oc_cmd" method to run "oc" commmands. Primary cluster context being a
# client cluster, the test cases need not switch context to provider cluster before initializing a resource of
# the kinds listed in constants.PROVIDER_CLUSTER_RESOURCE_KINDS
if (
(not cluster_kubeconfig)
and config.multicluster
and config.ENV_DATA.get("odf_provider_mode_deployment", False)
and kind.lower() in constants.PROVIDER_CLUSTER_RESOURCE_KINDS
):
provider_cluster_index = config.get_provider_index()
provider_kubeconfig_path = os.path.join(
config.clusters[provider_cluster_index].ENV_DATA["cluster_path"],
config.clusters[provider_cluster_index].RUN.get("kubeconfig_location"),
)
self.cluster_kubeconfig = provider_kubeconfig_path
# TODO : self.cluster_context = provider_cluster_index, remove cluster_kubeconfig check in if condition
else:
self.cluster_kubeconfig = cluster_kubeconfig
self.threading_lock = threading_lock
self.silent = silent
self.skip_tls_verify = skip_tls_verify
# TODO: Set cluster_context based on the conditions of setting cluster_kubeconfig. Currently, setting
# cluster_context expects the current context to be the cluster where the resource is present.
# This cannot deal with simultaneous usage of two instances in two different clusters.
self.cluster_context = config.cluster_ctx.MULTICLUSTER.get("multicluster_index")

@property
Expand Down
Loading