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.
This commit is contained in:
Jeff Bradberry 2024-01-24 15:10:07 -05:00 committed by Seth Foster
parent 1b44bebed3
commit 1e254c804c

View File

@ -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)