From ea525467285d083600d49394535b895c8376b043 Mon Sep 17 00:00:00 2001 From: Artem Glazychev Date: Mon, 15 Aug 2022 20:30:37 +0700 Subject: [PATCH] Remove metadata from dnsContextClient Signed-off-by: Artem Glazychev --- .../connectioncontext/dnscontext/client.go | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/pkg/networkservice/connectioncontext/dnscontext/client.go b/pkg/networkservice/connectioncontext/dnscontext/client.go index eee42d636..c8841613a 100644 --- a/pkg/networkservice/connectioncontext/dnscontext/client.go +++ b/pkg/networkservice/connectioncontext/dnscontext/client.go @@ -28,15 +28,11 @@ import ( "google.golang.org/grpc" "github.com/networkservicemesh/sdk/pkg/networkservice/core/next" - "github.com/networkservicemesh/sdk/pkg/networkservice/utils/metadata" "github.com/networkservicemesh/sdk/pkg/tools/dnsconfig" + "github.com/networkservicemesh/sdk/pkg/tools/dnsutils" "github.com/networkservicemesh/sdk/pkg/tools/log" ) -const ( - dnsContextClientRefreshKey = "dnsContextClientRefreshKey" -) - type dnsContextClient struct { chainContext context.Context resolveConfigPath string @@ -76,8 +72,9 @@ func (c *dnsContextClient) Request(ctx context.Context, request *networkservice. request.Connection.Context.DnsContext = &networkservice.DNSContext{} } - initialClientDNSConfigs, _ := metadata.Map(ctx, true).LoadOrStore(dnsContextClientRefreshKey, request.Connection.Context.DnsContext.Configs) - request.Connection.Context.DnsContext.Configs = append(initialClientDNSConfigs.([]*networkservice.DNSConfig), c.resolvconfDNSConfig) + if !dnsutils.ContainsDNSConfig(request.GetConnection().GetContext().GetDnsContext().Configs, c.resolvconfDNSConfig) { + request.GetConnection().GetContext().GetDnsContext().Configs = append(request.GetConnection().GetContext().GetDnsContext().Configs, c.resolvconfDNSConfig) + } rv, err := next.Client(ctx).Request(ctx, request, opts...) if err != nil {