Skip to content

Commit e4bc10a

Browse files
committed
Conditionally include Redis connection information
Redis is only used when cache is enabled or RQ tasking is used. In other cases, the connection is not needed. We've changed the Foreman installer to only install Redis if needed, just to stop wasting resources[1]. However, this leads to warnings. This PR changes the status view to only include Redis if it's used. [1]: theforeman/puppet-pulpcore@7a5543b closes #9070 https://pulp.plan.io/issues/9070
1 parent 0c3b69d commit e4bc10a

File tree

4 files changed

+22
-2
lines changed

4 files changed

+22
-2
lines changed

CHANGES/9070.bugfix

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Remove Redis connection information from status unless it's used, either by RQ
2+
tasking or content caching.

pulpcore/app/serializers/status.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ class StatusSerializer(serializers.Serializer):
7474
help_text=_("Database connection information")
7575
)
7676

77-
redis_connection = RedisConnectionSerializer(help_text=_("Redis connection information"))
77+
redis_connection = RedisConnectionSerializer(
78+
required=False,
79+
help_text=_("Redis connection information"),
80+
)
7881

7982
storage = StorageSerializer(required=False, help_text=_("Storage information"))

pulpcore/app/views/status.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,11 @@ def get(self, request):
5757
for app in pulp_plugin_configs():
5858
versions.append({"component": app.label, "version": app.version})
5959

60-
redis_status = {"connected": self._get_redis_conn_status()}
60+
if settings.CACHE_ENABLED or not settings.USE_NEW_WORKER_TYPE:
61+
redis_status = {"connected": self._get_redis_conn_status()}
62+
else:
63+
redis_status = None
64+
6165
db_status = {"connected": self._get_db_conn_status()}
6266

6367
try:

pulpcore/tests/functional/api/test_status.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""Test the status page."""
22
import unittest
33

4+
from django.test import override_settings
45
from jsonschema import validate
56
from pulp_smash import api, cli, config, utils
67
from pulp_smash.pulp3.constants import STATUS_PATH
@@ -91,10 +92,20 @@ def verify_get_response(self, status):
9192
"""
9293
validate(status, self.status_response)
9394
self.assertTrue(status["database_connection"]["connected"])
95+
self.assertIsNotNone(status["redis_connection"])
9496
self.assertTrue(status["redis_connection"]["connected"])
9597
self.assertNotEqual(status["online_workers"], [])
9698
self.assertNotEqual(status["versions"], [])
9799
if self.storage == "pulpcore.app.models.storage.FileSystem":
98100
self.assertIsNotNone(status["storage"])
99101
else:
100102
self.assertIsNone(status["storage"])
103+
104+
@override_settings(CACHE_ENABLED=False, USE_NEW_WORKER_TYPE=True)
105+
def verify_get_response_without_redis(self, status):
106+
"""Verify the response to an HTTP GET call when Redis is not used.
107+
108+
Verify that redis_connection is null
109+
"""
110+
validate(status, self.status_response)
111+
self.assertIsNone(status["redis_connection"])

0 commit comments

Comments
 (0)