Repository navigation
MINIFICPP-2933 Stop MiNiFi C++ if C2 connection is lost for some time - #2292
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved watchdog timing and shutdown-coordination races can cause false timeout exits or restart the agent after a terminal shutdown request.
3 open issues
What changed in this PR
Adds an opt-in C2 connection timeout that gracefully shuts down MiNiFi when successful heartbeats stop or never begin, with service handling to prevent automatic restart.
Changes:
- Introduces the connection watchdog, timeout configuration, and shutdown callback carrying exit code 90.
- Updates Windows and systemd service handling and documents the configuration.
- Adds unit, integration, and container scenarios covering timeout behavior.
| File | Description |
|---|---|
| minifi-api/include/minifi-cpp/properties/Configuration.h | Declares the connection-timeout property. |
| minifi_main/MiNiFiWindowsService.cpp | Prevents restart after timeout exit. |
| minifi_main/MiNiFiMain.cpp | Handles shutdown requests and exit codes. |
| libminifi/test/unit/C2ShutdownRecorder.h | Records shutdown callbacks for tests. |
| libminifi/test/unit/C2ConnectionWatchdogTests.cpp | Tests watchdog timing and lifecycle. |
| libminifi/test/unit/C2AgentWatchdogConfigurationTests.cpp | Tests timeout configuration and agent behavior. |
| libminifi/test/libtest/integration/IntegrationBase.h | Adds shutdown tracking fields. |
| libminifi/test/libtest/integration/IntegrationBase.cpp | Records shutdown requests in the harness. |
| libminifi/test/integration/C2ConnectionTimeoutTest.cpp | Tests shutdown after heartbeat failures. |
| libminifi/src/FlowController.cpp | Passes shutdown callbacks to C2. |
| libminifi/src/Configuration.cpp | Registers timeout property validators. |
| libminifi/src/c2/C2ConnectionWatchdog.cpp | Implements heartbeat timeout monitoring. |
| libminifi/src/c2/C2Agent.cpp | Configures and manages the watchdog. |
| libminifi/include/RequestShutdown.h | Defines the shutdown callback contract. |
| libminifi/include/FlowController.h | Updates the controller callback interface. |
| libminifi/include/c2/C2ExitCodes.h | Defines timeout exit code 90. |
| libminifi/include/c2/C2ConnectionWatchdog.h | Declares watchdog state and heartbeat updates. |
| libminifi/include/c2/C2Agent.h | Adds watchdog state and shutdown callback. |
| extensions/standard-processors/tests/features/steps/steps.py | Adds server-stop and exit-code checks. |
| extensions/standard-processors/tests/features/minifi_c2_server.feature | Adds lost and unavailable connection scenarios. |
| conf/minifi.properties.in | Adds a commented timeout example. |
| C2.md | Documents timeout and service behavior. |
| bin/minifi.service.in | Prevents systemd restart for exit code 90. |
| behave_framework/src/minifi_behave/steps/checking_steps.py | Checks logs from exited containers. |
| behave_framework/src/minifi_behave/containers/container_windows.py | Exposes container exit codes on Windows. |
| behave_framework/src/minifi_behave/containers/container_protocol.py | Adds the exit-code interface. |
| behave_framework/src/minifi_behave/containers/container_linux.py | Exposes container exit codes on Linux. |
Review effort: Balanced
szaszm
reviewed
Oct 27, 2026
fgerlits
reviewed
Oct 30, 2026
szaszm
reviewed
Nov 5, 2026
adamdebreceni
approved these changes
Nov 5, 2026
szaszm
reviewed
Nov 5, 2026
szaszm
approved these changes
Nov 5, 2026
fgerlits
approved these changes
Nov 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Added nifi.c2.connection.timeout minifi property that triggers a graceful shutdown if set and the C2 connection is not established or lost for the specified time period.
Additionally to the automated tests, the feature was manually verified using Windows and Linux (systemd) MiNiFi services.
https://issues.apache.org/jira/browse/MINIFICPP-2933
Thank you for submitting a contribution to Apache NiFi - MiNiFi C++.
In order to streamline the review of the contribution we ask you to ensure the following steps have been taken:
For all changes:
Is there a JIRA ticket associated with this PR? Is it referenced in the commit message?
Does your PR title start with MINIFICPP-XXXX where XXXX is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character.
Has your PR been rebased against the latest commit within the target branch (typically main)?
Is your initial contribution a single, squashed commit?
For code changes:
For documentation related changes:
Note:
Please ensure that once the PR is submitted, you check GitHub Actions CI results for build issues and submit an update to your PR as soon as possible.