Skip to content

Commit

Permalink
[BugFix] Fix FE proxy will fail when FE external service is recreated (
Browse files Browse the repository at this point in the history
…#557)

Signed-off-by: yandongxiao <[email protected]>
  • Loading branch information
yandongxiao authored Jun 26, 2024
1 parent 6195e7e commit 3e26a71
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ run:
timeout: 5m
skip-files:
- ".*_test\\.go"
- pkg/subcontrollers/feproxy/feproxy_configmap.go
skip-dirs:
- test/testdata_etc # test files
- internal/cache # extracted from Go code
Expand Down
14 changes: 9 additions & 5 deletions pkg/subcontrollers/feproxy/feproxy_configmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func (controller *FeProxyController) SyncConfigMap(ctx context.Context, src *sra

feSearchServiceName := service.SearchServiceName(src.Name, feSpec)
feExternalServiceName := service.ExternalServiceName(src.Name, feSpec)
proxyPass := fmt.Sprintf("http://%s:%d", feExternalServiceName, httpPort)
proxyPass := fmt.Sprintf("http://%s.%s.%s:%d", feExternalServiceName, src.GetNamespace(), "svc.cluster.local", httpPort)

resolver := feProxySpec.Resolver
if resolver == "" {
Expand Down Expand Up @@ -72,7 +72,7 @@ http {
server {
listen 8080;
resolver %[1]s;
resolver %[1]s valid=10s;
proxy_intercept_errors on;
recursive_error_pages on;
Expand All @@ -82,7 +82,9 @@ http {
}
location / {
proxy_pass %[2]s;
# see https://serverfault.com/questions/240476/how-to-force-nginx-to-resolve-dns-of-a-dynamic-hostname-everytime-when-doing-p/593003#593003 for why we use set
set $fe_service "%[2]s";
proxy_pass $fe_service;
proxy_set_header Expect $http_expect;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
Expand All @@ -91,7 +93,8 @@ http {
}
location /api/transaction/load {
proxy_pass %[2]s;
set $fe_service "%[2]s";
proxy_pass $fe_service;
proxy_pass_request_body off;
proxy_set_header Expect $http_expect;
proxy_set_header Host $host;
Expand All @@ -101,7 +104,8 @@ http {
}
location ~ ^/api/.*/.*/_stream_load$ {
proxy_pass %[2]s;
set $fe_service "%[2]s";
proxy_pass $fe_service;
proxy_pass_request_body off;
proxy_set_header Expect $http_expect;
proxy_set_header Host $host;
Expand Down

0 comments on commit 3e26a71

Please sign in to comment.