Commit c369cec5 authored by Sebastian Stark's avatar Sebastian Stark

notify via email if ignorable rsync error happened

parent 9097f9fb
......@@ -14,6 +14,21 @@ func FailureMail(exitCode int, logBuffer *RingIO) {
SendMail(config.Notify, subject, mail)
}
func RsyncIssueMail(rsyncError error, rsyncErrorCode int) {
var errText string
if s, ok := rsyncIgnoredErrors[rsyncErrorCode]; ok == true {
errText = s
} else {
errText = "<unknown>"
}
mail := fmt.Sprintf(`rsync finished with error: %s (%s).
This is a non-fatal error, snaprd will try again.`, rsyncError, errText)
subject := fmt.Sprintf("snaprd rsync error (origin: %s)", config.Origin)
// In this case we care that the mail command is not blocking the whole
// program
go SendMail(config.Notify, subject, mail)
}
func NotifyMail(to, msg string) {
SendMail(to, "snaprd notice", msg)
}
......
......@@ -137,6 +137,10 @@ func createSnapshot(base *snapshot) (*snapshot, error) {
debugf("The error code we got is: %v", rsyncRet)
if errmsg, ok := rsyncIgnoredErrors[rsyncRet]; ok == true {
log.Printf("ignoring rsync error %d: %s", rsyncRet, errmsg)
// 24 ("files vanished") happens too often and is usually harmless
if rsyncRet != 24 && config.Notify != "" {
RsyncIssueMail(err, rsyncRet)
}
failed = false
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment