Skip to content

Commit

Permalink
Use more up-to-date memcached package (release-engineering#60)
Browse files Browse the repository at this point in the history
python-memcached has not beed updated in many years and we now see the
following error appear everywhere in the logs
(linsomniac/python-memcached#176):

    /venv/lib64/python3.9/site-packages/memcache.py:1304: SyntaxWarning: "is" with a literal. Did you mean "=="?
      if key_extra_len is 0:
  • Loading branch information
hluk committed Jul 13, 2022
1 parent b8d5caf commit 7e516f7
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 22 deletions.
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ services:

memcached:
image: "quay.io/factory2/memcached"
ports:
- 11211:11211

resultsdb-listener:
image: greenwave
Expand Down
4 changes: 2 additions & 2 deletions docker/greenwave-settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
"reconnect_attempts_max": 5,
}
CACHE = {
# 'backend': "dogpile.cache.null",
'backend': "dogpile.cache.memcached",
# 'backend': 'dogpile.cache.null',
'backend': 'dogpile.cache.pymemcache',
'expiration_time': 1, # 1 is 1 second, keep to see that memcached
# service is working
'arguments': {
Expand Down
2 changes: 1 addition & 1 deletion functional-tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ def cache_config(tmpdir_factory):
if 'GREENWAVE_TEST_URL' in os.environ:
# This should point to the same cache as the Greenwave server used by tests.
return {
'backend': "dogpile.cache.memcached",
'backend': 'dogpile.cache.pymemcache',
'expiration_time': 300,
'arguments': {
'url': 'memcached:11211',
Expand Down
21 changes: 21 additions & 0 deletions functional-tests/test_cache.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import uuid

from dogpile.cache import make_region

from greenwave.utils import sha1_mangle_key


def test_cache():
cache = make_region(key_mangler=sha1_mangle_key)
cache.configure(
backend='dogpile.cache.pymemcache',
expiration_time=5,
arguments={
'url': 'localhost:11211',
'distributed_lock': True,
},
)
key = uuid.uuid1().hex
assert cache.get(key) is not True
cache.set(key, True)
assert cache.get(key) is True
4 changes: 2 additions & 2 deletions openshift/greenwave-test-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ objects:
WAIVERDB_API_URL = 'http://waiverdb-test-${TEST_ID}-web:8080/api/v1.0'
RESULTSDB_API_URL = 'http://resultsdb-test-${TEST_ID}-internal-api:5001/api/v2.0'
CACHE = {
#'backend': "dogpile.cache.null",
'backend': "dogpile.cache.memcached",
#'backend': 'dogpile.cache.null',
'backend': 'dogpile.cache.pymemcache',
'expiration_time': 1, # 1 is 1 second, keep to see that memcached
# service is working
'arguments': {
Expand Down
29 changes: 13 additions & 16 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ PyYAML = "^6.0"
"dogpile.cache" = "^1.1.4"
flask = "^2.1.2"
gunicorn = "^20.1.0"
python-memcached = "^1.59"
requests = "^2.28.1"
python-dateutil = "^2.8.2"
fedora-messaging = "^2.1.0"
Expand All @@ -46,6 +45,7 @@ psycopg2-binary = {version = "^2.9.3", optional = true}
sphinx = {version = "^5.0.2", optional = true}
sphinxcontrib-httpdomain = {version = "^1.8.0", optional = true}
statsd = "^3.3.0"
pymemcache = "^3.5.2"

[tool.poetry.extras]
test = [
Expand Down

0 comments on commit 7e516f7

Please sign in to comment.