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

Optionally abort startup when unknown configuration parameters were detected #5676

Merged
merged 18 commits into from
Apr 18, 2024

Conversation

leonardehrenfried
Copy link
Member

Summary

When managing a large number of deployments many configuration files need to be maintained and when upgrading to newer versions, it's easy to overlook that the configuration schema has changed.

There is already a validation system in place that prints warnings but it would be nice if you could make OTP fail loudly when the configuration is invalid. This way you'd notice straight away.

This PR adds this capability: you can pass the CLI param --configCheck and OTP fails to startup. This forces you to deal with the invalid configuration straight away.

Unit tests

✔️

Documentation

✔️

@leonardehrenfried leonardehrenfried added New Feature IBI Developed by or important for IBI Group labels Feb 8, 2024
@leonardehrenfried leonardehrenfried requested a review from a team as a code owner February 8, 2024 13:56
@leonardehrenfried
Copy link
Member Author

cc @miles-grant-ibigroup @hbruch

Copy link

codecov bot commented Feb 8, 2024

Codecov Report

Attention: Patch coverage is 13.33333% with 13 lines in your changes are missing coverage. Please review.

Project coverage is 67.88%. Comparing base (0532203) to head (68f667e).
Report is 254 commits behind head on dev-2.x.

Files Patch % Lines
...opentripplanner/standalone/config/ConfigModel.java 0.00% 6 Missing ⚠️
...n/java/org/opentripplanner/standalone/OTPMain.java 0.00% 4 Missing ⚠️
...opentripplanner/standalone/config/BuildConfig.java 0.00% 1 Missing ⚠️
...g/opentripplanner/standalone/config/OtpConfig.java 0.00% 1 Missing ⚠️
...pentripplanner/standalone/config/RouterConfig.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             dev-2.x    #5676      +/-   ##
=============================================
+ Coverage      67.77%   67.88%   +0.11%     
- Complexity     16474    16560      +86     
=============================================
  Files           1901     1908       +7     
  Lines          72121    72355     +234     
  Branches        7430     7443      +13     
=============================================
+ Hits           48881    49121     +240     
+ Misses         20727    20714      -13     
- Partials        2513     2520       +7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

jtorin
jtorin previously approved these changes Feb 15, 2024
Copy link
Contributor

@jtorin jtorin left a comment

Choose a reason for hiding this comment

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

I can see the benefit of exposing the config validation logic outside of OTP. It would be possible to work-around it by analyzing the log for validation errors, but it's messy to do in an automated fashion, and to fully emulate the behavior the OTP process would have to be stopped. So this adds value.

However, I don't see that OTP sets an exit code, somewhat limiting the use in automated logic.

@leonardehrenfried leonardehrenfried added this to the 2.5 (next release) milestone Feb 21, 2024
Copy link
Member

@t2gran t2gran left a comment

Choose a reason for hiding this comment

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

My main consern with this PR is that the we opens up for an alternative way of setting up OTP. The design is well though through to support a wide range of deployments, while this PR is not. Supporting alternatives always require more maintenance. The code changes here are relative small, but we are likely to see other similar requests in the future. I have taken some time to think through this, and I do see it is useful for some deployments, so I will approve it (when my comments are fixed). I have also considered other strategies, but have not found one which would work in all cases with this strict validation applied.

This deviates from the main model/design. But, it supports simpler deployments. I have considered spliting environment specific config (including ways if filtering the config - supported today) and OTP tuning. But, it is not so simple. E.g. you may want to turn on a feature in the test environment, but not in the production environment.

docs/Migrating-Configuration.md Outdated Show resolved Hide resolved
src/main/java/org/opentripplanner/standalone/OTPMain.java Outdated Show resolved Hide resolved
jtorin
jtorin previously approved these changes Mar 12, 2024
Copy link
Member

@t2gran t2gran left a comment

Choose a reason for hiding this comment

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

The doc is ok, just some minor stuff left.

docs/Migrating-Configuration.md Outdated Show resolved Hide resolved
mkdocs.yml Outdated Show resolved Hide resolved
src/main/java/org/opentripplanner/standalone/OTPMain.java Outdated Show resolved Hide resolved
jtorin
jtorin previously approved these changes Mar 12, 2024
jtorin
jtorin previously approved these changes Mar 13, 2024
@t2gran t2gran modified the milestones: 2.5, 2.6 (next release) Mar 13, 2024
jtorin
jtorin previously approved these changes Mar 25, 2024
@leonardehrenfried leonardehrenfried changed the title Optionally abort startup when invalid configuration was detected Optionally abort startup when unknown configuration parameters were detected Apr 2, 2024
Co-authored-by: Thomas Gran <t2gran@gmail.com>
@leonardehrenfried leonardehrenfried merged commit 085f049 into opentripplanner:dev-2.x Apr 18, 2024
5 checks passed
@leonardehrenfried leonardehrenfried deleted the config-check branch April 18, 2024 13:24
t2gran pushed a commit that referenced this pull request Apr 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
IBI Developed by or important for IBI Group New Feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants