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

Add error handling and tests #4

Merged
merged 6 commits into from
Jan 8, 2018
Merged

Add error handling and tests #4

merged 6 commits into from
Jan 8, 2018

Conversation

dschniepp
Copy link
Contributor

Over christmas we experienced (CaseClauseError) no case clause matching: {:error, :econnrefused} errors.

Elixir.CaseClauseError: no case clause matching: {:error, :econnrefused}
  File "lib/libcluster_ec2.ex", line 53, in ClusterEC2.request/1
  File "lib/libcluster_ec2.ex", line 29, in ClusterEC2.local_instance_tags/0
  File "lib/libcluster_ec2.ex", line 38, in ClusterEC2.local_instance_tag_value/1
  File "lib/strategy/tags.ex", line 96, in ClusterEC2.Strategy.Tags.get_nodes/1
  File "lib/strategy/tags.ex", line 61, in ClusterEC2.Strategy.Tags.handle_info/2
...
(4 additional frame(s) were not displayed)

(CaseClauseError) no case clause matching: {:error, :econnrefused}

So I changed the code in order to prevent exceptions. What do you think?

  • Reimplemented request via Tesla
  • Added tests
  • Moved tags related code from lib/libcluster_ec2.ex to lib/strategy/tags.ex
  • added .editorconfig

@kyleaa
Copy link
Owner

kyleaa commented Jan 5, 2018

This looks great!

I'm curious and haven't found it documented - do you know if returning an empty list from get_nodes will cause all of the nodes to disconnect?

@dschniepp
Copy link
Contributor Author

Good point, I think it will cause that all nodes get disconnected otherwise Cluster.Strategy.disconnect_nodes wouldn't be necessary.

Thank you for pointing out I will propose a solution. Maybe we can bubble up the errors and in case of a connection error or timeout we will keep the state as it is.

@dschniepp
Copy link
Contributor Author

@kyleaa i changed the logic to the following behaviour:
In case the instance_id or region is not set the node_list will not be fetched and returns an error tuple. If the error appears the existing state won't be changed. What do you think?

@kyleaa kyleaa merged commit 65d2b6c into kyleaa:master Jan 8, 2018
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