From 1e254c804cc8d543dc751de567f5d38bc6a67c27 Mon Sep 17 00:00:00 2001 From: Jeff Bradberry Date: Wed, 24 Jan 2024 15:10:07 -0500 Subject: [PATCH] The listener port cannot be disabled when setting peers_from_control_nodes If the port is explicitly set to null (causing any ReceptorAddress to be deleted), then that's a validation error. If the port is left off but a ReceptorAddress doesn't already exist, we should not infer a port number and that is also a validation error. --- awx/api/serializers.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/awx/api/serializers.py b/awx/api/serializers.py index 5526d9741f..5495e05a4b 100644 --- a/awx/api/serializers.py +++ b/awx/api/serializers.py @@ -5710,7 +5710,8 @@ class InstanceSerializer(BaseSerializer): # cannot enable peers_from_control_nodes if listener_port is not set if attrs.get('peers_from_control_nodes'): - if not attrs.get('listener_port') and self.instance and self.instance.canonical_address_port is None: + port = attrs.get('listener_port', -1) # -1 denotes missing, None denotes explicit null + if (port is None) or (port == -1 and self.instance and self.instance.canonical_address is None): raise serializers.ValidationError(_("Cannot enable peers_from_control_nodes if listener_port is not set.")) return super().validate(attrs)