diff --git a/pkg/networkservice/chains/nsmgr/vl3_test.go b/pkg/networkservice/chains/nsmgr/vl3_test.go index d5a43d019..4c6a44831 100644 --- a/pkg/networkservice/chains/nsmgr/vl3_test.go +++ b/pkg/networkservice/chains/nsmgr/vl3_test.go @@ -76,11 +76,11 @@ func Test_NSC_ConnectsTo_vl3NSE(t *testing.T) { ctx, nseReg, sandbox.GenerateTestToken, - vl3.NewServer(ctx, serverPrefixCh), vl3dns.NewServer(ctx, dnsServerIPCh, vl3dns.WithDomainSchemes("{{ index .Labels \"podName\" }}.{{ .NetworkService }}."), vl3dns.WithDNSPort(40053)), + vl3.NewServer(ctx, serverPrefixCh), ) resolver := net.Resolver{ @@ -163,7 +163,6 @@ func Test_vl3NSE_ConnectsTo_vl3NSE(t *testing.T) { ctx, nseReg, sandbox.GenerateTestToken, - vl3.NewServer(ctx, serverPrefixCh), vl3dns.NewServer(ctx, dnsServerIPCh, vl3dns.WithDomainSchemes("{{ index .Labels \"podName\" }}.{{ .NetworkService }}."), @@ -173,6 +172,7 @@ func Test_vl3NSE_ConnectsTo_vl3NSE(t *testing.T) { vl3dns.WithConfigs(dnsConfigs), vl3dns.WithDNSPort(40053), ), + vl3.NewServer(ctx, serverPrefixCh), ) resolver := net.Resolver{ @@ -252,11 +252,11 @@ func Test_NSC_GetsVl3DnsAddressDelay(t *testing.T) { ctx, nseReg, sandbox.GenerateTestToken, - vl3.NewServer(ctx, serverPrefixCh), vl3dns.NewServer(ctx, dnsServerIPCh, vl3dns.WithDomainSchemes("{{ index .Labels \"podName\" }}.{{ .NetworkService }}."), - vl3dns.WithDNSPort(40053))) + vl3dns.WithDNSPort(40053)), + vl3.NewServer(ctx, serverPrefixCh)) nsc := domain.Nodes[0].NewClient(ctx, sandbox.GenerateTestToken) @@ -300,10 +300,10 @@ func Test_vl3NSE_ConnectsTo_Itself(t *testing.T) { ctx, nseReg, sandbox.GenerateTestToken, - vl3.NewServer(ctx, serverPrefixCh), vl3dns.NewServer(ctx, dnsServerIPCh, - vl3dns.WithDNSPort(40053))) + vl3dns.WithDNSPort(40053)), + vl3.NewServer(ctx, serverPrefixCh)) // Connection to itself. This allows us to assign a dns address to ourselves. nsc := domain.Nodes[0].NewClient(ctx, sandbox.GenerateTestToken, client.WithName(nseReg.Name)) diff --git a/pkg/networkservice/connectioncontext/dnscontext/vl3dns/server.go b/pkg/networkservice/connectioncontext/dnscontext/vl3dns/server.go index 5581c0dca..fa9de720e 100644 --- a/pkg/networkservice/connectioncontext/dnscontext/vl3dns/server.go +++ b/pkg/networkservice/connectioncontext/dnscontext/vl3dns/server.go @@ -128,17 +128,16 @@ func (n *vl3DNSServer) Request(ctx context.Context, request *networkservice.Netw } } - ips := getSrcIPs(request.GetConnection()) - if len(ips) > 0 { - for _, recordName := range recordNames { - n.dnsServerRecords.Store(recordName, ips) - } - - metadata.Map(ctx, false).Store(clientDNSNameKey{}, recordNames) - } - resp, err := next.Server(ctx).Request(ctx, request) if err == nil { + ips := getSrcIPs(resp) + if len(ips) > 0 { + for _, recordName := range recordNames { + n.dnsServerRecords.Store(recordName, ips) + } + + metadata.Map(ctx, false).Store(clientDNSNameKey{}, recordNames) + } configs := make([]*networkservice.DNSConfig, 0) if srcRoutes := resp.GetContext().GetIpContext().GetSrcRoutes(); len(srcRoutes) > 0 { var lastPrefix = srcRoutes[len(srcRoutes)-1].Prefix