multicluster icon indicating copy to clipboard operation
multicluster copied to clipboard

Zones cannot match qname

Open zishen opened this issue 2 years ago • 2 comments

When I use multiycluster, and I andd a serviceImport, I found it cannot reslove the domain name. And I had a doubt:

the code is following,and I add some log:

func (m MultiCluster) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error) {
	state := request.Request{W: w, Req: r}

	qname := state.QName()

	zone := plugin.Zones(m.Zones).Matches(qname)
	log.Warningf("haha===ServeDNS qname:%+v,m.Zones:%+v", qname, m.Zones)
	log.Warningf("haha===ServeDNS CompareDomainName:%+v,CountLabel:%+v", dns.CompareDomainName("cluster.local.", qname), dns.CountLabel("cluster.local."))
	log.Warningf("haha===ServeDNS dns.Msg:r(%+v)", r)
	log.Warningf("haha===ServeDNS state: %+v", state.Req)
	if zone == "" {
		return plugin.NextOrFailure(m.Name(), m.Next, ctx, w, r)
	}
	zone = qname[len(qname)-len(zone):] // maintain case of original query
....

And the logs are:

[WARNING] plugin/multicluster: haha===ServeDNS zone:cluster.local
[WARNING] plugin/multicluster: haha===ServeDNS qname:3629697582728363839.1269917840174598765.,m.Zones:[cluster.local.]
[WARNING] plugin/multicluster: haha===ServeDNS CompareDomainName:0,CountLabel:2
[WARNING] plugin/multicluster: haha===ServeDNS dns.Msg:r(;; opcode: QUERY, status: NOERROR, id: 21087
;; flags: rd; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;3629697582728363839.1269917840174598765.	IN	 HINFO
)

I'm confused about why qname is "3629697582728363839.1269917840174598765", not like "cluster.local"?

version: k8s v1.26, coredns v1.9.3

zishen avatar Jun 21 '23 09:06 zishen

@runakash can you take a look?

zishen avatar Jun 21 '23 09:06 zishen

Looks like you're logging the address to the struct.

runakash avatar Jul 13 '23 10:07 runakash