Skip to content

Commit

Permalink
DEBUG
Browse files Browse the repository at this point in the history
Signed-off-by: Tom Pantelis <[email protected]>
  • Loading branch information
tpantelis committed Nov 22, 2024
1 parent eb6abef commit e499e76
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
11 changes: 6 additions & 5 deletions coredns/plugin/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ package lighthouse
import (
"context"
"errors"
"fmt"

"github.com/coredns/coredns/plugin"
"github.com/coredns/coredns/request"
Expand All @@ -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.
Expand Down Expand Up @@ -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)
}

Expand Down Expand Up @@ -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 {
Expand Down
6 changes: 5 additions & 1 deletion coredns/plugin/record.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand All @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions coredns/plugin/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit e499e76

Please sign in to comment.