From b0b29da388b6085bf2248a8e6e44df1188a7146a Mon Sep 17 00:00:00 2001 From: Ta-Ching Chen Date: Fri, 12 Jul 2019 09:16:10 +0800 Subject: [PATCH] Replace localhost with 127.0.0.1 to prevent DNS resolving problem (#1227) --- pkg/fetcher/fetcher.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pkg/fetcher/fetcher.go b/pkg/fetcher/fetcher.go index ee355237..d2755c99 100644 --- a/pkg/fetcher/fetcher.go +++ b/pkg/fetcher/fetcher.go @@ -615,14 +615,17 @@ func (fetcher *Fetcher) SpecializePod(ctx context.Context, fetchReq types.Functi return errors.Wrap(err, "error encoding load request") } + // Instead of using "localhost", here we use "127.0.0.1" for + // inter-pod communication to prevent wrongly record returned from DNS. + if loadReq.EnvVersion >= 2 { contentType = "application/json" - specializeURL = "http://localhost:8888/v2/specialize" + specializeURL = "http://127.0.0.1:8888/v2/specialize" reader = bytes.NewReader(loadPayload) fetcher.logger.Info("calling environment v2 specialization endpoint") } else { contentType = "text/plain" - specializeURL = "http://localhost:8888/specialize" + specializeURL = "http://127.0.0.1:8888/specialize" reader = bytes.NewReader([]byte{}) fetcher.logger.Info("calling environment v1 specialization endpoint") }