Review comments
authorDavid Leadbeater <dgl@dgl.cx>
Mon, 24 Jan 2022 21:04:26 +0000 (08:04 +1100)
committerDavid Leadbeater <dgl@dgl.cx>
Mon, 24 Jan 2022 21:31:21 +0000 (08:31 +1100)
- Drop "desired"
- Drop go 1.17 compat, will be switched entirely to go 1.17 elsewhere

Signed-off-by: David Leadbeater <dgl@dgl.cx>
CONFIGURATION.md
config/config.go
prober/dns.go
prober/dns_test.go
prober/utils_test.go

index bd2b4161c94ed18778440f8f37d0e057072c27e6..9949ffe6fc5932c1adfc0c1a725cc86aaf97dec8 100644 (file)
@@ -189,7 +189,8 @@ query_name: <string>
 [ query_type: <string> | default = "ANY" ]
 [ query_class: <string> | default = "IN" ]
 
-[ recursion_desired: <boolean> | default = true ]
+# Set the recursion desired (RD) flag in the request.
+[ recursion: <boolean> | default = true ]
 
 # List of valid response codes.
 valid_rcodes:
index 46dbfb4bd98c46526b8bf495b270a706a1dc1b4c..b71d97edb77bc10950e18399fa37f346f8ecc6cc 100644 (file)
@@ -82,7 +82,7 @@ var (
        // DefaultDNSProbe set default value for DNSProbe
        DefaultDNSProbe = DNSProbe{
                IPProtocolFallback: true,
-               RecursionDesired:   true,
+               Recursion:          true,
        }
 )
 
@@ -266,7 +266,7 @@ type DNSProbe struct {
        QueryClass         string           `yaml:"query_class,omitempty"` // Defaults to IN.
        QueryName          string           `yaml:"query_name,omitempty"`
        QueryType          string           `yaml:"query_type,omitempty"`        // Defaults to ANY.
-       RecursionDesired   bool             `yaml:"recursion_desired,omitempty"` // Defaults to true.
+       Recursion          bool             `yaml:"recursion_desired,omitempty"` // Defaults to true.
        ValidRcodes        []string         `yaml:"valid_rcodes,omitempty"`      // Defaults to NOERROR.
        ValidateAnswer     DNSRRValidator   `yaml:"validate_answer_rrs,omitempty"`
        ValidateAuthority  DNSRRValidator   `yaml:"validate_authority_rrs,omitempty"`
index 130a9cb53ad83c329b74982d6ff0549a17c97bcf..8e8a1b59c8f2231ad30fcf6fcdf89bc4361e9305 100644 (file)
@@ -250,7 +250,7 @@ func ProbeDNS(ctx context.Context, target string, module config.Module, registry
 
        msg := new(dns.Msg)
        msg.Id = dns.Id()
-       msg.RecursionDesired = module.DNS.RecursionDesired
+       msg.RecursionDesired = module.DNS.Recursion
        msg.Question = make([]dns.Question, 1)
        msg.Question[0] = dns.Question{dns.Fqdn(module.DNS.QueryName), qt, qc}
 
index 38ee38ac904ce2690b1aeac9a057209f1354c24d..73385ae1a7fd9b39956b464a19d4ecf519593f6e 100644 (file)
@@ -103,7 +103,7 @@ func TestRecursiveDNSResponse(t *testing.T) {
                                IPProtocol:         "ip4",
                                IPProtocolFallback: true,
                                QueryName:          "example.com",
-                               RecursionDesired:   true,
+                               Recursion:          true,
                        }, true,
                },
                {
@@ -111,7 +111,7 @@ func TestRecursiveDNSResponse(t *testing.T) {
                                IPProtocol:         "ip4",
                                IPProtocolFallback: true,
                                QueryName:          "example.com",
-                               RecursionDesired:   true,
+                               Recursion:          true,
                                ValidRcodes:        []string{"SERVFAIL", "NXDOMAIN"},
                        }, false,
                },
@@ -120,7 +120,7 @@ func TestRecursiveDNSResponse(t *testing.T) {
                                IPProtocol:         "ip4",
                                IPProtocolFallback: true,
                                QueryName:          "example.com",
-                               RecursionDesired:   true,
+                               Recursion:          true,
                                ValidateAnswer: config.DNSRRValidator{
                                        FailIfMatchesRegexp:    []string{".*7200.*"},
                                        FailIfNotMatchesRegexp: []string{".*3600.*"},
@@ -132,7 +132,7 @@ func TestRecursiveDNSResponse(t *testing.T) {
                                IPProtocol:         "ip4",
                                IPProtocolFallback: true,
                                QueryName:          "example.com",
-                               RecursionDesired:   true,
+                               Recursion:          true,
                                ValidateAuthority: config.DNSRRValidator{
                                        FailIfMatchesRegexp: []string{".*7200.*"},
                                },
@@ -143,7 +143,7 @@ func TestRecursiveDNSResponse(t *testing.T) {
                                IPProtocol:         "ip4",
                                IPProtocolFallback: true,
                                QueryName:          "example.com",
-                               RecursionDesired:   true,
+                               Recursion:          true,
                                ValidateAdditional: config.DNSRRValidator{
                                        FailIfNotMatchesRegexp: []string{".*3600.*"},
                                },
@@ -154,7 +154,7 @@ func TestRecursiveDNSResponse(t *testing.T) {
                                IPProtocol:         "ip4",
                                IPProtocolFallback: true,
                                QueryName:          "example.com",
-                               RecursionDesired:   false,
+                               Recursion:          false,
                        }, false,
                },
        }
@@ -183,7 +183,7 @@ func TestRecursiveDNSResponse(t *testing.T) {
                                "probe_dns_authority_rrs":  0,
                                "probe_dns_additional_rrs": 0,
                        }
-                       if !test.Probe.RecursionDesired {
+                       if !test.Probe.Recursion {
                                expectedResults["probe_dns_answer_rrs"] = 0
                        }
                        checkRegistryResults(expectedResults, mfs, t)
@@ -494,7 +494,7 @@ func TestDNSProtocol(t *testing.T) {
                                QueryName:         "example.com",
                                TransportProtocol: protocol,
                                IPProtocol:        "ip6",
-                               RecursionDesired:  true,
+                               Recursion:         true,
                        },
                }
                registry := prometheus.NewRegistry()
@@ -518,7 +518,7 @@ func TestDNSProtocol(t *testing.T) {
                        Timeout: time.Second,
                        DNS: config.DNSProbe{
                                QueryName:         "example.com",
-                               RecursionDesired:  true,
+                               Recursion:         true,
                                TransportProtocol: protocol,
                                IPProtocol:        "ip4",
                        },
@@ -545,7 +545,7 @@ func TestDNSProtocol(t *testing.T) {
                        Timeout: time.Second,
                        DNS: config.DNSProbe{
                                QueryName:         "example.com",
-                               RecursionDesired:  true,
+                               Recursion:         true,
                                TransportProtocol: protocol,
                        },
                }
@@ -570,8 +570,8 @@ func TestDNSProtocol(t *testing.T) {
                module = config.Module{
                        Timeout: time.Second,
                        DNS: config.DNSProbe{
-                               QueryName:        "example.com",
-                               RecursionDesired: true,
+                               QueryName: "example.com",
+                               Recursion: true,
                        },
                }
                registry = prometheus.NewRegistry()
@@ -614,7 +614,7 @@ func TestDNSMetrics(t *testing.T) {
                        IPProtocol:         "ip4",
                        IPProtocolFallback: true,
                        QueryName:          "example.com",
-                       RecursionDesired:   true,
+                       Recursion:          true,
                },
        }
        registry := prometheus.NewRegistry()
index 0f51906dbb5274ef1c4b518ed0fbbd69f81f275d..ed56baf41eb24649072ce591f705e44b17eba55e 100644 (file)
@@ -162,7 +162,7 @@ func TestChooseProtocol(t *testing.T) {
        registry = prometheus.NewPedanticRegistry()
 
        ip, _, err = chooseProtocol(ctx, "ip4", false, "ipv6.google.com", registry, logger)
-       if err != nil && err.Error() != "address ipv6.google.com: no suitable address found" && err.Error() != "lookup ipv6.google.com: no such host" {
+       if err != nil && err.Error() != "address ipv6.google.com: no suitable address found" {
                t.Error(err)
        } else if err == nil {
                t.Error("should set error")