Skip to content

Commit 1cac584

Browse files
committed
RDR chnages for 4.19
Signed-off-by: vavuthu <[email protected]>
1 parent 59c9b2f commit 1cac584

File tree

4 files changed

+146
-8
lines changed

4 files changed

+146
-8
lines changed

ocs_ci/deployment/deployment.py

+47-8
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@
4646
from ocs_ci.framework.logger_helper import log_step
4747
from ocs_ci.helpers.dr_helpers import (
4848
configure_drcluster_for_fencing,
49+
create_service_exporter,
50+
validate_storage_cluster_peer_state,
51+
verify_volsync,
4952
)
5053
from ocs_ci.ocs import constants, ocp, defaults, registry
5154
from ocs_ci.ocs.cluster import (
@@ -1691,6 +1694,18 @@ def deploy_ocs_via_operator(self, image=None):
16911694
merge_dict(
16921695
cluster_data, {"metadata": {"annotations": rdr_bluestore_annotation}}
16931696
)
1697+
if (
1698+
version.get_semantic_ocs_version_from_config() >= version.VERSION_4_19
1699+
and config.MULTICLUSTER.get("multicluster_mode") == "regional-dr"
1700+
):
1701+
api_server_exported_address_annotation = (
1702+
f'{config.ENV_DATA["cluster_name"]}.'
1703+
f"ocs-provider-server.openshift-storage.svc.clusterset.local:50051"
1704+
)
1705+
merge_dict(
1706+
cluster_data,
1707+
{"metadata": {"annotations": api_server_exported_address_annotation}},
1708+
)
16941709
if config.ENV_DATA.get("noobaa_external_pgsql"):
16951710
log_step(
16961711
"Creating external pgsql DB for NooBaa and correct StorageCluster data"
@@ -2953,25 +2968,39 @@ def deploy(self):
29532968

29542969
@retry(ResourceWrongStatusException, tries=10, delay=5)
29552970
def configure_rbd(self):
2956-
st_string = '{.items[?(@.metadata.ownerReferences[*].kind=="StorageCluster")].spec.mirroring.enabled}'
2957-
query_mirroring = (
2958-
f"oc get CephBlockPool -n {config.ENV_DATA['cluster_namespace']}"
2959-
f" -o=jsonpath='{st_string}'"
2960-
)
2971+
odf_running_version = version.get_ocs_version_from_csv(only_major_minor=True)
2972+
if odf_running_version >= version.VERSION_4_19:
2973+
cmd = (
2974+
"oc get cephblockpoolradosnamespaces -n {config.ENV_DATA['cluster_namespace']}"
2975+
" -o=jsonpath='{.items[*].status.phase}'"
2976+
)
2977+
resource_name = constants.CEPHBLOCKPOOLRADOSNS
2978+
expected_state = constants.STATUS_READY
2979+
else:
2980+
st_string = '{.items[?(@.metadata.ownerReferences[*].kind=="StorageCluster")].spec.mirroring.enabled}'
2981+
cmd = (
2982+
f"oc get CephBlockPool -n {config.ENV_DATA['cluster_namespace']}"
2983+
f" -o=jsonpath='{st_string}'"
2984+
)
2985+
resource_name = constants.CEPHBLOCKPOOL
2986+
expected_state = "true"
2987+
29612988
out_list = run_cmd_multicluster(
2962-
query_mirroring, skip_index=get_all_acm_and_recovery_indexes()
2989+
cmd, skip_index=get_all_acm_and_recovery_indexes()
29632990
)
29642991
index = 0
29652992
for out in out_list:
29662993
if not out:
29672994
continue
29682995
logger.info(out.stdout.decode())
2969-
if out.stdout.decode() != "true":
2996+
if out.stdout.decode() != expected_state:
29702997
logger.error(
29712998
f"On cluster {config.clusters[index].ENV_DATA['cluster_name']}"
29722999
)
29733000
raise ResourceWrongStatusException(
2974-
"CephBlockPool", expected="true", got=out.stdout.decode()
3001+
resource_or_name=resource_name,
3002+
expected=expected_state,
3003+
got=out.stdout.decode(),
29753004
)
29763005
index = +1
29773006

@@ -3798,13 +3827,23 @@ def deploy(self):
37983827
# Enable MCO console plugin
37993828
enable_mco_console_plugin()
38003829
config.switch_acm_ctx()
3830+
odf_running_version = version.get_ocs_version_from_csv(only_major_minor=True)
3831+
if odf_running_version >= version.VERSION_4_19:
3832+
# create service exporter
3833+
create_service_exporter()
3834+
38013835
# RBD specific dr deployment
38023836
if self.rbd:
38033837
rbddops = RBDDRDeployOps()
38043838
self.configure_mirror_peer()
38053839
rbddops.deploy()
38063840
self.enable_acm_observability()
3841+
38073842
self.deploy_dr_policy()
3843+
if odf_running_version >= version.VERSION_4_19:
3844+
# validate storage cluster peer state
3845+
validate_storage_cluster_peer_state()
3846+
verify_volsync()
38083847
update_volsync_channel()
38093848

38103849
# Enable cluster backup on both ACMs

ocs_ci/helpers/dr_helpers.py

+88
Original file line numberDiff line numberDiff line change
@@ -1973,3 +1973,91 @@ def configure_rdr_hub_recovery():
19731973
)
19741974
logger.info("All pre-reqs verified for performing hub recovery")
19751975
return True
1976+
1977+
1978+
def validate_storage_cluster_peer_state():
1979+
"""
1980+
Validate Storage cluster peer state
1981+
1982+
Raises:
1983+
TimeoutExpiredError: incase storage cluster peer state is not reached 'Peered' state.
1984+
1985+
"""
1986+
restore_index = config.cur_index
1987+
managed_clusters = get_non_acm_cluster_config()
1988+
for cluster in managed_clusters:
1989+
index = cluster.MULTICLUSTER["multicluster_index"]
1990+
config.switch_ctx(index)
1991+
logger.info("Validating Storage Cluster Peer status")
1992+
sample = TimeoutSampler(
1993+
timeout=300,
1994+
sleep=5,
1995+
func=check_storage_cluster_peer_state(),
1996+
)
1997+
if not sample.wait_for_func_status(result=True):
1998+
error_msg = (
1999+
"Storage cluster peer status does not have expected values within the time "
2000+
f"limit on cluster {cluster.ENV_DATA['cluster_name']}"
2001+
)
2002+
logger.error(error_msg)
2003+
raise TimeoutExpiredError(error_msg)
2004+
config.switch_ctx(restore_index)
2005+
2006+
2007+
def check_storage_cluster_peer_state():
2008+
"""
2009+
Checks Storage cluster peer state
2010+
2011+
Returns:
2012+
bool: True if storage cluster peer state is 'Peered'. otherwise False
2013+
2014+
"""
2015+
storage_cluster_peer = ocp.OCP(
2016+
kind=constants.STORAGECLUSTERPEER,
2017+
namespace=config.ENV_DATA["cluster_namespace"],
2018+
)
2019+
storage_cluster_peer_data = storage_cluster_peer.get()
2020+
storage_cluster_peer_status = storage_cluster_peer_data["spec"]["status"].get(
2021+
"state"
2022+
)
2023+
if storage_cluster_peer_status == constants.STATUS_PEERED:
2024+
return True
2025+
else:
2026+
logger.warning(f"storage cluster peer state is {storage_cluster_peer_status}")
2027+
return False
2028+
2029+
2030+
def create_service_exporter():
2031+
"""
2032+
Create Service exporter
2033+
"""
2034+
restore_index = config.cur_index
2035+
managed_clusters = get_non_acm_cluster_config()
2036+
for cluster in managed_clusters:
2037+
index = cluster.MULTICLUSTER["multicluster_index"]
2038+
config.switch_ctx(index)
2039+
logger.info("Creating Service exporter")
2040+
run_cmd(f"oc create -f {constants.DR_SERVICE_EXPORTER}")
2041+
config.switch_ctx(restore_index)
2042+
2043+
2044+
def verify_volsync():
2045+
"""
2046+
Verify volsync pod is created in volsync-system namespace
2047+
"""
2048+
restore_index = config.cur_index
2049+
managed_clusters = get_non_acm_cluster_config()
2050+
for cluster in managed_clusters:
2051+
index = cluster.MULTICLUSTER["multicluster_index"]
2052+
config.switch_ctx(index)
2053+
logger.info(
2054+
f"Verifying volsync pod in namespace {constants.VOLSYNC_SYSTEM_NAMESPACE}"
2055+
)
2056+
pod = ocp.OCP(kind=constants.POD, namespace=constants.VOLSYNC_SYSTEM_NAMESPACE)
2057+
assert pod.wait_for_resource(
2058+
condition="Running",
2059+
selector=constants.VOLSYNC_LABEL,
2060+
resource_count=1,
2061+
timeout=600,
2062+
)
2063+
config.switch_ctx(restore_index)

ocs_ci/ocs/constants.py

+5
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@
114114
STATUS_READY = "Ready"
115115
STATUS_PROGRESSING = "Progressing"
116116
PEER_READY = "Peer ready"
117+
STATUS_PEERED = "Peered"
117118
STATUS_PENDING = "Pending"
118119
STATUS_CONTAINER_CREATING = "ContainerCreating"
119120
STATUS_AVAILABLE = "Available"
@@ -174,6 +175,7 @@
174175
STORAGECLASS = "StorageClass"
175176
DEVICECLASS = "deviceClass"
176177
STORAGESYSTEM = "StorageSystem"
178+
STORAGECLUSTERPEER = "StorageClusterPeer"
177179
PV = "PersistentVolume"
178180
PVC = "PersistentVolumeClaim"
179181
POD = "Pod"
@@ -293,6 +295,7 @@
293295
TEST_FILES_BUCKET = "ocsci-test-files"
294296
ROOK_REPOSITORY = "https://github.com/rook/rook.git"
295297
OPENSHIFT_STORAGE_NAMESPACE = "openshift-storage"
298+
VOLSYNC_SYSTEM_NAMESPACE = "volsync-system"
296299
OPENSHIFT_NAMESPACE = "openshift"
297300
OPENSHIFT_STORAGE_CLIENT_NAMESPACE = "openshift-storage-client"
298301
OPENSHIFT_STORAGE_EXTENDED_NAMESPACE = "openshift-storage-extended"
@@ -660,6 +663,7 @@
660663
NOOBAA_CNPG_POD_LABEL = "app.kubernetes.io/name=cloudnative-pg"
661664
ROOK_CEPH_DETECT_VERSION_LABEL = "app=rook-ceph-detect-version"
662665
CEPH_FILE_CONTROLLER_DETECT_VERSION_LABEL = "app=ceph-file-controller-detect-version"
666+
VOLSYNC_LABEL = "app.kubernetes.io/name=volsync"
663667
CONTROLLER_DETECT_VERSION_NAME = "controller-detect-version"
664668
OSD_KEY_ROTATION_POD_NAME = "rook-ceph-osd-key-rotation"
665669
ROOK_CEPH_DETECT_VERSION_POD_NAME = "rook-ceph-detect-version"
@@ -1283,6 +1287,7 @@
12831287
TEMPLATE_MULTICLUSTER_DIR, "openshift_dr_system_operatorgroup.yaml"
12841288
)
12851289
ACM_DPA = os.path.join(TEMPLATE_MULTICLUSTER_DIR, "dpa_acm.yaml")
1290+
DR_SERVICE_EXPORTER = os.path.join(TEMPLATE_MULTICLUSTER_DIR, "service_exporter.yaml")
12861291
DR_POLICY_ACM_HUB = os.path.join(TEMPLATE_MULTICLUSTER_DIR, "dr_policy_acm_hub.yaml")
12871292
ODR_S3_SECRET_YAML = os.path.join(TEMPLATE_MULTICLUSTER_DIR, "odr_s3_secret.yaml")
12881293
OPENSHIFT_DR_SYSTEM_NAMESPACE = "openshift-dr-system"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
apiVersion: multicluster.x-k8s.io/v1alpha1
3+
kind: ServiceExport
4+
metadata:
5+
name: ocs-provider-server
6+
namespace: openshift-storage

0 commit comments

Comments
 (0)