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

Rancher strategy #27

Merged
merged 2 commits into from
Sep 7, 2017
Merged

Rancher strategy #27

merged 2 commits into from
Sep 7, 2017

Conversation

zorbash
Copy link
Contributor

@zorbash zorbash commented Sep 5, 2017

This introduces a strategy for the Rancher container management platform.
see: https://github.com/rancher/rancher

It leverages the metadata HTTP API to get the IPs of all the containers of a service to form a cluster.

Copy link
Owner

@bitwalker bitwalker left a comment

Choose a reason for hiding this comment

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

Just a few comments, but looks good! I'm generally not a huge fan of rolling strategies into the mainline libcluster repo, as it means I have to maintain them, and if I'm not using them myself, or likely to, then it can mean they fall out of date. That said, this is pretty basic, so it should be easy to keep up to date. Thanks for the PR!

new_nodelist = MapSet.new(get_nodes(state))
added = MapSet.difference(new_nodelist, state.meta)
removed = MapSet.difference(state.meta, new_nodelist)
new_nodelist = case Cluster.Strategy.disconnect_nodes(topology, disconnect, list_nodes, MapSet.to_list(removed)) do
Copy link
Owner

Choose a reason for hiding this comment

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

Small nitpick:

new_nodelist =
  case ...

rather than the case and assignment on one line

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I updated this part, let me know what you think.

defp get_nodes(%State{topology: topology, config: config}) do
app_name = Keyword.fetch!(config, :node_basename)

cond do
Copy link
Owner

Choose a reason for hiding this comment

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

I think I'd prefer:

case Keyword.fetch!(config, :node_basename) do
  app_name when is_binary(app_name) and app_name != "" ->
    <happy case>
  app_name ->
    warn topology, "rancher strategy is selected, but :node_basename is invalid, got: #{inspect app_name}"
    []
end

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed according to your preference, but I also allow app_name to be configured as an Atom. Is this OK?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Please ignore the above comment, I changed it back to be exactly as you suggested, since it's a binary in the example config of the documentation and also the Kubernetes strategy only allows binary for the equivalent config option.

This introduces a strategy for the Rancher container management
platform (see: https://github.com/rancher/rancher).
It leverages the metadata HTTP API to get the IPs of all the containers
of a service to form a cluster.
@zorbash
Copy link
Contributor Author

zorbash commented Sep 6, 2017

Should I also update the CHANGELOG and README with info about this change, in this PR?

@bitwalker
Copy link
Owner

Sure! That would be greatly appreciated :)

@zorbash
Copy link
Contributor Author

zorbash commented Sep 7, 2017

README and CHANGELOG files have been updated.

@bitwalker bitwalker merged commit b6c3823 into bitwalker:master Sep 7, 2017
@bitwalker
Copy link
Owner

Thanks for all the great work!

@zorbash zorbash deleted the rancher-strategy branch September 8, 2017 08:41
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