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

Validate plugin compatibility with version ranges #642

Merged
merged 21 commits into from
Apr 8, 2016

Conversation

hairyhum
Copy link
Contributor

Proposal for #591

In plugin .app.src rabbitmq versions will be defined like {rabbitmq_versions, ["3.5.4", "3.6.0"]}, which means that this plugin valid for versions "3.5.4" and higher "3.5.x" and all "3.6.x" versions.
The same format is used for plugin dependencies e.g:

{application, rabbitmq_federation_management,[
    ...
    {plugins_versions, [{rabbitmq_management, ["3.7.2"]}, {rabbitmq_federation, ["3.7.0"]}]}
]}.

Requires rabbitmq_management dependency version to be 3.7.2 or higher for 3.7.x series and rabbitmq_federation version to be any of 3.7.x series.

@hairyhum
Copy link
Contributor Author

In plugin .app.src rabbitmq versions will be defined like {rabbitmq_versions, ["3.5.4", "3.6.0"]}, which means that this plugin valid for versions "3.5.4" and higher "3.5.x" and all "3.6.x" versions.

@michaelklishin
Copy link
Member

Lets start with some automated test examples that'd demonstrate how it works and what kind of edge cases there may be.

@hairyhum hairyhum changed the title DO NOT MERGE Rabbit broker version check in plugins proposal Rabbit broker version check in plugins proposal Mar 2, 2016
@hairyhum
Copy link
Contributor Author

hairyhum commented Mar 3, 2016

Should we continue with this?

@michaelklishin
Copy link
Member

@hairyhum I haven't looked at it properly yet, sorry.

@hairyhum
Copy link
Contributor Author

hairyhum commented Mar 8, 2016

Maybe it makes sense to include version checks for plugins depending on plugins.

@michaelklishin michaelklishin changed the title Rabbit broker version check in plugins proposal SPIKE Validate plugin compatibility with version ranges Mar 24, 2016
@hairyhum
Copy link
Contributor Author

Here are possible error messages:

Rabbitmq version mismatch:

[warning] Problem reading some plugins: plugin1: version mismatch, required: ["3.5.0","3.6.0"], got "3.7.0"

Rabbitmq version is not specified:

[warning] Some plugins doesn't specify required RabbitMQ version: plugin2, plugin3

Plugin dependency version do not match: (specified required version for dep1 and dep2, dep1 doesn't exist, dep2 version do not match requirement)

[warning] Some plugin versions do not match:
    plugin1: 
        missing dependency: dep1
        dependency version mismatch: dep2 required ["3.5.6", "3.6.0"], got "3.7.0"

Plugin will not be loaded in case of version mismatch. But will be loaded if required version is not specified. There should be some way to inform about it.

@michaelklishin @dumbbell @bdshroyer any ideas on improving messages?

@michaelklishin
Copy link
Member

"Problem loading a plugin…"
"Some plugin do not specify…"

I also don't think that using a pair of two versions will be very clear to the user.

@hairyhum
Copy link
Contributor Author

hairyhum commented Apr 4, 2016

Error message format example:

Failed to enable some plugins: 
    rabbitmq_federation_management:
        Dependency is missing or invalid: rabbitmq_management
    rabbitmq_management:
        Broker version is invalid. Current version: "3.7.0" Required: ["3.6.0"]
    rabbitmq_shovel_management:
        rabbitmq_shovel plugin version is invalid. Current version: "3.7.1" Required: ["3.7.2"]    

When running rabbitmq-plugins enable or rabbitmq-plugins set invalid plugins will not be added to enabled_plugins and error is printed.
When plugins (or broker) are updated and server restarts with existing list of plugins - it will print message to log and start without this plugins.

@michaelklishin michaelklishin changed the title SPIKE Validate plugin compatibility with version ranges Validate plugin compatibility with version ranges Apr 7, 2016
@michaelklishin michaelklishin added this to the n/a milestone Apr 7, 2016
@@ -1,7 +1,7 @@
{application, rabbit, %% -*- erlang -*-
[{description, "RabbitMQ"},
{id, "RabbitMQ"},
{vsn, "0.0.0"},
{vsn, "3.7.0"},
Copy link
Member

Choose a reason for hiding this comment

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

This value is updated at build time. @dumbbell do you agree with this default value bump?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, commited accidentally.

@@ -245,19 +253,103 @@ prepare_plugins(Enabled) ->
AllPlugins = list(PluginsDistDir),
Wanted = dependencies(false, Enabled, AllPlugins),
WantedPlugins = lookup_plugins(Wanted, AllPlugins),

{ValidPlugins, Problems} = validate_plugins(WantedPlugins),
%TODO: error message formatting
Copy link
Member

Choose a reason for hiding this comment

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

Should we address this?

@michaelklishin
Copy link
Member

@hairyhum this is on the finish line but there are still two things to do:

  • I had to update the copy. Please check that I haven't made any mistakes.
  • When I configure rabbitmq_management to validate rabbitmq_management_agent version so that I can trigger a dependency version mismatch error, I get effective version reported incorrectly.

Specifically, with the following added to rabbitmq_management.app.src:

{dependency_version_requirements, [{rabbitmq_management_agent, ["3.7.0"]}]},

and attempt to start the broker with `make run-broker PLUGINS='rabbitmq_management',
the effective version reports doesn't seem correct:

Error: Failed to enable some plugins:
    rabbitmq_management:
        Version '[]' of dependency 'rabbitmq_management_agent' is unsupported. Version ranges supported by the plugin: ["3.7.0"]

@michaelklishin
Copy link
Member

Scratch the above, it's due to the fact that in development plugin version was an empty string. When I set it to a realistic value, I get what I expect:

Error: Failed to enable some plugins:
    rabbitmq_management:
        Version '"3.4.0"' of dependency 'rabbitmq_management_agent' is unsupported. Version ranges supported by the plugin: ["3.7.0"]

So yeah, this seems to be mostly about copy review and a bit more testing, e.g. with a release build.

@hairyhum
Copy link
Contributor Author

hairyhum commented Apr 8, 2016

I guess we can skip validations if plugin version is empty, assuming it's development version. Or just warn users that there are empty versions, which won't be checked.

@michaelklishin
Copy link
Member

@hairyhum OK, that sounds like a good idea. Since this is in master, we should also add debug logging for what plugins were checked against what version ranges.

case is_version_supported(Version, Versions) of
true -> Acc;
false ->
[{{version_mismatch, Version, Versions}, Name} | Acc]
Copy link
Member

Choose a reason for hiding this comment

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

We should rename this to dependency_version_mismatch to be more specific.

@michaelklishin michaelklishin merged commit 64f5794 into master Apr 8, 2016
@dumbbell dumbbell deleted the rabbitmq-server-591 branch January 2, 2018 15:28
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.

2 participants