fix(cubeproxy): configure resolver for Redis hostnames#714
Conversation
50c0b7d to
77d4ae3
Compare
77d4ae3 to
e2b7687
Compare
|
Since CubeProxy is a container using the host network, I was wondering whether configuring the resolver inside this container to point to its own |
I do not think CubeProxy can rely on For OpenResty cosocket hostname resolution, nginx still needs an explicit References:
So I think there are two viable ways to provide the resolver addresses:
I kept the current one-click render-time approach because it is narrower and fails earlier/clearer when Redis is configured by hostname but no usable resolver can be found. |
I consider it is better for the cube proxy to use the container's resolv.conf. because in production deployment, cube proxy usually runs on k8s, which do not use the one-click deploy.sh |
That makes sense to me. I'll rework this PR toward the container-based approach. |
005058d to
e2b7687
Compare
Review: PR #714 — fix(cubeproxy): configure resolver for Redis hostnamesOverall: Well-structured PR with thorough test coverage. The resolver discovery logic is correctly scoped, input validation is strict (IPv4-only nameservers, atomic file writes), and error messages are actionable. A few areas for improvement below. Inline Comments Posted
Additional ObservationsCode Quality:
Test Coverage:
Security:
Performance:
Documentation:
Summary
|
e2b7687 to
a81f0c2
Compare
|
@fslongjin I've reworked the PR to use the container-side approach. CubeProxy now ships This removes the one-click-only host rendering path, so the same CubeProxy startup behavior applies to one-click, k8s-style, and manual Docker deployments. The fail-fast behavior is still kept when Redis is configured by hostname but no usable resolver can be found. I also validated the container-side rendering path and updated the one-click tests for the new flow. |
a81f0c2 to
1d8c520
Compare
chenhengqi
left a comment
There was a problem hiding this comment.
Let's focus on the resolver-related change and keep the diff minimal. Please drop other changes, they can be in a separate PR.
1d8c520 to
73eb271
Compare
|
@chenhengqi I re-scoped the PR to focus only on the resolver-related change. The updated version keeps the container-side I also dropped the unrelated helper cleanup, docs, and shell hardening changes. Those can be handled separately if still needed. |
73eb271 to
9da4847
Compare
9da4847 to
876d283
Compare
Add a CubeProxy nginx resolver include generated at container startup. OpenResty Lua cosocket hostname resolution requires an explicit nginx resolver directive, so reading /etc/resolv.conf alone is not enough when CubeProxy connects to Redis by hostname. start.sh updates conf/includes/resolver.inc based on the Redis target. If Redis is configured by hostname, it derives IPv4 nameservers from the container's /etc/resolv.conf and writes nginx resolver directives. If no usable resolver can be derived for that hostname, startup fails fast with a clear error. Redis IP literals leave the include as a no-op. Keep the change focused on Redis hostname resolution without reworking the wider one-click nginx rendering flow. Signed-off-by: zhengyilei <zheng_yilei@qq.com>
876d283 to
e91c8f2
Compare
Motivation
When CubeProxy connects to Redis by hostname, OpenResty Lua can fail with:
NGINX/OpenResty requires an explicit
resolverdirective for Lua cosocket hostname resolution. Reading/etc/resolv.confis not enough by itself, because nginx expects concrete resolver addresses innginx.conf.Following the review feedback, this PR keeps the fix focused on the resolver path itself. CubeProxy now derives a small nginx resolver include from the container runtime environment, instead of relying on a one-click-specific host-side resolver workaround or rendering the full nginx config inside the container.
What Changed
This PR makes CubeProxy prepare only the resolver include at container startup:
conf/includes/resolver.incinclude hook toCubeProxy/nginx.confCubeProxy/start.shto:CUBE_PROXY_REDIS_IPor the mountedglobal.conf/etc/resolv.confwhen Redis is configured by hostnameresolver ... ipv6=off valid=30s;andresolver_timeout 5s;intoresolver.incdeploy/one-click/tests/test_install_mode.shThe one-click test update is limited to the existing path that supplies CubeProxy runtime config. This PR does not rework the broader one-click nginx rendering flow.
Validation
bash tests/test_install_mode.sh.resolver ...; resolver_timeout 5s;start.shrendersconf/includes/resolver.inccorrectly andnginx -tsucceeds.Scope
This PR fixes Redis hostname resolution through CubeProxy's nginx/OpenResty resolver configuration.
It intentionally does not change: