TUN-1350: Enhance error messages with cloudflarestatus.com link, if relevant

This commit is contained in:
Nick Vollmar
2019-01-10 14:55:44 -06:00
parent 8de19dc647
commit 62b1ab8c98
25 changed files with 1632 additions and 33 deletions

View File

@@ -2,9 +2,9 @@ package origin
import (
"bufio"
"context"
"crypto/tls"
"fmt"
"github.com/google/uuid"
"io"
"net"
"net/http"
@@ -13,7 +13,6 @@ import (
"strings"
"time"
"golang.org/x/net/context"
"golang.org/x/sync/errgroup"
"github.com/cloudflare/cloudflared/h2mux"
@@ -23,6 +22,7 @@ import (
"github.com/cloudflare/cloudflared/websocket"
raven "github.com/getsentry/raven-go"
"github.com/google/uuid"
"github.com/pkg/errors"
_ "github.com/prometheus/client_golang/prometheus"
log "github.com/sirupsen/logrus"
@@ -63,6 +63,7 @@ type TunnelConfig struct {
NoChunkedEncoding bool
WSGI bool
CompressionQuality uint64
IncidentLookup IncidentLookup
}
type dialError struct {
@@ -265,6 +266,9 @@ func ServeTunnel(
logger.WithError(castedErr.cause).Error("Register tunnel error from server side")
// Don't send registration error return from server to Sentry. They are
// logged on server side
if incidents := config.IncidentLookup.ActiveIncidents(); len(incidents) > 0 {
logger.Error(activeIncidentsMsg(incidents))
}
return castedErr.cause, !castedErr.permanent
case clientRegisterTunnelError:
logger.WithError(castedErr.cause).Error("Register tunnel error on client side")
@@ -696,3 +700,17 @@ func trialZoneMsg(url string) []string {
" " + url,
}
}
func activeIncidentsMsg(incidents []Incident) string {
preamble := "There is an active Cloudflare incident that may be related:"
if len(incidents) > 1 {
preamble = "There are active Cloudflare incidents that may be related:"
}
incidentStrings := []string{}
for _, incident := range incidents {
incidentString := fmt.Sprintf("%s (%s)", incident.Name, incident.URL())
incidentStrings = append(incidentStrings, incidentString)
}
return preamble + " " + strings.Join(incidentStrings, "; ")
}