Skip to content

MINIFICPP-2933 Stop MiNiFi C++ if C2 connection is lost for some time - #2292

Merged
fgerlits merged 6 commits into
apache:mainfrom
lordgamez:MINIFICPP-2933
Nov 6, 2026
Merged

fgerlits merged 6 commits into
apache:mainfrom
lordgamez:MINIFICPP-2933

Conversation

@lordgamez

@lordgamez lordgamez commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

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:

  • If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under ASF 2.0?
  • If applicable, have you updated the LICENSE file?
  • If applicable, have you updated the NOTICE file?

For documentation related changes:

  • Have you ensured that format looks appropriate for the output in which it is rendered?

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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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

Comment thread minifi_main/MiNiFiMain.cpp Resolved
Comment thread libminifi/src/c2/C2Agent.cpp Resolved
Comment thread conf/minifi.properties.in Resolved
@lordgamez lordgamez added the priority Review these first label Oct 29, 2026
@fgerlits fgerlits assigned fgerlits and unassigned fgerlits Oct 30, 2026
@fgerlits
fgerlits self-requested a review October 30, 2026 13:24
Comment thread libminifi/src/c2/C2Agent.cpp Resolved
Comment thread minifi_main/MiNiFiMain.cpp Resolved
Comment thread minifi_main/MiNiFiMain.cpp Resolved
Comment thread minifi_main/MiNiFiMain.cpp Resolved
Comment thread minifi_main/MiNiFiMain.cpp Resolved
Comment thread C2.md Resolved
@fgerlits
fgerlits merged commit a403655 into apache:main Nov 6, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority Review these first

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants