Skip to content

Commit

Permalink
DEBUG
Browse files Browse the repository at this point in the history
Signed-off-by: Tom Pantelis <tompantelis@gmail.com>
  • Loading branch information
tpantelis committed Dec 5, 2024
1 parent 65e510d commit 66b876b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ jobs:
- name: Check out the mcs-api repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
with:
ref: 99db3af0a467136b9d1d2f19b13db0b78adac6d1
repository: kubernetes-sigs/mcs-api
ref: 3c4ee071514345f07ae2a9846a09e1a9563bcd55
repository: tpantelis/mcs-api
path: mcs-api

- name: Deploy Submariner with clusterset IP enabled
Expand Down
16 changes: 11 additions & 5 deletions coredns/plugin/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,21 @@ import (
"github.com/coredns/coredns/plugin"
"github.com/coredns/coredns/request"
"github.com/miekg/dns"
logw "github.com/submariner-io/admiral/pkg/log"
logf "sigs.k8s.io/controller-runtime/pkg/log"
)

const PluginName = "lighthouse"

var logger = logw.Logger{Logger: logf.Log.WithName("Plugin")}

// ServeDNS implements the plugin.Handler interface.
func (lh *Lighthouse) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error) {
state := &request.Request{W: w, Req: r}
qname := state.QName()

logger.Infof("Request received for %q", qname)

log.Debugf("Request received for %q", qname)

// qname: mysvc.default.svc.example.org.
Expand Down Expand Up @@ -69,12 +75,12 @@ func (lh *Lighthouse) getDNSRecord(ctx context.Context, zone string, state *requ
) (int, error) {
dnsRecords, isHeadless, found := lh.Resolver.GetDNSRecords(pReq.namespace, pReq.service, pReq.cluster, pReq.hostname)
if !found {
log.Debugf("No record found for %q", state.QName())
logger.Infof("No record found for %q", state.QName())
return lh.nextOrFailure(ctx, state, r, dns.RcodeNameError)
}

if len(dnsRecords) == 0 {
log.Debugf("Couldn't find a connected cluster or valid IPs for %q", state.QName())
logger.Infof("Couldn't find a connected cluster or valid IPs for %q", state.QName())
return lh.emptyResponse(state)
}

Expand All @@ -98,7 +104,7 @@ func (lh *Lighthouse) getDNSRecord(ctx context.Context, zone string, state *requ
}

if len(records) == 0 {
log.Debugf("Couldn't find a connected cluster or valid record for %q", state.QName())
logger.Infof("Couldn't find a connected cluster or valid record for %q", state.QName())
return lh.emptyResponse(state)
}

Expand All @@ -108,12 +114,12 @@ func (lh *Lighthouse) getDNSRecord(ctx context.Context, zone string, state *requ
a.SetReply(r)
a.Authoritative = true
a.Answer = append(a.Answer, records...)
log.Debugf("Responding to query with '%s'", a.Answer)
logger.Infof("Responding to query with '%s'", a.Answer)

wErr := w.WriteMsg(a)
if wErr != nil {
// Error writing reply msg
log.Errorf("Failed to write message %#v: %v", a, wErr)
logger.Errorf(wErr, "Failed to write message %#v", a)
return dns.RcodeServerFailure, lh.error("failed to write response")
}

Expand Down

0 comments on commit 66b876b

Please sign in to comment.