Skip to content

Commit

Permalink
Address first review comments
Browse files Browse the repository at this point in the history
Signed-off-by: Sagi Hirshfeld <[email protected]>
  • Loading branch information
sagihirshfeld committed Jan 16, 2025
1 parent a41dd5e commit 532cf16
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
1 change: 1 addition & 0 deletions ocs_ci/ocs/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,7 @@

# AMQ
AMQ_NAMESPACE = "myproject"
KAFKA_ENDPOINT = f"my-cluster-kafka-bootstrap.{AMQ_NAMESPACE}.svc.cluster.local:9092"
KAFKA_OPERATOR = "https://github.com/strimzi/strimzi-kafka-operator"
RGW_KAFKA_NOTIFY = "https://github.com/shonpaz123/notify/"
OCS_WORKLOADS = "https://github.com/red-hat-storage/ocs-workloads"
Expand Down
18 changes: 8 additions & 10 deletions ocs_ci/ocs/resources/bucket_notifications_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import logging
import os
import tempfile
import time
from time import sleep

from ocs_ci.framework import config
from ocs_ci.helpers.helpers import (
Expand All @@ -17,7 +17,7 @@
from ocs_ci.ocs.ocp import OCP
from ocs_ci.ocs.resources.pod import (
Pod,
get_noobaa_endpoint_pods,
get_noobaa_pods,
get_pods_having_label,
wait_for_pods_to_be_running,
)
Expand Down Expand Up @@ -81,10 +81,9 @@ def enable_bucket_notifs_on_cr(self, use_provided_pvc=False):
)
)
elif use_provided_pvc and self.pvc_factory:
clstr_proj_obj = OCP(namespace=self.namespace)
provided_notifs_pvc = self.pvc_factory(
interface=constants.CEPHFILESYSTEM,
project=clstr_proj_obj,
project=OCP(namespace=self.namespace),
size=20,
access_mode=constants.ACCESS_MODE_RWX,
).name
Expand Down Expand Up @@ -207,14 +206,14 @@ def create_kafka_conn_secret(self, topic):
conn_file_name = ""

kafka_conn_config = {
"metadata.broker.list": "my-cluster-kafka-bootstrap.myproject.svc.cluster.local:9092",
"metadata.broker.list": constants.KAFKA_ENDPOINT,
"notification_protocol": "kafka",
"topic": topic,
"name": conn_name,
}

with tempfile.NamedTemporaryFile(
mode="w+", prefix="kafka_conn_", suffix=".json", delete=True
mode="w+", prefix="kafka_conn_", suffix=".json"
) as conn_file:
conn_file_name = os.path.basename(conn_file.name)
conn_file.write(json.dumps(kafka_conn_config))
Expand Down Expand Up @@ -244,16 +243,15 @@ def add_notif_conn_to_noobaa_cr(self, secret):
"name": secret.resource_name,
"namespace": secret.namespace,
}
patch_path = "/spec/bucketNotifications/connections"
patch_path = os.path.join(NOTIFS_YAML_PATH_NB_CR, "connections")
add_op = [{"op": "add", "path": f"{patch_path}/-", "value": conn_data}]
self.nb_config_resource.patch(
resource_name=constants.NOOBAA_RESOURCE_NAME,
params=json.dumps(add_op),
format_type="json",
)

nb_pods = [pod.name for pod in get_noobaa_endpoint_pods()]
nb_pods += [constants.NOOBAA_CORE_POD]
nb_pods = [pod.name for pod in get_noobaa_pods()]
wait_for_pods_to_be_running(
namespace=self.namespace,
pod_names=nb_pods,
Expand Down Expand Up @@ -292,7 +290,7 @@ def put_bucket_notification(self, awscli_pod, mcg_obj, bucket, events, conn_file
)
)
logger.info("Waiting for put-bucket-notification to propogate")
time.sleep(60)
sleep(60)

def get_bucket_notification(self, awscli_pod, mcg_obj, bucket):
"""
Expand Down

0 comments on commit 532cf16

Please sign in to comment.