From e2220d3a9164f8065846705869784d62c17878a1 Mon Sep 17 00:00:00 2001 From: amirhalfon1 Date: Sun, 3 Mar 2024 18:10:59 +0200 Subject: [PATCH 1/3] FOUN-1370: add kafka event notification for roomEntry changes add kafka event notification for roomEntry changes raise event also if it doesn't require any permission --- .../2024_03_03_deploy_kafka_room_events.php | 17 +++++++ ...afka_room_entry_notifications.template.xml | 51 +++++++++++++++++++ .../lib/model/KafkaNotificationTemplate.php | 2 +- release-notes.md | 12 +++++ 4 files changed, 81 insertions(+), 1 deletion(-) create mode 100644 deployment/updates/scripts/2024_03_03_deploy_kafka_room_events.php create mode 100644 deployment/updates/scripts/xml/notifications/2024_03_03_add_kafka_room_entry_notifications.template.xml diff --git a/deployment/updates/scripts/2024_03_03_deploy_kafka_room_events.php b/deployment/updates/scripts/2024_03_03_deploy_kafka_room_events.php new file mode 100644 index 00000000000..a3aa6c8534d --- /dev/null +++ b/deployment/updates/scripts/2024_03_03_deploy_kafka_room_events.php @@ -0,0 +1,17 @@ + + + + @SERVICE_URL@ + -2 + Stand alone php 1.0.0 + 30 + Stand alone php 1.0.0 + + + -2 + @ADMIN_CONSOLE_PARTNER_ADMIN_SECRET@ + 2 + + + + + + + + diff --git a/plugins/event_notification/providers/kafka/lib/model/KafkaNotificationTemplate.php b/plugins/event_notification/providers/kafka/lib/model/KafkaNotificationTemplate.php index 30036cb9bc0..6aaf5f2a3a0 100644 --- a/plugins/event_notification/providers/kafka/lib/model/KafkaNotificationTemplate.php +++ b/plugins/event_notification/providers/kafka/lib/model/KafkaNotificationTemplate.php @@ -114,7 +114,7 @@ public function dispatch(kScope $scope) } $requiredPermissions = explode(",", $this->getRequiresPermissions()); - if(count($requiredPermissions)) + if(count(array_filter($requiredPermissions))) { KalturaLog::debug("Checking if partner has permissions required to dispatch [{$this->getRequiresPermissions()}]"); $found = false; diff --git a/release-notes.md b/release-notes.md index 1e09e96b6da..06ea31d7047 100644 --- a/release-notes.md +++ b/release-notes.md @@ -1,3 +1,15 @@ +# Tucana-20.7.0 +## Add kafka event notification for room entry updates ## +- Issue Type: Task +- Issue ID: FOUN-1370 + +### Configuration ### + Replace all tokens (SERVICE_URL, ADMIN_CONSOLE_PARTNER_ADMIN_SECRET, TOPIC_NAME) from the template XML file below and remove ".template" from the file name: + /opt/kaltura/app/deployment/updates/scripts/xml/notifications/2024_03_03_add_kafka_room_entry_notifications.template.xml + +### Deployment scripts ### + php /opt/kaltura/app/deployment/updates/scripts/2024_03_03_deploy_kafka_room_events.php + # Tucana-20.6.0 ## Add partner and permissions for media repurposing ## - Issue Type: Task From 1571e7ea3f2f6005cbc7fc3a16381d5c02e67494 Mon Sep 17 00:00:00 2001 From: amirhalfon1 Date: Tue, 5 Mar 2024 14:30:59 +0200 Subject: [PATCH 2/3] code review changes: remove un-needed print_r change "@TOPIC_NAME@" to "entry" remove "template" from filename in script use "strlen" for "array_filter" instead of default filter callback --- .../updates/scripts/2024_03_03_deploy_kafka_room_events.php | 3 +-- .../2024_03_03_add_kafka_room_entry_notifications.template.xml | 2 +- .../providers/kafka/lib/model/KafkaNotificationTemplate.php | 2 +- release-notes.md | 2 +- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/deployment/updates/scripts/2024_03_03_deploy_kafka_room_events.php b/deployment/updates/scripts/2024_03_03_deploy_kafka_room_events.php index a3aa6c8534d..5349bed027f 100644 --- a/deployment/updates/scripts/2024_03_03_deploy_kafka_room_events.php +++ b/deployment/updates/scripts/2024_03_03_deploy_kafka_room_events.php @@ -5,9 +5,8 @@ require_once (__DIR__ . '/../../bootstrap.php'); $script = realpath(dirname(__FILE__) . "/../../../tests/standAloneClient/exec.php"); -$newTemplateUpdate = realpath(dirname(__FILE__) . "/../../updates/scripts/xml/notifications/2024_03_03_add_kafka_room_entry_notifications.template.xml"); +$newTemplateUpdate = realpath(dirname(__FILE__) . "/../../updates/scripts/xml/notifications/2024_03_03_add_kafka_room_entry_notifications.xml"); -print_r($newTemplateUpdate); if(!file_exists($newTemplateUpdate) || !file_exists($script)) { KalturaLog::err("Missing update script file"); diff --git a/deployment/updates/scripts/xml/notifications/2024_03_03_add_kafka_room_entry_notifications.template.xml b/deployment/updates/scripts/xml/notifications/2024_03_03_add_kafka_room_entry_notifications.template.xml index c84cd9515c9..82fb464df4a 100644 --- a/deployment/updates/scripts/xml/notifications/2024_03_03_add_kafka_room_entry_notifications.template.xml +++ b/deployment/updates/scripts/xml/notifications/2024_03_03_add_kafka_room_entry_notifications.template.xml @@ -24,7 +24,7 @@ 1 - @TOPIC_NAME@ + entry id 1 KalturaRoomEntry diff --git a/plugins/event_notification/providers/kafka/lib/model/KafkaNotificationTemplate.php b/plugins/event_notification/providers/kafka/lib/model/KafkaNotificationTemplate.php index 6aaf5f2a3a0..4b0b70b26e2 100644 --- a/plugins/event_notification/providers/kafka/lib/model/KafkaNotificationTemplate.php +++ b/plugins/event_notification/providers/kafka/lib/model/KafkaNotificationTemplate.php @@ -114,7 +114,7 @@ public function dispatch(kScope $scope) } $requiredPermissions = explode(",", $this->getRequiresPermissions()); - if(count(array_filter($requiredPermissions))) + if(count(array_filter($requiredPermissions, 'strlen'))) { KalturaLog::debug("Checking if partner has permissions required to dispatch [{$this->getRequiresPermissions()}]"); $found = false; diff --git a/release-notes.md b/release-notes.md index 06ea31d7047..88dcb1d9fcb 100644 --- a/release-notes.md +++ b/release-notes.md @@ -4,7 +4,7 @@ - Issue ID: FOUN-1370 ### Configuration ### - Replace all tokens (SERVICE_URL, ADMIN_CONSOLE_PARTNER_ADMIN_SECRET, TOPIC_NAME) from the template XML file below and remove ".template" from the file name: + Replace all tokens (SERVICE_URL, ADMIN_CONSOLE_PARTNER_ADMIN_SECRET) from the template XML file below and remove ".template" from the file name: /opt/kaltura/app/deployment/updates/scripts/xml/notifications/2024_03_03_add_kafka_room_entry_notifications.template.xml ### Deployment scripts ### From 70d0ec52b50cd498890a71520dacae009e1ed49b Mon Sep 17 00:00:00 2001 From: amirhalfon1 Date: Tue, 12 Mar 2024 14:52:19 +0200 Subject: [PATCH 3/3] validate kafka config (and brokers) --- .../2024_03_03_deploy_kafka_room_events.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/deployment/updates/scripts/2024_03_03_deploy_kafka_room_events.php b/deployment/updates/scripts/2024_03_03_deploy_kafka_room_events.php index 5349bed027f..b036c889980 100644 --- a/deployment/updates/scripts/2024_03_03_deploy_kafka_room_events.php +++ b/deployment/updates/scripts/2024_03_03_deploy_kafka_room_events.php @@ -9,8 +9,21 @@ if(!file_exists($newTemplateUpdate) || !file_exists($script)) { - KalturaLog::err("Missing update script file"); - return; + KalturaLog::err("Missing update script file"); + return; +} + +if (!kConf::hasMap(kConfMapNames::KAFKA)){ + KalturaLog::err("Kafka configuration file (kafka.ini) wasn't found!"); + return; +} + +$kafkaConfig = kConf::getMap(kConfMapNames::KAFKA); + +if (!isset($kafkaConfig['brokers']) && !(isset($kafkaConfig['host']) && isset($kafkaConfig['port']))) +{ + KalturaLog::err("No Kafka brokers configured"); + return; } passthru("php $script $newTemplateUpdate");