From 66b876b1f4ff8240ec5124de4f247fab5a6480e7 Mon Sep 17 00:00:00 2001 From: Tom Pantelis Date: Thu, 5 Dec 2024 12:07:21 -0500 Subject: [PATCH] DEBUG Signed-off-by: Tom Pantelis --- .github/workflows/e2e.yml | 4 ++-- coredns/plugin/handler.go | 16 +++++++++++----- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index d86ef9fb..ec4d02c2 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -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 diff --git a/coredns/plugin/handler.go b/coredns/plugin/handler.go index 056a41b4..53f9c577 100644 --- a/coredns/plugin/handler.go +++ b/coredns/plugin/handler.go @@ -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. @@ -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) } @@ -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) } @@ -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") }