-
Notifications
You must be signed in to change notification settings - Fork 23
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
improve config search and add default freebsd config location #835
Conversation
Is it really good to add the number of places that |
The environment variable can still be used, I am just adding one more common place to search to the already existing list Also those are pretty common places to have the configuration file, I think I prefer to have it specified once here than having to deal with edge cases in multiple location because the ones listed here don't work for an OS that we say we are supporting. |
I understand what you mean and I see the benefit of it too. There were some issues before when unit tests used the configuration files under /etc which made them fail when the updates were not backward compatible. I guess that @mattias-p has fixed that issue. I agree that is simplifies. |
@@ -107,6 +107,10 @@ before_install: | |||
- git clone --depth=1 --branch=$TRAVIS_BRANCH https://github.com/zonemaster/zonemaster-engine.git | |||
- ( cd zonemaster-engine && cpanm --verbose --notest . ) && rm -rf zonemaster-engine | |||
|
|||
# Install share files | |||
- mkdir -p ./lib/auto/share/dist/ | |||
- ln -s ../../../../share ./lib/auto/share/dist/Zonemaster-Backend |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does this change relate to this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Otherwise the tests fail as dist_file
cannot find the dist directory for Zonemaster-Backend
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR adds a second path to look for backend_config.ini
, else Config.pm still falls back to what dist_file
gives. What has changed that requires a change for Travis? Or is it a bug that you fix at the same time?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before, dist_file
was not executed as we are using the environment variable, now it is always executed, that is the difference.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I may, instead of having to install the share files I'd rather avoid executing dist_file
if the ZONEMASTER_BACKEND_CONFIG_FILE
variable is set. This would prevent failure such as the Travis one. Would it be possible to execute dist_file
only if the environment variable is unset?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, thanks. Then the Travis patch could be removed I guess.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then the Travis patch could be removed I guess.
I would prefer to keep it so that the share directory is correctly installed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All right.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before,
dist_file
was not executed as we are using the environment variable, now it is always executed, that is the difference.
That change is not included in the description. Please add that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has been reverted, dist_file
is now executed only if the variable is not set, as it was before.
@@ -107,6 +107,10 @@ before_install: | |||
- git clone --depth=1 --branch=$TRAVIS_BRANCH https://github.com/zonemaster/zonemaster-engine.git | |||
- ( cd zonemaster-engine && cpanm --verbose --notest . ) && rm -rf zonemaster-engine | |||
|
|||
# Install share files | |||
- mkdir -p ./lib/auto/share/dist/ | |||
- ln -s ../../../../share ./lib/auto/share/dist/Zonemaster-Backend |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR adds a second path to look for backend_config.ini
, else Config.pm still falls back to what dist_file
gives. What has changed that requires a change for Travis? Or is it a bug that you fix at the same time?
if ( -e $default_path ) { | ||
$path = $default_path; | ||
last; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the current code, $path
is always defined. In the new code it will be undefined if the environment variable is undefinded and backend_config.ini
does not exist in any of the three paths. That will probably give a different error message. It should probably be defined.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error will be the same actually. If dist_file('Zonemaster-Backend', "backend_config.ini")
fails to find the file, then the backend fails to start with error Failed to find shared file 'backend_config.ini' for dist 'Zonemaster-Backend'
in both cases, otherwise $path
will be defined as the file exists.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the Change Request still holds? It is blocking the merge process so I would like to know if something needs to be addressed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please update the description of this PR to include the change for Travis, and I am fine with the changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've updated the description.
Testing v2021.2LGTM. As far as I can see it works as it should. |
Purpose
Improve the config search mechanism
Context
Following the comment #833 (comment)
Changes
/usr/local/etc/zonemaster/backend_config.ini
)How to test this PR
/etc/zonemaster/backend_config.ini
, run the backend, check that this is the config file loaded, then delete it/usr/local/etc/zonemaster/backend_config.ini
, run the backend, check that this is the config file loaded, then delete it/tmp/my_config.ini
, set the environment variableZONEMASTER_BACKEND_CONFIG_FILE
to/tmp/my_config.ini
, run the backend, check that this is the config file loaded, then delete it