mirror of
https://github.com/ansible/awx.git
synced 2026-02-21 13:10:11 -03:30
Only create receptor address if port is defined
If a Instance endpoint is patched with
{"peers_from_control_nodes" True}
but a listener_port is not defined on the instance,
or is part of the patch payload, do not create a
receptor address.
Only update or create a receptor address if listener_port
is set, either in the payload or already on the instance.
Signed-off-by: Seth Foster <fosterbseth@gmail.com>
This commit is contained in:
@@ -5609,10 +5609,14 @@ class InstanceSerializer(BaseSerializer):
|
||||
else:
|
||||
instance = super(InstanceSerializer, self).update(obj, validated_data)
|
||||
|
||||
# delete the receptor address if the port is expolisitly set to None
|
||||
if 'port' in kwargs and not kwargs['port']:
|
||||
# delete the receptor address if the port is expolisitly set to None
|
||||
instance.receptor_addresses.filter(address=instance.hostname).delete()
|
||||
elif 'port' in kwargs:
|
||||
# only create or update if port is defined in validated_data or already exists in the
|
||||
# canonical address
|
||||
# this prevents creating a receptor address if peers_from_control_nodes is in
|
||||
# validated_data but a port is not set
|
||||
elif kwargs and ('port' in kwargs or instance.canonical_address_port):
|
||||
kwargs['canonical'] = True
|
||||
instance.receptor_addresses.update_or_create(address=instance.hostname, defaults=kwargs)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user