Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

healthchecks: Handle no such host from Network Check and show MetaApiConnErr as WARNING. #1631

Closed
Closed
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
2 changes: 1 addition & 1 deletion internal/healthchecks/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ var (
Message: "Request to GCE Metadata server failed",
Action: "Check your internet connection and firewall rules.",
ResourceLink: "https://cloud.google.com/stackdriver/docs/solutions/agents/ops-agent/troubleshoot-run-ingest#network-issues",
IsFatal: true,
IsFatal: false,
}
LogApiScopeErr = HealthCheckError{
Code: "LogApiScopeErr",
Expand Down
11 changes: 10 additions & 1 deletion internal/healthchecks/network_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package healthchecks
import (
"context"
"errors"
"net"
"net/http"
"time"

Expand Down Expand Up @@ -72,6 +73,14 @@ var (
}
)

func isHostNotFound(err error) bool {
var dnsError *net.DNSError
if errors.As(err, &dnsError) {
return dnsError.IsNotFound
}
return false
}

func (r networkRequest) SendRequest(logger logs.StructuredLogger) error {
var response *http.Response
var err error
Expand All @@ -87,7 +96,7 @@ func (r networkRequest) SendRequest(logger logs.StructuredLogger) error {
}
}
if err != nil {
if isTimeoutError(err) || isConnectionRefusedError(err) {
if isTimeoutError(err) || isConnectionRefusedError(err) || isHostNotFound(err) {
return r.healthCheckError
}
return err
Expand Down
Loading