Skip to content

Commit

Permalink
The listener port cannot be disabled when setting peers_from_control_…
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
jbradberry authored and fosterseth committed Feb 2, 2024
1 parent 1b44beb commit 1e254c8
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion awx/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5710,7 +5710,8 @@ def check_peers_changed():

# 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)
Expand Down

0 comments on commit 1e254c8

Please sign in to comment.