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

Config files check #1671

Merged
merged 13 commits into from
Aug 24, 2018
Merged

Config files check #1671

merged 13 commits into from
Aug 24, 2018

Conversation

hairyhum
Copy link
Contributor

@hairyhum hairyhum commented Aug 14, 2018

Changes:

Bugfixes:

Getting filename without extension to check extensions fixed for unix:
before it was getting everything before the last dot as a name without extension,
now it uses basename and dirname to only strip extension from the file name.
Example:
For /foo/bar.baz/file filename without extension was /foo/bar and check
for /foo/bar == /foo/bar.baz/file (that the file has no extension) returned false.

Behaviour changes (script):

If RABBITMQ_ADVANCED_CONFIG_FILE exists, but RABBITMQ_CONFIG_FILE does not,
advanced config will be used as -config. This removes confusion if people want
to configure using the erlang terms format.
The script will print a warning to the stdout about that.

If both old and new config files exist and RABBITMQ_CONFIG_FILE points
to both (no extension) - there will be a warinig in the stdout
and the old format config file will be used as -config.
New configs will be ignored.

If RABBITMQ_CONFIG_FILE is configured with a wrong extension - there will be an
error and the script will fail.
This might be a breaking change if people are using files like rabbit.foo.config
and configure RABBITMQ_CONFIG_FILE to rabbit.foo. Should we support that?

If RABBITMQ_ADVANCED_CONFIG_FILE is configured with a wrong extension and is to
be used as -config - there will be an error and the script will fail.

Behaviour changes (erlang):

Prelaunch checks that RABBITMQ_ADVANCED_CONFIG_FILE is a valid config file
using file:consult and that RABBITMQ_CONFIG_FILE is either a config file
using file:consult if it has the .config extension or not a config file
if it has the .conf extension.
The same thing is checked on server start.

If '.config' file does not exist - it will not be shown in logs.

-conf_advanced argument now HAS TO always have extension.
The .config extension is always set in scripts.

Refactorings:

Extension check, -config argument and generated config arguments (-conf, -conf_advanced)
and file existense checks now separated.

"Filename without extension" (e.g. RABBITMQ_CONFIG_FILE_NOEX) variables
are set for all config files and used in more places.

More comments in code to explain what's going on.

Defaults:

advanced file now has the .config extension by default, because it can only
have one extension. Configuring it without extension is still supported.

@michaelklishin
Copy link
Member

Can we add some bats/shell script tests for this?

@@ -48,9 +48,97 @@ if not exist "!ERLANG_HOME!\bin\erl.exe" (

set RABBITMQ_EBIN_ROOT=!RABBITMQ_HOME!\ebin

if not exist "!RABBITMQ_SCHEMA_DIR!" (
Copy link
Collaborator

Choose a reason for hiding this comment

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

What do you think about combining the configuration setup code into its own .bat file to be shared between rabbitmq-server.bat and rabbitmq-service.bat?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We do have rabbitmq-env.bat. Do you think it can be moved there?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's wait for future powershell work

# Config file has an extension, but it's neither .conf or .config
echo "ERROR: Wrong extension for RABBITMQ_CONFIG_FILE: $RABBITMQ_CONFIG_FILE" 2>&1
echo "ERROR: extension should be either .conf or .config" 2>&1
return 1
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This exit should stop the rabbitmq-server sctipt, but it doesn't.
Is there a set -e missing anywhere?
I wonder if this check should go to rabbitmq-server to keep this file clean from logic.

Copy link
Collaborator

Choose a reason for hiding this comment

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

That is surprising. There is a set -e in the _rmq_env_initialize function but only if RABBITMQ_SCRIPTS_DIR is unset. Let me change the code to check the result of rabbitmq_config

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looks fine after 55a6953

@hairyhum
Copy link
Contributor Author

@lukebakken I keep discovering single closing curly braces like $RABBITMQ_MNESIA_BASE}/$RABBITMQ_NODENAME. It feels like there can be more typos like this.
Why are you removing the braces?

@hairyhum
Copy link
Contributor Author

The integration tests are in rabbitmq-ci branch config_files_check https://github.com/rabbitmq/rabbitmq-ci/pull/22

Copy link
Collaborator

@lukebakken lukebakken left a comment

Choose a reason for hiding this comment

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

👍 bats tests pass on Linux and Windows 2012. Nice job @hairyhum

@michaelklishin michaelklishin merged commit 526ec37 into master Aug 24, 2018
@michaelklishin michaelklishin added this to the 3.7.8 milestone Aug 24, 2018
@lukebakken lukebakken deleted the config_files_check branch December 21, 2018 19:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants