Skip to content

Skip Deinit() when modules were never initialized#288

Open
RiSKeD wants to merge 1 commit intomainfrom
fix/init
Open

Skip Deinit() when modules were never initialized#288
RiSKeD wants to merge 1 commit intomainfrom
fix/init

Conversation

@RiSKeD
Copy link
Contributor

@RiSKeD RiSKeD commented Feb 27, 2026

--check-config and --dry-run (on failure) call cleanup() without having called initModules(), causing spurious Deinit log noise on every config validation. Track whether module init was attempted and only run Deinit if it was.

Copilot AI review requested due to automatic review settings February 27, 2026 14:14
@RiSKeD
Copy link
Contributor Author

RiSKeD commented Feb 27, 2026

Before change:

root@anti-monitor:~# /usr/local/bin/dutagent --check-config -c /etc/dutagent/hermes-config-invalid-test.yaml 
2026/02/27 15:08:13 Bad configuration: parsing YAML failed: command must have at most one main module
2026/02/27 15:08:13 GRACEFUL SHUTDOWN: De-init modules
2026/02/27 15:08:13 All modules de-initialized

Afterwards:

root@anti-monitor:~# /usr/local/bin/dutagent --check-config -c /etc/dutagent/hermes-config-invalid-test.yaml 
2026/02/27 15:08:13 Bad configuration: parsing YAML failed: command must have at most one main module

@RiSKeD RiSKeD changed the title fix(dutagent): skip Deinit when modules were never initialized fix: skip Deinit when modules were never initialized Feb 27, 2026
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes spurious Deinit log noise that occurs when --check-config or --dry-run (on failure) execute cleanup without having initialized modules. A boolean flag is introduced to track whether module initialization was attempted, ensuring Deinit() is only called when appropriate.

Changes:

  • Added modulesInitialed field to track whether initModules() was called
  • Modified cleanup() to only call Deinit() if modules were initialized
  • Simplified cleanup logic by removing the nil check for devices

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@RiSKeD RiSKeD force-pushed the fix/init branch 2 times, most recently from 12f209a to 285046c Compare February 27, 2026 14:25
@RiSKeD RiSKeD requested review from Copilot and jenstopp March 11, 2026 07:27
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

--check-config and --dry-run (on failure) call cleanup() without having
called initModules(), causing spurious Deinit log noise on every config
validation. Track whether module init was attempted and only run Deinit
if it was.

Signed-off-by: Fabian Wienand <fabian.wienand@9elements.com>
@jenstopp
Copy link
Member

Wouldn't it be even more robust to save the "init happened" info with each module?

@jenstopp jenstopp changed the title fix: skip Deinit when modules were never initialized Skip Deinit() when modules were never initialized Mar 16, 2026
@RiSKeD
Copy link
Contributor Author

RiSKeD commented Mar 17, 2026

Sure this could also be done. I don't favor any of the approaches. I can rewrite it that way too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants