From 93c2c5661210fb91434cd1e27f4bb6a28168f693 Mon Sep 17 00:00:00 2001 From: Rick Elrod Date: Sun, 11 Dec 2022 01:36:34 -0600 Subject: [PATCH] [wsrelay] Copy the message payload before we relay We internally manipulate the message payload a bit (to know whether we are originating it on the task side or the web system is originating it). But when we get the message, we actually get a reference to the dict containing the payload. Other producers in wsrelay might still be acting on the message and deciding whether or not to relay it. So we need to manipulate and send a *copy* of the message, and leave the original alone. Signed-off-by: Rick Elrod --- awx/main/wsrelay.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/awx/main/wsrelay.py b/awx/main/wsrelay.py index 29d6218a93..38f5f6ddbf 100644 --- a/awx/main/wsrelay.py +++ b/awx/main/wsrelay.py @@ -161,6 +161,11 @@ class WebsocketRelayConnection: # the message along. The web instance will add it back to the same channels group, # but it won't have needs_relay=True, so we'll ignore it. continue + + # We need to copy the message because we're going to delete the needs_relay key + # and we don't want to modify the original message because other producers may + # still need to act on it. It seems weird, but it's necessary. + msg = dict(msg) del msg["needs_relay"] except asyncio.TimeoutError: current_subscriptions = self.producers[name]["subscriptions"]