Skip to content

Support health-check, add local first mode in swarm#51

Merged
mesudip merged 11 commits into
masterfrom
dev
May 25, 2026
Merged

Support health-check, add local first mode in swarm#51
mesudip merged 11 commits into
masterfrom
dev

Conversation

@mesudip
Copy link
Copy Markdown
Owner

@mesudip mesudip commented May 22, 2026

No description provided.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request significantly enhances Docker Swarm integration and container lifecycle management. Key additions include a new prefer-local swarm mode that prioritizes local task containers over service VIPs, support for Docker healthchecks to gate backend registration, and a configurable BACKEND_START_GRACE_SECONDS to prevent premature reloads for starting containers. Additionally, the StickySessionProcessor has been replaced by a more comprehensive UpstreamProcessor. Feedback identifies a high-severity issue in WebServer.py where an optimization that skips updates for existing container backends prevents the proxy from detecting dynamic changes, such as a container connecting to a new network after its initial start.

Comment thread nginx_proxy/WebServer.py
Comment on lines +304 to +306
existing_backend = self.config_data.has_backend(backend.id)
if existing_backend and backend.type != "service":
return False
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The optimization that skips updates for existing container backends prevents the proxy from picking up dynamic changes, such as a container connecting to a new network after it has already started. Since DockerEventListener calls update_backend specifically when such events occur, this check causes those updates to be ignored for containers. It is recommended to allow updates for all backend types to ensure the configuration remains in sync with the Docker state, especially since the Throttler and Nginx configuration comparison already handle performance concerns efficiently.

Suggested change
existing_backend = self.config_data.has_backend(backend.id)
if existing_backend and backend.type != "service":
return False
existing_backend = self.config_data.has_backend(backend.id)

@codecov
Copy link
Copy Markdown

codecov Bot commented May 22, 2026

Codecov Report

❌ Patch coverage is 73.53846% with 172 lines in your changes missing coverage. Please review.
✅ Project coverage is 66.06%. Comparing base (97c3b66) to head (abda739).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
nginx_proxy/DockerEventListener.py 72.04% 77 Missing and 27 partials ⚠️
nginx_proxy/WebServer.py 75.63% 20 Missing and 9 partials ⚠️
nginx_proxy/post_processors/upstream_processor.py 81.48% 8 Missing and 2 partials ⚠️
nginx_proxy/NginxProxyApp.py 50.00% 7 Missing and 1 partial ⚠️
...inx_proxy/pre_processors/virtual_host_processor.py 76.66% 6 Missing and 1 partial ⚠️
nginx_proxy/pre_processors/redirect_processor.py 77.77% 3 Missing and 3 partials ⚠️
nginx/Nginx.py 0.00% 4 Missing ⚠️
nginx/Url.py 50.00% 1 Missing and 2 partials ⚠️
nginx_proxy/Throttler.py 90.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master      #51      +/-   ##
==========================================
+ Coverage   61.32%   66.06%   +4.73%     
==========================================
  Files          30       30              
  Lines        2384     2879     +495     
  Branches      382      463      +81     
==========================================
+ Hits         1462     1902     +440     
- Misses        829      848      +19     
- Partials       93      129      +36     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

)

assert "bad_source.example.com" not in vhost_map
assert "valid-source.example.com" in vhost_map
@mesudip
Copy link
Copy Markdown
Owner Author

mesudip commented May 24, 2026

/gemini help

@gemini-code-assist
Copy link
Copy Markdown

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

@mesudip
Copy link
Copy Markdown
Owner Author

mesudip commented May 24, 2026

/gemini review

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces significant enhancements to Docker Swarm support, most notably a new prefer-local discovery mode that prioritizes healthy local task containers and utilizes the service VIP as a fallback. The internal architecture is refactored to use a thread-safe command queue and dispatcher for Docker events, which now includes support for container healthchecks and a configurable startup grace period to improve reliability. Additionally, the PR adds a dedicated reload mechanism via SIGHUP, improves hostname validation, and includes extensive integration tests for these new features. Feedback was provided regarding the dispatcher's error handling to ensure that termination signals lead to a graceful shutdown rather than just killing the daemon thread.

Comment on lines +152 to +153
except (KeyboardInterrupt, SystemExit):
raise
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Raising KeyboardInterrupt or SystemExit inside a daemon thread will not terminate the main process; it will only kill the dispatcher thread. This could leave the application in a broken state where events are enqueued but never processed. It is better to log the termination and rely on the _STOP sentinel for graceful shutdown.

@mesudip mesudip merged commit 377a95d into master May 25, 2026
7 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants