Settings not loaded after dev env reload & request output

I was setting up a fresh development env and I ran into two problems.

First of all, I have the problem that after autoreload cleared any loaded settings. On IRC @tbrisker said

try adding Foreman.settings.load to config/application.rb:315, seems to work for me

Is anyone else tracking this? @ezr-ondrej perhaps?

Then I also see empty lines for every request:

17:05:28 rails.1   | 2021-05-07T17:05:28 [I|app|0f3ba5cb] Started GET "/notification_recipients" for 127.0.0.1 at 2021-05-07 17:05:28 +0200
17:05:28 rails.1   | 2021-05-07T17:05:28 [I|app|0f3ba5cb] Processing by NotificationRecipientsController#index as JSON
17:05:28 rails.1   | 2021-05-07T17:05:28 [D|tax|0f3ba5cb] Current location set to Default Location
17:05:28 rails.1   | 2021-05-07T17:05:28 [D|tax|0f3ba5cb] Current organization set to Default Organization
17:05:28 rails.1   | 2021-05-07T17:05:28 [D|not|0f3ba5cb] Cache Miss: notification, writing cache for notification-4
17:05:28 rails.1   | 2021-05-07T17:05:28 [D|not|0f3ba5cb] Expiring notification cache notification-4 in 3600 seconds
17:05:28 rails.1   | 2021-05-07T17:05:28 [D|app|0f3ba5cb] Body: {"notifications":[]}
17:05:28 rails.1   | 2021-05-07T17:05:28 [I|app|0f3ba5cb] Completed 200 OK in 29ms (Views: 0.1ms | ActiveRecord: 4.8ms | Allocations: 20559)
17:05:28 rails.1   |  0f3ba5cb | 
17:05:28 rails.1   |  0f3ba5cb | 
17:05:38 rails.1   | 2021-05-07T17:05:38 [I|app|303b334c] Started GET "/notification_recipients" for 127.0.0.1 at 2021-05-07 17:05:38 +0200
17:05:38 rails.1   | 2021-05-07T17:05:38 [I|app|303b334c] Processing by NotificationRecipientsController#index as JSON
17:05:38 rails.1   | 2021-05-07T17:05:38 [D|tax|303b334c] Current location set to Default Location
17:05:38 rails.1   | 2021-05-07T17:05:38 [D|tax|303b334c] Current organization set to Default Organization
17:05:38 rails.1   | 2021-05-07T17:05:38 [D|not|303b334c] Cache Hit: notification, reading cache for notification-4
17:05:38 rails.1   | 2021-05-07T17:05:38 [D|app|303b334c] Body: {"notifications":[]}
17:05:38 rails.1   | 2021-05-07T17:05:38 [I|app|303b334c] Completed 200 OK in 12ms (Views: 0.1ms | ActiveRecord: 0.6ms | Allocations: 13578)
17:05:38 rails.1   |  303b334c | 
17:05:38 rails.1   |  303b334c | 

Is this also a known problem? Any idea where this comes from?

Iā€™m not using autoreload because it generally doesnā€™t work, but Iā€™ll take a look into it, as it should work because of this line: foreman/foreman.rb at b6b6ffc01ca7065182571a221d4a02e1baa25127 Ā· theforeman/foreman Ā· GitHub

Though it might be a case, that it gets here before all the descendants are loaded, so there are no subclasses to load the setting definitions from.

Iā€™ve managed to work around this issue locally by adding

Foreman.settings.load 

to config/application.rb:318.
This is being tracked at Bug #32489: Setting registry doesn't reload properly on autoreload - Foreman.

My experience is that it usually does work, and if it doesnā€™t itā€™s something we need to fix. Restarting the server on every code change is a PITA.

1 Like

I agree with @tbrisker, we should keep autoreloading to work. I believe itā€™s important for people who donā€™t know yet how to fix a $thing and need to experiment. Typically new contributors or myself :slight_smile:

Iā€™ll also add to that that autoreload is the default dev deployment. Having a broken-by-default setup is a painful experience.

I agree and I believe it is something we should try fixing asap. I also agree that for most cases it works, but with multiple plugins there are gotchas. I myself, have fixing the dev reload properly in my todo, but it would seem that for now Iā€™ve managed just to break it :man_facepalming:

This should fix the issue: