Skip to content

Commit

Permalink
fix(kuma-cp) retry to resolve the service name by splitting it
Browse files Browse the repository at this point in the history
Signed-off-by: Nikolay Nikolaev <nikolay.nikolaev@konghq.com>
  • Loading branch information
Nikolay Nikolaev committed Jun 17, 2020
1 parent 85c4a72 commit 3bea89e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
3 changes: 2 additions & 1 deletion pkg/dns-server/resolver/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ func (d *SimpleDNSResolver) SyncServices(services map[string]bool) (errs error)
errs = multierr.Append(errs, errors.Wrapf(err, "unable to allocate an ip for service %s", service))
} else {
d.viplist[service] = ip
simpleDNSLog.Info("Adding ", "service", service, "ip", ip)
}
}
}
Expand Down Expand Up @@ -212,7 +213,7 @@ func (d *SimpleDNSResolver) domainFromName(name string) (string, error) {

func (d *SimpleDNSResolver) serviceFromName(name string) (string, error) {
split := dns.SplitDomainName(name)
if len(split) < 2 {
if len(split) < 1 {
return "", errors.Errorf("wrong DNS name: %s", name)
}

Expand Down
8 changes: 7 additions & 1 deletion pkg/xds/topology/vip_outbounds.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package topology
import (
"github.com/pkg/errors"
"go.uber.org/multierr"
"strings"

mesh_proto "github.com/Kong/kuma/api/mesh/v1alpha1"
mesh_core "github.com/Kong/kuma/pkg/core/resources/apis/mesh"
Expand All @@ -24,7 +25,12 @@ func PatchDataplaneWithVIPOutbounds(dataplane *mesh_core.DataplaneResource,

vip, err := resolver.ForwardLookup(inService)
if err != nil {
errs = multierr.Append(errs, errors.Wrapf(err, "unable to resolve %s", inService))
// try to get the first part of the FQDN service and look it up
split := strings.Split(inService,".")
vip, err = resolver.ForwardLookup(split[0])
if err!=nil {
errs = multierr.Append(errs, errors.Wrapf(err, "unable to resolve %s", inService))
}
}
serviceVIPMap[inService] = vip
}
Expand Down

0 comments on commit 3bea89e

Please sign in to comment.