You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by sz...@apache.org on 2024/11/22 08:47:18 UTC
(nifi-minifi-cpp) 06/07: MINIFICPP-2493 Fix C2 flow update with parameter contexts
This is an automated email from the ASF dual-hosted git repository.
szaszm pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/nifi-minifi-cpp.git
commit 59531402813aa7c88a9771fc29e713217637249e
Author: Gabor Gyimesi <ga...@gmail.com>
AuthorDate: Thu Nov 21 14:13:24 2024 +0100
MINIFICPP-2493 Fix C2 flow update with parameter contexts
https://issues.apache.org/jira/browse/MINIFICPP-2493
Closes #1898
Signed-off-by: Marton Szasz <sz...@apache.org>
---
docker/test/integration/features/minifi_c2_server.feature | 12 ++++++++++++
.../test/integration/resources/minifi-c2-server/config.yml | 12 +++++++++++-
libminifi/src/core/FlowConfiguration.cpp | 2 ++
3 files changed, 25 insertions(+), 1 deletion(-)
diff --git a/docker/test/integration/features/minifi_c2_server.feature b/docker/test/integration/features/minifi_c2_server.feature
index b3bce044f..ff6640deb 100644
--- a/docker/test/integration/features/minifi_c2_server.feature
+++ b/docker/test/integration/features/minifi_c2_server.feature
@@ -54,3 +54,15 @@ Feature: MiNiFi can communicate with Apache NiFi MiNiFi C2 server
When all instances start up
Then the MiNiFi C2 SSL server logs contain the following message: "acknowledged with a state of FULLY_APPLIED(DONE)" in less than 60 seconds
And a flowfile with the content "test" is placed in the monitored directory in less than 10 seconds
+
+ Scenario: MiNiFi flow config is updated from MiNiFi C2 server with overriden parameter context
+ Given a GetFile processor with the name "GetFile1" and the "Input Directory" property set to "${INPUT_DIR}"
+ And parameter context name is set to 'my-context'
+ And a non-sensitive parameter in the flow config called 'INPUT_DIR' with the value '/tmp/non-existent' in the parameter context 'my-context'
+ And C2 is enabled in MiNiFi
+ And a file with the content "test" is present in "/tmp/input"
+ And a MiNiFi C2 server is set up
+ When all instances start up
+ Then the MiNiFi C2 server logs contain the following message: "acknowledged with a state of FULLY_APPLIED(DONE)" in less than 30 seconds
+ And a flowfile with the content "test" is placed in the monitored directory in less than 10 seconds
+ And the Minifi logs do not contain the following message: "Failed to parse json response: The document is empty. at 0" after 0 seconds
diff --git a/docker/test/integration/resources/minifi-c2-server/config.yml b/docker/test/integration/resources/minifi-c2-server/config.yml
index ddac4cd77..5b8548105 100644
--- a/docker/test/integration/resources/minifi-c2-server/config.yml
+++ b/docker/test/integration/resources/minifi-c2-server/config.yml
@@ -1,6 +1,15 @@
MiNiFi Config Version: 3
Flow Controller:
name: MiNiFi Flow
+Parameter Contexts:
+ - id: 721e10b7-8e00-3188-9a27-476cca376978
+ name: my-context
+ description: my parameter context
+ Parameters:
+ - name: INPUT_DIR
+ description: ''
+ sensitive: false
+ value: /tmp/input
Processors:
- name: Get files from /tmp/input
id: 2f2a3b47-f5ba-49f6-82b5-bc1c86b96e27
@@ -8,7 +17,7 @@ Processors:
scheduling strategy: TIMER_DRIVEN
scheduling period: 1000 ms
Properties:
- Input Directory: /tmp/input
+ Input Directory: "#{INPUT_DIR}"
- name: Put files to /tmp/output
id: e143601d-de4f-44ba-a6ec-d1f97d77ec94
class: org.apache.nifi.minifi.processors.PutFile
@@ -27,5 +36,6 @@ Connections:
source relationship names:
- success
destination id: e143601d-de4f-44ba-a6ec-d1f97d77ec94
+Parameter Context Name: my-context
Controller Services: []
Remote Process Groups: []
diff --git a/libminifi/src/core/FlowConfiguration.cpp b/libminifi/src/core/FlowConfiguration.cpp
index fd46a064a..53b1e8def 100644
--- a/libminifi/src/core/FlowConfiguration.cpp
+++ b/libminifi/src/core/FlowConfiguration.cpp
@@ -94,6 +94,7 @@ std::unique_ptr<core::reporting::SiteToSiteProvenanceReportingTask> FlowConfigur
std::unique_ptr<core::ProcessGroup> FlowConfiguration::updateFromPayload(const std::string& url, const std::string& yamlConfigPayload, const std::optional<std::string>& flow_id) {
auto old_provider = service_provider_;
+ auto old_parameter_contexts = std::move(parameter_contexts_);
service_provider_ = std::make_shared<core::controller::StandardControllerServiceProvider>(std::make_unique<core::controller::ControllerServiceNodeMap>(), configuration_);
auto payload = getRootFromPayload(yamlConfigPayload);
if (!url.empty() && payload != nullptr) {
@@ -110,6 +111,7 @@ std::unique_ptr<core::ProcessGroup> FlowConfiguration::updateFromPayload(const s
flow_version_->setFlowVersion(url, bucket_id, flow_id ? *flow_id : payload_flow_id);
} else {
service_provider_ = old_provider;
+ parameter_contexts_ = std::move(old_parameter_contexts);
}
return payload;
}