Skip to content

Conversation

@hectcastro
Copy link
Contributor

@hectcastro hectcastro commented Jan 21, 2017

Modify get_cluster_info to include a timeout (defaults to 3 seconds) and match against the success (END) and failure case (ERROR) in the same call. From there, gracefully degrade (only if the IGNORE_CLUSTER_ERRORS option is True) when the ElastiCache cluster configuration endpoint isn't available by returning the provided host and port in the nodes list.

Also, add two additional tests to the protocol test suite to cover the additional functionality.

Fixes #16


Testing

root@22a790647170:/usr/src/app# python setup.py nosetests
running nosetests
running egg_info
writing requirements to django_elasticache.egg-info/requires.txt
writing django_elasticache.egg-info/PKG-INFO
writing top-level names to django_elasticache.egg-info/top_level.txt
writing dependency_links to django_elasticache.egg-info/dependency_links.txt
reading manifest file 'django_elasticache.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'django_elasticache.egg-info/SOURCES.txt'
............
----------------------------------------------------------------------
Ran 13 tests in 0.159s

OK

These tests were executed within a Python 2.7 Docker container with all of the necessary dependencies. Let me know if you'd like that setup in a separate PR.

Modify `get_cluster_info` to include a timeout (defaults to 3 seconds) and
gracefully degrade when the ElastiCache cluster configuration endpoint isn't
available by returning the provided `host` and `port` in the `nodes` list.

I also added an additional test to the protocol test suite to cover the
additional functionality.
Make use of Telnet.expect() to match against the success (END) and failure
case (ERROR) in the same call.

Update protocol tests to handle patching expect() with output that was
previously returned by read_until().
Conditionally ignore failures to `config get cluster` calls against the
configured LOCATION endpoint with the introduction of a `IGNORE_CLUSTER_ERRORS`
option (that defaults to `False`).
Copy link
Owner

@gusdan gusdan left a comment

Choose a reason for hiding this comment

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

Looks good. Just few changes.



def get_cluster_info(host, port):
def get_cluster_info(host, port, timeout=3):
Copy link
Owner

Choose a reason for hiding this comment

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

let's remove timeouts or use default timeout from cache configuration setting

'tcp_nodelay': True,
'ketama': True
'ketama': True,
'IGNORE_CLUSTER_ERRORS': False,
Copy link
Owner

Choose a reason for hiding this comment

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

i don't think we should pass IGNORE_CLUSTER_ERRORS to parent class (pylibmc)



def get_cluster_info(host, port):
def get_cluster_info(host, port, ignore_cluster_errors=False, timeout=3):
Copy link
Owner

Choose a reason for hiding this comment

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

let's remove timeout.

@hectcastro
Copy link
Contributor Author

I believe that all of your comments have been addressed.

Copy link
Owner

@gusdan gusdan left a comment

Choose a reason for hiding this comment

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

looks good

@gusdan gusdan merged commit 53f127d into gusdan:master Feb 11, 2017
@hectcastro hectcastro deleted the feature/hmc/graceful-degradation branch February 11, 2017 13:38
@hectcastro
Copy link
Contributor Author

Thanks, @gusdan!

matteiuspi pushed a commit to CashStar/django-elasticache that referenced this pull request Mar 19, 2021
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