Skip to content
This repository has been archived by the owner on Jul 1, 2023. It is now read-only.

coredns #84

Merged
merged 9 commits into from Oct 18, 2018
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gopkg.toml
Expand Up @@ -49,7 +49,7 @@
name = "github.com/gravitational/configure"

[[constraint]]
branch = "master"
version = "1.0.0"
name = "github.com/gravitational/roundtrip"

[[constraint]]
Expand Down
2 changes: 1 addition & 1 deletion agent/server_test.go
Expand Up @@ -421,7 +421,7 @@ func (r *AgentSuite) TestReflectsStatusInStatusCode(c *C) {
client, err := r.httpClient(fmt.Sprintf("https://127.0.0.1:%v", rpcPort))
c.Assert(err, IsNil)

resp, err := client.Get(client.Endpoint(""), url.Values{})
resp, err := client.Get(context.TODO(), client.Endpoint(""), url.Values{})
c.Assert(err, IsNil)
c.Assert(resp.Code(), Equals, http.StatusServiceUnavailable)

Expand Down
3 changes: 2 additions & 1 deletion monitoring/collector/docker.go
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package collector

import (
"context"
"net"
"net/http"
"net/url"
Expand Down Expand Up @@ -85,7 +86,7 @@ func (d *DockerCollector) Collect(ch chan<- prometheus.Metric) error {
// healthStatus determines status of docker service
// by fetching the docker's version HTTP endpoint from daemon socket
func (d *DockerCollector) healthStatus() (bool, error) {
resp, err := d.client.Get(d.client.Endpoint("version"), url.Values{})
resp, err := d.client.Get(context.TODO(), d.client.Endpoint("version"), url.Values{})
if err != nil {
return false, trace.Wrap(err, "HTTP request failed: %v", err)
}
Expand Down
5 changes: 3 additions & 2 deletions monitoring/collector/etcd.go
Expand Up @@ -18,6 +18,7 @@ package collector

import (
"bytes"
"context"
"encoding/json"
"net/http"
"net/url"
Expand Down Expand Up @@ -84,7 +85,7 @@ func NewEtcdCollector(config *monitoring.ETCDConfig) (*EtcdCollector, error) {

// Collect implements the prometheus.Collector interface
func (e *EtcdCollector) Collect(ch chan<- prometheus.Metric) error {
resp, err := e.client.Get(e.client.Endpoint("v2", "stats", "leader"), url.Values{})
resp, err := e.client.Get(context.TODO(), e.client.Endpoint("v2", "stats", "leader"), url.Values{})
if err != nil {
return trace.Wrap(err)
}
Expand Down Expand Up @@ -114,7 +115,7 @@ func (e *EtcdCollector) Collect(ch chan<- prometheus.Metric) error {
func (e *EtcdCollector) healthStatus() (healthy bool, err error) {
result := struct{ Health string }{}
nresult := struct{ Health bool }{}
resp, err := e.client.Get(e.client.Endpoint("health"), url.Values{})
resp, err := e.client.Get(context.TODO(), e.client.Endpoint("health"), url.Values{})
if err != nil {
return false, trace.Wrap(err)
}
Expand Down
2 changes: 1 addition & 1 deletion monitoring/collector/systemd.go
Expand Up @@ -29,7 +29,7 @@ var (
"flanneld.service",
"serf.service",
"planet-agent.service",
"dnsmasq.service",
"coredns.service",
"registry.service",
"docker.service",
"etcd.service",
Expand Down
5 changes: 5 additions & 0 deletions monitoring/defaults.go
Expand Up @@ -72,3 +72,8 @@ func GetStorageDriverBootConfigParams(drv string) health.Checker {
func NewStorageChecker(config StorageConfig) health.Checker {
return noopChecker{}
}

// NewDNSChecker sends some default queries to monitor DNS / service discovery health
func NewDNSChecker() health.Checker {
return noopChecker{}
}
9 changes: 8 additions & 1 deletion monitoring/defaults_linux.go
Expand Up @@ -56,7 +56,7 @@ func DefaultProcessChecker() health.Checker {
return &ProcessChecker{[]string{
"dockerd",
"lxd",
"dnsmasq",
"coredns",
"kube-apiserver",
"kube-scheduler",
"kube-controller-manager",
Expand Down Expand Up @@ -128,3 +128,10 @@ func DefaultBootConfigParams() health.Checker {
},
)
}

// NewDNSChecker sends some default queries to monitor DNS / service discovery health
func NewDNSChecker(questionA []string) health.Checker {
return &DNSChecker{
QuestionA: questionA,
}
}
57 changes: 57 additions & 0 deletions monitoring/dns.go
@@ -0,0 +1,57 @@
/*
Copyright 2016 Gravitational, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package monitoring

import (
"context"
"fmt"
"net"

"github.com/gravitational/satellite/agent/health"
pb "github.com/gravitational/satellite/agent/proto/agentpb"
)

// DNSMonitor will monitor a list of DNS servers for valid responses
type DNSChecker struct {
// QuestionA is a slice of questions to ask for A (Host) records
QuestionA []string
}

// Name returns the name of this checker
func (r *DNSChecker) Name() string { return "dns" }

// Check checks if the DNS servers are responding
func (r *DNSChecker) Check(ctx context.Context, reporter health.Reporter) {
checkFailed := false
for _, question := range r.QuestionA {
_, err := net.LookupHost(question)
if err != nil {
detail := fmt.Sprintf("failed to resolve %v", question)
reporter.Add(NewProbeFromErr(r.Name(), detail, err))
checkFailed = true
}
}

if checkFailed {
return
}

reporter.Add(&pb.Probe{
Checker: r.Name(),
Status: pb.Probe_Running,
})
}
33 changes: 21 additions & 12 deletions vendor/github.com/gravitational/roundtrip/client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion vendor/github.com/gravitational/roundtrip/seeker.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.