Skip to content

Commit

Permalink
Template the listener protocol into the receptor install bundle (#14792)
Browse files Browse the repository at this point in the history
Previously we were hard-coding tcp, now we need to also support ws/wss.
  • Loading branch information
jbradberry authored and fosterseth committed Feb 1, 2024
1 parent cd61745 commit e999509
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
4 changes: 2 additions & 2 deletions awx/api/templates/instance_install_bundle/group_vars/all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ custom_tls_certfile: receptor/tls/receptor.crt
custom_tls_keyfile: receptor/tls/receptor.key
custom_ca_certfile: receptor/tls/ca/mesh-CA.crt
{% if listener_port %}
receptor_protocol: tcp
receptor_protocol: {{ listener_protocol }}
receptor_listener: true
receptor_port: {{ listener_port }}
{% else %}
Expand All @@ -28,7 +28,7 @@ receptor_listener: false
receptor_peers:
{% for peer in peers %}
- address: {{ peer.address }}
protocol: {{ peer.protocol}}
protocol: {{ peer.protocol }}
{% endfor %}
{% endif %}
{% verbatim %}
Expand Down
7 changes: 4 additions & 3 deletions awx/api/views/instance_install_bundle.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,10 @@ def generate_group_vars_all_yml(instance_obj):
peers.append(dict(address=addr.get_full_address(), protocol=addr.protocol))
context = dict(instance=instance_obj, peers=peers)

listener_port = instance_obj.canonical_address_port
if listener_port:
context['listener_port'] = listener_port
canonical_addr = instance_obj.canonical_address
if canonical_addr:
context['listener_port'] = canonical_addr.port
context['listener_protocol'] = canonical_addr.protocol

all_yaml = render_to_string("instance_install_bundle/group_vars/all.yml", context=context)
# convert consecutive newlines with a single newline
Expand Down
4 changes: 4 additions & 0 deletions awx/main/models/ha.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,10 @@ def health_check_pending(self):
return True
return self.health_check_started > self.last_health_check

@property
def canonical_address(self):
return self.receptor_addresses.filter(canonical=True).first()

@property
def canonical_address_port(self):
# note: don't create a different query for receptor addresses, as this is prefetched on the View for optimization
Expand Down

0 comments on commit e999509

Please sign in to comment.