Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lazy configuration processing, printing all errors at once #19801

Merged
merged 2 commits into from
Jul 2, 2024

Conversation

todvora
Copy link
Contributor

@todvora todvora commented Jul 2, 2024

This PR changes the way how we handle configuration errors during startup. The original logic stopped on first encountered error, forcing user to fix it and try again, which could repeat several times and leads to tiresome process. The new logic discovers and reports all problems at once, making it easy to fix in one go.

Removed duplicated configuration processing during the datanode startup, which I assume, was a copy-paste error.

Description

See Graylog2/JadConfig#127

Motivation and Context

Fixes #19207

How Has This Been Tested?

Manually

Screenshots (if appropriate):

Before, stopping at the first error:

2024-07-02 09:19:25,504 ERROR: org.graylog.datanode.bootstrap.CmdLineTool - Invalid configuration
com.github.joschi.jadconfig.ParameterException: Required parameter "opensearch_data_location" not found.
	at com.github.joschi.jadconfig.JadConfig.processClassField(JadConfig.java:173) ~[jadconfig-0.15.0.jar:?]
	at com.github.joschi.jadconfig.JadConfig.processClassFields(JadConfig.java:143) ~[jadconfig-0.15.0.jar:?]
	at com.github.joschi.jadconfig.JadConfig.process(JadConfig.java:103) ~[jadconfig-0.15.0.jar:?]
	at org.graylog.datanode.bootstrap.CmdLineTool.processConfiguration(CmdLineTool.java:422) [classes/:?]
	at org.graylog.datanode.bootstrap.CmdLineTool.parseAndGetConfiguration(CmdLineTool.java:310) [classes/:?]
	at org.graylog.datanode.bootstrap.CmdLineTool.doRun(CmdLineTool.java:266) [classes/:?]
	at org.graylog.datanode.bootstrap.CmdLineTool.run(CmdLineTool.java:246) [classes/:?]
	at org.graylog.datanode.bootstrap.Main.main(Main.java:57) [classes/:?]

After, collecting all errors and then failing:

2024-07-02 09:21:06,927 ERROR: org.graylog.datanode.bootstrap.CmdLineTool - Invalid configuration
com.github.joschi.jadconfig.LazyValidationException: Following errors ocurred during configuration processing:
Required parameter "opensearch_data_location" not found.
Required parameter "opensearch_config_location" not found.
Required parameter "opensearch_logs_location" not found.
	at com.github.joschi.jadconfig.JadConfig.processFailingLazily(JadConfig.java:118) ~[jadconfig-0.15.0.jar:?]
	at org.graylog.datanode.bootstrap.CmdLineTool.processConfiguration(CmdLineTool.java:422) [classes/:?]
	at org.graylog.datanode.bootstrap.CmdLineTool.parseAndGetConfiguration(CmdLineTool.java:310) [classes/:?]
	at org.graylog.datanode.bootstrap.CmdLineTool.doRun(CmdLineTool.java:266) [classes/:?]
	at org.graylog.datanode.bootstrap.CmdLineTool.run(CmdLineTool.java:246) [classes/:?]
	at org.graylog.datanode.bootstrap.Main.main(Main.java:57) [classes/:?]

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Refactoring (non-breaking change)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.

@todvora todvora requested a review from moesterheld July 2, 2024 07:27
@todvora
Copy link
Contributor Author

todvora commented Jul 2, 2024

FYI @janheise @luk-kaminski @bernd 🙏

Copy link
Contributor

@luk-kaminski luk-kaminski left a comment

Choose a reason for hiding this comment

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

Looks good, thx!

Copy link
Contributor

@moesterheld moesterheld left a comment

Choose a reason for hiding this comment

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

lgtm

@moesterheld moesterheld merged commit 33dfb06 into master Jul 2, 2024
10 of 12 checks passed
@moesterheld moesterheld deleted the feature/datanode-lazy-configuration-processing branch July 2, 2024 08:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants