Skip to content

Conversation

@Watson1978
Copy link
Contributor

@Watson1978 Watson1978 commented Jan 14, 2026

Which issue(s) this PR fixes:
Fixes #

Ref. #5100

What this PR does / why we need it:
Currently, if a user explicitly @includes a file that is also located
in config_include_dir, the file is loaded twice.
This causes startup failures due to port conflicts or ID duplication.

This commit introduces a deduplication mechanism using a callback:

  1. Add on_file_parsed callback to Fluent::Config.build to track files loaded during the user config parsing phase.
  2. In Supervisor, record loaded files via this callback.
  3. When expanding config_include_dir, skip files that have already been loaded in the user configuration.

Docs Changes:

Release Note:

Signed-off-by: Shizuo Fujita <fujita@clear-code.com>
@Watson1978 Watson1978 force-pushed the conf.d branch 2 times, most recently from 3215bf9 to 06b7380 Compare January 15, 2026 01:40
Signed-off-by: Shizuo Fujita <fujita@clear-code.com>
Signed-off-by: Shizuo Fujita <fujita@clear-code.com>
Signed-off-by: Shizuo Fujita <fujita@clear-code.com>
end
end

@on_file_parsed&.call(File.expand_path(File.join(@include_basepath, @fname))) if root_element
Copy link
Contributor Author

Choose a reason for hiding this comment

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

File.join(@include_basepath, @fname) returns an absolute path,
however it doesn't include the drive letter on Windows systems.

It uses File.expand_path together to get the full absolute path.

Copy link
Contributor

@kenhys kenhys left a comment

Choose a reason for hiding this comment

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

just brief review.

# reload
supervisor.__send__(:reload_config)
reload_elements = supervisor.instance_variable_get(:@conf).elements
assert_equal(elements, reload_elements)
Copy link
Contributor

Choose a reason for hiding this comment

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

It might be better to check log message too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added tests to check log message.
d12af91


assert_equal('source', elements[3].name)
assert_equal('obsolete_plugins', elements[3]['@type'])
end
Copy link
Contributor

Choose a reason for hiding this comment

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

It might be better to check:

  • disable with config_include_dir "" and @include TEST_CONF_D/*.conf (success)
  • config_include_dir TEST_CONF_D and @include TEST_CONF_D/*.conf (error)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

* disable with config_include_dir "" and @include TEST_CONF_D/*.conf (success)

59a6d36

* config_include_dir TEST_CONF_D and @include TEST_CONF_D/*.conf (error)

4e34f8c

@Watson1978 Watson1978 marked this pull request as ready for review January 15, 2026 09:29
Signed-off-by: Shizuo Fujita <fujita@clear-code.com>
Signed-off-by: Shizuo Fujita <fujita@clear-code.com>
Signed-off-by: Shizuo Fujita <fujita@clear-code.com>
@Watson1978 Watson1978 added the backport to v1.19 We will backport this fix to the LTS branch label Jan 16, 2026
@Watson1978 Watson1978 added this to the v1.20.0 milestone Jan 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport to v1.19 We will backport this fix to the LTS branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants