-
Notifications
You must be signed in to change notification settings - Fork 900
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
Add warning for local settings changes #23167
Conversation
I considered making this test and/or dev only, but I think it's useful to know if someone's touched this file in production too, so I left it for everything. |
a5b7b15
to
5f6f892
Compare
This is similar to our bundler warning. |
I still don't understand disabling warnings even on the bundler inject side 😉 |
@Fryguy what is the difference between |
@Fryguy I tried adding your prototype/ems_workflows to
|
@agrare |
Note that I opened #23168 for the separate bug that string keys clobber symbol keys. |
I turn the bundler-inject warnings off also. I added the overrides I don't need to be warned that they're there everytime I open a rails console IMO. If the user manually added the files/overrides it seems odd that we'd warn them that they did that. |
This might be easier to see the difference...the first 3 are committed files, the bottom 3 are "local" overrides. This PR only warns on the local overrides. > Settings.instance_variable_get(:@config_sources).select { |s| s.try(:path)&.to_s&.start_with?(Dir.pwd) }
=>
[#<Config::Sources::YAMLSource:0x0000000115fce3e0 @path="/Users/jfrey/dev/manageiq/config/settings.yml">,
#<Config::Sources::YAMLSource:0x0000000115fcd4e0 @path="/Users/jfrey/dev/manageiq/config/settings/development.yml">,
#<Config::Sources::YAMLSource:0x0000000115fcd4b8 @path="/Users/jfrey/dev/manageiq/config/environments/development.yml">,
#<Config::Sources::YAMLSource:0x0000000116866f48 @path="/Users/jfrey/dev/manageiq/config/settings.local.yml">,
#<Config::Sources::YAMLSource:0x0000000116866f20 @path="/Users/jfrey/dev/manageiq/config/settings/development.local.yml">,
#<Config::Sources::YAMLSource:0x0000000116866ef8 @path="/Users/jfrey/dev/manageiq/config/environments/development.local.yml">] |
There's no indication anywhere that the change is present, and it's easily forgotten (as in my case). Additionally, |
I always have :ems:
:ems_workflows:
:runner: "docker"
:prototype:
:ems_workflows:
:seed_builtin_workflows: true
:server:
:asynchronous_notifications: false
# :session_store: redis
:session:
:interval: 60
# redis://[:password@]host[:port][/db-number]
:redis_url: redis://127.0.0.1/3
:workers:
:worker_base:
:schedule_worker:
# useless session clear (too much noise)
:session_timeout_interval: 1.hour
# timer goes off every 3 minutes, reduce frequency (maybe 20.minutes)
# :performance_collection_interval: 10.minutes
:performance_collection_interval: 20.minutes
:performance_collection_start_delay: 5.minutes
:smtp:
# :authentication: login
# :password: ''
# :user_name: evmadmin
:authentication: 'plain'
:domain: example.com
:from: [email protected]
:host: 127.0.0.1
:port: '1025' I deal with enough databases that using I never touch |
For some people, this extra noise is expensive. If you are adding noise to the screen for the developer's "convenience", also add the feature to be quiet and get out of the developer's way. I do tend to leave the bundler warnings on - but it is very annoying and I frequently am tempted to turn it off. |
I closed because both @kbrock and @agrare seem to be using it in reasonable ways (I assumed no one used it regularly and the "correct" way is to just persist changes), and I agree with not creating noise for things that we are expected to use. However, I just noticed @kbrock used @agrare @kbrock Would you be ok if I reopened and changed to only warn on |
Should we not load from that file then if it shouldn't be used? It looks like we explicitly pull from it https://github.com/ManageIQ/manageiq/blob/master/lib/vmdb/settings.rb#L175 |
The settings.local.yml file, while a powerful tool, has a downside in that local changes modify all of dev/test/prod envs, without any indication of change, and thus it's easily forgettable. This commit adds a warning for the settings.local.yml file to indicate it has been modified.
@agrare It's a good question...I did consider it. It's part of how the config gem works under the covers, so I don't want to break their contract. The reason we explicitly list it is because we have plugins, so we need to enumerate all of the plugins, because the config gem doesn't support engines natively (and also because we have those database-level changes which needs to get in between file-level changes and local overrides) Also, it's not really wrong to use it, per se (which is why I keep using air-quotes around the word "correct"). It's a useful tool, but as with all tools, it has downsides, namely that it's easily forgettable with no indication of change and also modifies all of dev/test/prod envs. For other use cases, other files are better, such as settings/development.local.yml, which is a better choice for more permanent settings in dev like how @kbrock is using it. |
5f6f892
to
456305f
Compare
Updated the commit to only look at the settings.local.yml and not the other environment-specific local files. |
Oh okay I didn't realize that was one of their default files they look for also, yeah 👍 for warning on that one then |
@agrare I'm glad you pointed me to the config gem. It seems recent versions changed it so that settings.local.yml specifically file is not loaded in test environments. I'm going to change the way our settings code works by leveraging more of the core gem, including this whole test-doesn't-load-locals thing instead. Then, I think we don't need a warning. |
This PR adds a warning when any settings.local.yml file has changes in it. Because these changes aren't necessarily expected, they can break things if the user is not aware.
In my case, I had a settings.local.yml file present and had forgotten about it, and then test cases kept failing and I couldn't figure out why. This file is intentionally ignored by .gitignore, so locally it looked like nothing was changed.
@agrare Please review. Not sure about the wording.
Example screenshots:
With changes to
config/settings.local.yml
: