Skip to content

Commit

Permalink
Remove metadata from dnsContextClient
Browse files Browse the repository at this point in the history
Signed-off-by: Artem Glazychev <artem.glazychev@xored.com>
  • Loading branch information
glazychev-art committed Aug 15, 2022
1 parent 990b341 commit ea52546
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions pkg/networkservice/connectioncontext/dnscontext/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit ea52546

Please sign in to comment.