From e499e768a92251ae4bb5fc1845e9c1925284646a Mon Sep 17 00:00:00 2001 From: Tom Pantelis Date: Fri, 22 Nov 2024 10:13:22 -0500 Subject: [PATCH] DEBUG Signed-off-by: Tom Pantelis --- .github/workflows/e2e.yml | 2 +- coredns/plugin/handler.go | 11 ++++++----- coredns/plugin/record.go | 6 +++++- coredns/plugin/setup.go | 3 +++ 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 4603acf8..5cc84778 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -95,7 +95,7 @@ jobs: export KUBECONFIG=$(find $(git rev-parse --show-toplevel)/output/kubeconfigs/ -type f -printf %p:) cd mcs-api/conformance go test -v -timeout 30m -contexts cluster1,cluster2 -args -test.timeout 15m \ - --ginkgo.v --ginkgo.trace --ginkgo.label-filter "Required || EndpointSlice || DNS" + --ginkgo.v --ginkgo.trace --ginkgo.label-filter "DNS" - name: Print report.html if: always() diff --git a/coredns/plugin/handler.go b/coredns/plugin/handler.go index 056a41b4..fda4de05 100644 --- a/coredns/plugin/handler.go +++ b/coredns/plugin/handler.go @@ -21,6 +21,7 @@ package lighthouse import ( "context" "errors" + "fmt" "github.com/coredns/coredns/plugin" "github.com/coredns/coredns/request" @@ -34,7 +35,7 @@ func (lh *Lighthouse) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns state := &request.Request{W: w, Req: r} qname := state.QName() - log.Debugf("Request received for %q", qname) + fmt.Printf("Request received for %q\n", qname) // qname: mysvc.default.svc.example.org. // zone: example.org. @@ -69,12 +70,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()) + fmt.Printf("No record found for %q\n", 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()) + fmt.Printf("Couldn't find a connected cluster or valid IPs for %q\n", state.QName()) return lh.emptyResponse(state) } @@ -102,13 +103,13 @@ func (lh *Lighthouse) getDNSRecord(ctx context.Context, zone string, state *requ return lh.emptyResponse(state) } - log.Debugf("rr is %v", records) + fmt.Printf("rr is %v\n", records) a := new(dns.Msg) a.SetReply(r) a.Authoritative = true a.Answer = append(a.Answer, records...) - log.Debugf("Responding to query with '%s'", a.Answer) + fmt.Printf("Responding to query with '%s'\n", a.Answer) wErr := w.WriteMsg(a) if wErr != nil { diff --git a/coredns/plugin/record.go b/coredns/plugin/record.go index e7afdcb9..888727bf 100644 --- a/coredns/plugin/record.go +++ b/coredns/plugin/record.go @@ -19,11 +19,13 @@ limitations under the License. package lighthouse import ( + "fmt" "net" "strings" "github.com/coredns/coredns/request" "github.com/miekg/dns" + "github.com/submariner-io/admiral/pkg/resource" "github.com/submariner-io/lighthouse/coredns/resolver" "sigs.k8s.io/mcs-api/pkg/apis/v1alpha1" ) @@ -47,13 +49,15 @@ func (lh *Lighthouse) createSRVRecords(dnsrecords []resolver.DNSRecord, state *r ) []dns.RR { var records []dns.RR + fmt.Printf("createSRVRecords: %s", resource.ToJSON(dnsrecords)) + for _, dnsRecord := range dnsrecords { var reqPorts []v1alpha1.ServicePort if pReq.port == "" { reqPorts = dnsRecord.Ports } else { - log.Debugf("Requested port %q, protocol %q for SRV", pReq.port, pReq.protocol) + fmt.Printf("Requested port %q, protocol %q for SRV\n", pReq.port, pReq.protocol) for _, port := range dnsRecord.Ports { name := strings.ToLower(port.Name) diff --git a/coredns/plugin/setup.go b/coredns/plugin/setup.go index ffccf032..ef175a4c 100644 --- a/coredns/plugin/setup.go +++ b/coredns/plugin/setup.go @@ -25,6 +25,7 @@ import ( "github.com/coredns/caddy" "github.com/coredns/coredns/core/dnsserver" "github.com/coredns/coredns/plugin" + clog "github.com/coredns/coredns/plugin/pkg/log" "github.com/pkg/errors" "github.com/submariner-io/admiral/pkg/watcher" "github.com/submariner-io/lighthouse/coredns/gateway" @@ -85,6 +86,8 @@ func setupLighthouse(c *caddy.Controller) error { } func lighthouseParse(c *caddy.Controller) (*Lighthouse, error) { + clog.D.Set() + cfg, err := buildKubeConfigFunc(masterURL, kubeconfig) if err != nil { return nil, errors.Wrap(err, "error building kubeconfig")