Skip to content

Commit 7394fd5

Browse files
committed
RDR chnages for 4.19
Signed-off-by: vavuthu <[email protected]>
1 parent 41fc835 commit 7394fd5

File tree

4 files changed

+148
-9
lines changed

4 files changed

+148
-9
lines changed

ocs_ci/deployment/deployment.py

+49-9
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,20 @@ 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+
"ocs.openshift.io/api-server-exported-address": (
1703+
f'{config.ENV_DATA["cluster_name"]}.'
1704+
f"ocs-provider-server.openshift-storage.svc.clusterset.local:50051"
1705+
)
1706+
}
1707+
merge_dict(
1708+
cluster_data,
1709+
{"metadata": {"annotations": api_server_exported_address_annotation}},
1710+
)
16941711
if config.ENV_DATA.get("noobaa_external_pgsql"):
16951712
log_step(
16961713
"Creating external pgsql DB for NooBaa and correct StorageCluster data"
@@ -2953,25 +2970,39 @@ def deploy(self):
29532970

29542971
@retry(ResourceWrongStatusException, tries=10, delay=5)
29552972
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-
)
2973+
odf_running_version = version.get_semantic_ocs_version_from_config()
2974+
if odf_running_version >= version.VERSION_4_19:
2975+
cmd = (
2976+
f"oc get cephblockpoolradosnamespaces -n {config.ENV_DATA['cluster_namespace']}"
2977+
" -o=jsonpath='{.items[*].status.phase}'"
2978+
)
2979+
resource_name = constants.CEPHBLOCKPOOLRADOSNS
2980+
expected_state = constants.STATUS_READY
2981+
else:
2982+
st_string = '{.items[?(@.metadata.ownerReferences[*].kind=="StorageCluster")].spec.mirroring.enabled}'
2983+
cmd = (
2984+
f"oc get CephBlockPool -n {config.ENV_DATA['cluster_namespace']}"
2985+
f" -o=jsonpath='{st_string}'"
2986+
)
2987+
resource_name = constants.CEPHBLOCKPOOL
2988+
expected_state = "true"
2989+
29612990
out_list = run_cmd_multicluster(
2962-
query_mirroring, skip_index=get_all_acm_and_recovery_indexes()
2991+
cmd, skip_index=get_all_acm_and_recovery_indexes()
29632992
)
29642993
index = 0
29652994
for out in out_list:
29662995
if not out:
29672996
continue
29682997
logger.info(out.stdout.decode())
2969-
if out.stdout.decode() != "true":
2998+
if out.stdout.decode() != expected_state:
29702999
logger.error(
29713000
f"On cluster {config.clusters[index].ENV_DATA['cluster_name']}"
29723001
)
29733002
raise ResourceWrongStatusException(
2974-
"CephBlockPool", expected="true", got=out.stdout.decode()
3003+
resource_or_name=resource_name,
3004+
expected=expected_state,
3005+
got=out.stdout.decode(),
29753006
)
29763007
index = +1
29773008

@@ -3798,14 +3829,23 @@ def deploy(self):
37983829
# Enable MCO console plugin
37993830
enable_mco_console_plugin()
38003831
config.switch_acm_ctx()
3832+
odf_running_version = version.get_semantic_ocs_version_from_config()
3833+
if odf_running_version >= version.VERSION_4_19:
3834+
# create service exporter
3835+
create_service_exporter()
3836+
38013837
# RBD specific dr deployment
38023838
if self.rbd:
38033839
rbddops = RBDDRDeployOps()
38043840
self.configure_mirror_peer()
38053841
rbddops.deploy()
38063842
self.enable_acm_observability()
3843+
38073844
self.deploy_dr_policy()
3808-
update_volsync_channel()
3845+
if odf_running_version >= version.VERSION_4_19:
3846+
# validate storage cluster peer state
3847+
validate_storage_cluster_peer_state()
3848+
verify_volsync()
38093849

38103850
# Enable cluster backup on both ACMs
38113851
for i in acm_indexes:

ocs_ci/helpers/dr_helpers.py

+88
Original file line numberDiff line numberDiff line change
@@ -2097,3 +2097,91 @@ def wait_for_vrg_state(
20972097
)
20982098
logger.info(error_msg)
20992099
raise TimeoutExpiredError(error_msg)
2100+
2101+
2102+
def validate_storage_cluster_peer_state():
2103+
"""
2104+
Validate Storage cluster peer state
2105+
2106+
Raises:
2107+
TimeoutExpiredError: incase storage cluster peer state is not reached 'Peered' state.
2108+
2109+
"""
2110+
restore_index = config.cur_index
2111+
managed_clusters = get_non_acm_cluster_config()
2112+
for cluster in managed_clusters:
2113+
index = cluster.MULTICLUSTER["multicluster_index"]
2114+
config.switch_ctx(index)
2115+
logger.info("Validating Storage Cluster Peer status")
2116+
sample = TimeoutSampler(
2117+
timeout=300,
2118+
sleep=5,
2119+
func=check_storage_cluster_peer_state(),
2120+
)
2121+
if not sample.wait_for_func_status(result=True):
2122+
error_msg = (
2123+
"Storage cluster peer status does not have expected values within the time "
2124+
f"limit on cluster {cluster.ENV_DATA['cluster_name']}"
2125+
)
2126+
logger.error(error_msg)
2127+
raise TimeoutExpiredError(error_msg)
2128+
config.switch_ctx(restore_index)
2129+
2130+
2131+
def check_storage_cluster_peer_state():
2132+
"""
2133+
Checks Storage cluster peer state
2134+
2135+
Returns:
2136+
bool: True if storage cluster peer state is 'Peered'. otherwise False
2137+
2138+
"""
2139+
storage_cluster_peer = ocp.OCP(
2140+
kind=constants.STORAGECLUSTERPEER,
2141+
namespace=config.ENV_DATA["cluster_namespace"],
2142+
)
2143+
storage_cluster_peer_data = storage_cluster_peer.get()
2144+
storage_cluster_peer_status = storage_cluster_peer_data["spec"]["status"].get(
2145+
"state"
2146+
)
2147+
if storage_cluster_peer_status == constants.STATUS_PEERED:
2148+
return True
2149+
else:
2150+
logger.warning(f"storage cluster peer state is {storage_cluster_peer_status}")
2151+
return False
2152+
2153+
2154+
def create_service_exporter():
2155+
"""
2156+
Create Service exporter
2157+
"""
2158+
restore_index = config.cur_index
2159+
managed_clusters = get_non_acm_cluster_config()
2160+
for cluster in managed_clusters:
2161+
index = cluster.MULTICLUSTER["multicluster_index"]
2162+
config.switch_ctx(index)
2163+
logger.info("Creating Service exporter")
2164+
run_cmd(f"oc create -f {constants.DR_SERVICE_EXPORTER}")
2165+
config.switch_ctx(restore_index)
2166+
2167+
2168+
def verify_volsync():
2169+
"""
2170+
Verify volsync pod is created in volsync-system namespace
2171+
"""
2172+
restore_index = config.cur_index
2173+
managed_clusters = get_non_acm_cluster_config()
2174+
for cluster in managed_clusters:
2175+
index = cluster.MULTICLUSTER["multicluster_index"]
2176+
config.switch_ctx(index)
2177+
logger.info(
2178+
f"Verifying volsync pod in namespace {constants.VOLSYNC_SYSTEM_NAMESPACE}"
2179+
)
2180+
pod = ocp.OCP(kind=constants.POD, namespace=constants.VOLSYNC_SYSTEM_NAMESPACE)
2181+
assert pod.wait_for_resource(
2182+
condition="Running",
2183+
selector=constants.VOLSYNC_LABEL,
2184+
resource_count=1,
2185+
timeout=600,
2186+
)
2187+
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)