mirror of
https://github.com/octoleo/syncthing.git
synced 2025-04-02 15:51:51 +00:00
all: Failure reporting fixes (#7331)
This commit is contained in:
parent
ffc14a77c6
commit
27a34609a1
@ -47,7 +47,7 @@ func main() {
|
|||||||
mux.Handle("/", cr)
|
mux.Handle("/", cr)
|
||||||
|
|
||||||
if *dsn != "" {
|
if *dsn != "" {
|
||||||
mux.HandleFunc("/failure", handleFailureFn(*dsn))
|
mux.HandleFunc("/newcrash/failure", handleFailureFn(*dsn))
|
||||||
}
|
}
|
||||||
|
|
||||||
log.SetOutput(os.Stdout)
|
log.SetOutput(os.Stdout)
|
||||||
|
@ -1202,7 +1202,7 @@ func unchanged(nf, ef protocol.FileIntf) bool {
|
|||||||
func (db *Lowlevel) handleFailure(err error) {
|
func (db *Lowlevel) handleFailure(err error) {
|
||||||
db.checkErrorForRepair(err)
|
db.checkErrorForRepair(err)
|
||||||
if shouldReportFailure(err) {
|
if shouldReportFailure(err) {
|
||||||
db.evLogger.Log(events.Failure, err)
|
db.evLogger.Log(events.Failure, err.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,13 +123,15 @@ func (h *failureHandler) Serve(ctx context.Context) error {
|
|||||||
|
|
||||||
if sub != nil {
|
if sub != nil {
|
||||||
sub.Unsubscribe()
|
sub.Unsubscribe()
|
||||||
reports := make([]FailureReport, 0, len(h.buf))
|
if len(h.buf) > 0 {
|
||||||
for descr, stat := range h.buf {
|
reports := make([]FailureReport, 0, len(h.buf))
|
||||||
reports = append(reports, newFailureReport(descr, stat.count))
|
for descr, stat := range h.buf {
|
||||||
|
reports = append(reports, newFailureReport(descr, stat.count))
|
||||||
|
}
|
||||||
|
timeout, cancel := context.WithTimeout(context.Background(), finalSendTimeout)
|
||||||
|
defer cancel()
|
||||||
|
sendFailureReports(timeout, reports, url)
|
||||||
}
|
}
|
||||||
timeout, cancel := context.WithTimeout(context.Background(), finalSendTimeout)
|
|
||||||
defer cancel()
|
|
||||||
sendFailureReports(timeout, reports, url)
|
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -192,7 +194,7 @@ func sendFailureReports(ctx context.Context, reports []FailureReport, url string
|
|||||||
|
|
||||||
reqCtx, reqCancel := context.WithTimeout(ctx, sendTimeout)
|
reqCtx, reqCancel := context.WithTimeout(ctx, sendTimeout)
|
||||||
defer reqCancel()
|
defer reqCancel()
|
||||||
req, err := http.NewRequestWithContext(reqCtx, http.MethodGet, url, &b)
|
req, err := http.NewRequestWithContext(reqCtx, http.MethodPost, url, &b)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
l.Infoln("Failed to send failure report:", err)
|
l.Infoln("Failed to send failure report:", err)
|
||||||
return
|
return
|
||||||
|
Loading…
x
Reference in New Issue
Block a user