This repository was archived by the owner on Apr 26, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Fix up healthcheck generation for workers docker image #12405
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Fix up healthcheck generation for workers docker image. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -308,7 +308,7 @@ def generate_worker_files(environ, config_path: str, data_dir: str): | |
|
||
Args: | ||
environ: _Environ[str] | ||
config_path: Where to output the generated Synapse main worker config file. | ||
config_path: The location of the generated Synapse main worker config file. | ||
data_dir: The location of the synapse data directory. Where log and | ||
user-facing config files live. | ||
""" | ||
|
@@ -321,7 +321,8 @@ def generate_worker_files(environ, config_path: str, data_dir: str): | |
# and adding a replication listener. | ||
|
||
# First read the original config file and extract the listeners block. Then we'll add | ||
# another listener for replication. Later we'll write out the result. | ||
# another listener for replication. Later we'll write out the result to the shared | ||
# config file. | ||
listeners = [ | ||
{ | ||
"port": 9093, | ||
|
@@ -387,6 +388,10 @@ def generate_worker_files(environ, config_path: str, data_dir: str): | |
# worker_type + instance # | ||
worker_type_counter: Dict[str, int] = {} | ||
|
||
# A list of internal endpoints to healthcheck, starting with the main process | ||
# which exists even if no workers do. | ||
healthcheck_urls = ["http://localhost:8080/health"] | ||
|
||
# For each worker type specified by the user, create config values | ||
for worker_type in worker_types: | ||
worker_type = worker_type.strip() | ||
|
@@ -411,6 +416,8 @@ def generate_worker_files(environ, config_path: str, data_dir: str): | |
# Update the shared config with any worker-type specific options | ||
shared_config.update(worker_config["shared_extra_conf"]) | ||
|
||
healthcheck_urls.append("http://localhost:%d/health" % (worker_port,)) | ||
|
||
# Check if more than one instance of this worker type has been specified | ||
worker_type_total_count = worker_types.count(worker_type) | ||
if worker_type_total_count > 1: | ||
|
@@ -476,15 +483,10 @@ def generate_worker_files(environ, config_path: str, data_dir: str): | |
# Determine the load-balancing upstreams to configure | ||
nginx_upstream_config = "" | ||
|
||
# At the same time, prepare a list of internal endpoints to healthcheck | ||
# starting with the main process which exists even if no workers do. | ||
healthcheck_urls = ["http://localhost:8080/health"] | ||
|
||
for upstream_worker_type, upstream_worker_ports in nginx_upstreams.items(): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nginx_upstreams is only populated when there is more than one worker of a given type configured. |
||
body = "" | ||
for port in upstream_worker_ports: | ||
body += " server localhost:%d;\n" % (port,) | ||
healthcheck_urls.append("http://localhost:%d/health" % (port,)) | ||
|
||
# Add to the list of configured upstreams | ||
nginx_upstream_config += NGINX_UPSTREAM_CONFIG_BLOCK.format( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just a driveby while Im in the area, for the same reason as #11997.