Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,16 @@ func TestDefaultDelegationAlwaysReported(t *testing.T) {
if in.Policy.Mode != "Cluster" || len(in.Policy.Servers) != 1 {
t.Fatalf("default delegation policy=%+v", in.Policy)
}
return dnsprobe.ProbeResult{Zone: &dnsprobe.ZoneEvidence{Views: []dnsprobe.AuthorityObservation{{Nameservers: []string{"NS.EXAMPLE.TEST."}}}}}, nil
// Shape of a real probe: the recursive view, then the authority view
// reached through glue; both must agree and the authority answers AA.
return dnsprobe.ProbeResult{Zone: &dnsprobe.ZoneEvidence{
Zone: in.Zone,
Authorities: []string{"192.0.2.10:53"},
Views: []dnsprobe.AuthorityObservation{
{ID: "recursive/" + in.Policy.Servers[0], Nameservers: []string{"NS.EXAMPLE.TEST."}, SOAOwner: in.Zone},
{ID: "authority/192.0.2.10:53", Nameservers: []string{"ns.example.test"}, SOAOwner: in.Zone, Authoritative: true},
},
}}, nil
}
_, unit := reconcileOnce(t, r, req)
var data zoneData
Expand Down
29 changes: 22 additions & 7 deletions internal/go/providers/hosted/controllers/zoneunit/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/appthrust/dns-api/internal/go/providers/hosted/withdrawal"
dnsv1alpha1 "github.com/appthrust/dns-api/pkg/go/api/dns/v1alpha1"
hostedv1alpha1 "github.com/appthrust/dns-api/pkg/go/api/hosted/v1alpha1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/controller-runtime/pkg/client"
)

Expand Down Expand Up @@ -110,16 +111,22 @@ func (r *ZoneReconciler) observeDelegation(ctx context.Context, unit *dnsv1alpha
observed, err = r.Options.Resolver.Probe(ctx, request)
}
data := delegationData{ObservedNameServers: []string{}, LastProbeTime: r.Options.Clock()}
if err != nil || observed.Zone == nil || len(observed.Zone.Views) != len(policy.Servers) {
if err != nil {
// Transport errors may carry private network details; publish only the class.
data.Error = "DNSProbeFailed"
}
if observed.Zone != nil {
for _, view := range observed.Zone.Views {
data.ObservedNameServers = append(data.ObservedNameServers, view.Nameservers...)
if view.Failure != "" {
data.Error = "DNSProbeFailed"
} else {
// The probe appends authority views after the recursive views, so the
// view count is not a failure signal; the shared evaluator decides
// (every required view answered, consistent NS/SOA, authorities AA).
decision := dnsprobe.EvaluateZone(request, observed.Zone)
if observed.Zone != nil {
for _, view := range observed.Zone.Views {
data.ObservedNameServers = append(data.ObservedNameServers, view.Nameservers...)
}
}
if decision.Status != metav1.ConditionTrue {
data.Error = boundedError(decision.Reason + ": " + decision.Message)
}
}
data.ObservedNameServers = dnsprobe.Names(data.ObservedNameServers)
data.Matches = data.Error == "" && slices.Equal(data.ObservedNameServers, expected)
Expand Down Expand Up @@ -236,3 +243,11 @@ func retainPublication(state *schedulerState, spec hostedv1alpha1.HostedZoneSpec
}
}
}

// boundedError keeps delegation diagnostics within the 512-byte public schema.
func boundedError(message string) string {
if len(message) > 512 {
return message[:512]
}
return message
}
Loading