Skip to content

Commit daa1693

Browse files
fix: ensure rulebook_queue_name is not sanitized outside dispatcherd flag (#1351)
We have found a bug where the installers set a rulebook queue_name longer than 63 chars, a limit imposed for pg_notify (dispatcherd feature flag). This was set at the initialization of settings, where we can not check yet the status of the flag. This PR ensure the queue name is not sanitized for pg_notify when the feature flag is not enabled. [Jira: AAP-48235](https://issues.redhat.com/browse/AAP-48235) Signed-off-by: Alex <[email protected]>
1 parent f82dabc commit daa1693

File tree

2 files changed

+21
-17
lines changed

2 files changed

+21
-17
lines changed

src/aap_eda/core/management/commands/rqworker.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
from django.core.management.base import BaseCommand, CommandParser
2323
from django_rq.management.commands import rqworker
2424

25+
from aap_eda import utils
2526
from aap_eda.settings import features
2627

2728
logger = logging.getLogger(__name__)
@@ -55,8 +56,27 @@ def _handle_dispatcherd(self, *args, **options) -> None:
5556

5657
# Use rqworker expected args to determine worker type
5758
if "ActivationWorker" in options["worker_class"]:
59+
# dispatcherd worker settings can not be initialized as settings
60+
# because the queue name sanitization must happen
61+
# after the settings are loaded, we can not check the feature flag
62+
# before the settings are loaded.
63+
dispatcher_worker_settings = {
64+
**settings.DISPATCHERD_DEFAULT_SETTINGS,
65+
"brokers": {
66+
"pg_notify": {
67+
**settings.DISPATCHERD_DEFAULT_SETTINGS["brokers"][
68+
"pg_notify"
69+
],
70+
"channels": [
71+
utils.sanitize_postgres_identifier(
72+
settings.RULEBOOK_QUEUE_NAME,
73+
)
74+
],
75+
},
76+
},
77+
}
5878
dispatcherd_setup(
59-
settings.DISPATCHERD_ACTIVATION_WORKER_SETTINGS,
79+
dispatcher_worker_settings,
6080
)
6181

6282
elif "DefaultWorker" in options["worker_class"]:

src/aap_eda/settings/post_load.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -530,22 +530,6 @@ def post_loading(loaded_settings: Dynaconf):
530530
},
531531
}
532532

533-
settings.DISPATCHERD_ACTIVATION_WORKER_SETTINGS = {
534-
**settings.DISPATCHERD_DEFAULT_SETTINGS,
535-
"brokers": {
536-
"pg_notify": {
537-
**settings.DISPATCHERD_DEFAULT_SETTINGS["brokers"][
538-
"pg_notify"
539-
],
540-
"channels": [
541-
utils.sanitize_postgres_identifier(
542-
settings.RULEBOOK_QUEUE_NAME,
543-
)
544-
],
545-
},
546-
},
547-
}
548-
549533
data = {
550534
key: settings[key]
551535
for key in settings

0 commit comments

Comments
 (0)