Documentation ¶
Index ¶
- Constants
- Variables
- func NotifyAdmins(subject, message string, settings *evergreen.Settings) error
- func ProcessNotifications(ae *web.App, mciNotification *MCINotification, updateTimes bool) (map[NotificationKey][]Email, error)
- func Run(settings *evergreen.Settings) error
- func SendNotifications(settings *evergreen.Settings, mciNotification *MCINotification, ...) (err error)
- func TemplateEmailBody(ae *web.App, name string, data interface{}) (string, error)
- func TrySendNotification(recipients []string, subject, body string, mailer Mailer) (err error)
- func TrySendNotificationToUser(userId string, subject, body string, mailer Mailer) error
- func UpdateNotificationTimes() (err error)
- func ValidateNotifications(mciNotification *MCINotification) error
- type BuildCompletionHandler
- func (self *BuildCompletionHandler) GetChangeInfo(notification *TriggeredBuildNotification) ([]ChangeInfo, error)
- func (self *BuildCompletionHandler) GetNotifications(ae *web.App, key *NotificationKey) ([]Email, error)
- func (self *BuildCompletionHandler) TemplateNotification(ae *web.App, notification *TriggeredBuildNotification) (Email, error)
- type BuildEmail
- type BuildFailureHandler
- func (self *BuildFailureHandler) GetChangeInfo(notification *TriggeredBuildNotification) ([]ChangeInfo, error)
- func (self *BuildFailureHandler) GetNotifications(ae *web.App, key *NotificationKey) ([]Email, error)
- func (self *BuildFailureHandler) TemplateNotification(ae *web.App, notification *TriggeredBuildNotification) (Email, error)
- type BuildNotificationForTemplate
- type BuildNotificationHandler
- type BuildSuccessHandler
- func (self *BuildSuccessHandler) GetChangeInfo(notification *TriggeredBuildNotification) ([]ChangeInfo, error)
- func (self *BuildSuccessHandler) GetNotifications(ae *web.App, key *NotificationKey) ([]Email, error)
- func (self *BuildSuccessHandler) TemplateNotification(ae *web.App, notification *TriggeredBuildNotification) (Email, error)
- type BuildSuccessToFailureHandler
- func (self *BuildSuccessToFailureHandler) GetChangeInfo(notification *TriggeredBuildNotification) ([]ChangeInfo, error)
- func (self *BuildSuccessToFailureHandler) GetNotifications(ae *web.App, key *NotificationKey) ([]Email, error)
- func (self *BuildSuccessToFailureHandler) TemplateNotification(ae *web.App, notification *TriggeredBuildNotification) (Email, error)
- type ChangeInfo
- type Email
- type EmailBase
- type MCINotification
- type Mailer
- type Notification
- type NotificationHandler
- type NotificationKey
- type Runner
- type SmtpMailer
- type Subscription
- type TaskCompletionHandler
- func (self *TaskCompletionHandler) GetChangeInfo(notification *TriggeredTaskNotification) ([]ChangeInfo, error)
- func (self *TaskCompletionHandler) GetNotifications(ae *web.App, key *NotificationKey) ([]Email, error)
- func (self *TaskCompletionHandler) TemplateNotification(ae *web.App, notification *TriggeredTaskNotification) (Email, error)
- type TaskEmail
- type TaskFailureHandler
- func (self *TaskFailureHandler) GetChangeInfo(notification *TriggeredTaskNotification) ([]ChangeInfo, error)
- func (self *TaskFailureHandler) GetNotifications(ae *web.App, key *NotificationKey) ([]Email, error)
- func (self *TaskFailureHandler) TemplateNotification(ae *web.App, notification *TriggeredTaskNotification) (Email, error)
- type TaskNotificationForTemplate
- type TaskNotificationHandler
- type TaskSuccessHandler
- func (self *TaskSuccessHandler) GetChangeInfo(notification *TriggeredTaskNotification) ([]ChangeInfo, error)
- func (self *TaskSuccessHandler) GetNotifications(ae *web.App, key *NotificationKey) ([]Email, error)
- func (self *TaskSuccessHandler) TemplateNotification(ae *web.App, notification *TriggeredTaskNotification) (Email, error)
- type TaskSuccessToFailureHandler
- func (self *TaskSuccessToFailureHandler) GetChangeInfo(notification *TriggeredTaskNotification) ([]ChangeInfo, error)
- func (self *TaskSuccessToFailureHandler) GetNotifications(ae *web.App, key *NotificationKey) ([]Email, error)
- func (self *TaskSuccessToFailureHandler) TemplateNotification(ae *web.App, notification *TriggeredTaskNotification) (Email, error)
- type Team
- type TriggeredBuildNotification
- type TriggeredTaskNotification
Constants ¶
const ( TemplatePath = "notify/templates" BaseTemplate = "layout.html" )
const ( // number of times to try sending a notification NumSmtpRetries = 3 // period to sleep between tries SmtpSleepTime = 1 * time.Second // smtp port to connect to SmtpPort = 25 // smtp relay host to connect to SmtpServer = "localhost" // Thus on each run of the notifier, we check if the last notification time // (LNT) is within this window. If it is, then we use the retrieved LNT. // If not, we use the current time LNRWindow = 60 * time.Minute // MCI ops notification prefaces ProvisionFailurePreface = "[PROVISION-FAILURE]" ProvisionTimeoutPreface = "[PROVISION-TIMEOUT]" ProvisionLatePreface = "[PROVISION-LATE]" TeardownFailurePreface = "[TEARDOWN-FAILURE]" // repotracker notification prefaces RepotrackerFailurePreface = "[REPOTRACKER-FAILURE %v] on %v" // branch name to use if the project reference is not found UnknownProjectBranch = "" DefaultNotificationsConfig = "/etc/mci-notifications.yml" )
const ( RunnerName = "notify" Description = "send notifications for failed tasks and system issues" )
const ( TimeOutMessage = "timeout" UnresponsiveMessage = "unresponsive" )
Variables ¶
var ( Handlers = map[string]NotificationHandler{ // contains filtered or unexported fields } )
Functions ¶
func NotifyAdmins ¶
NotifyAdmins is a helper method to send a notification to the MCI admin team
func ProcessNotifications ¶
func ProcessNotifications(ae *web.App, mciNotification *MCINotification, updateTimes bool) (map[NotificationKey][]Email, error)
This function is responsible for all notifications processing
func Run ¶
This function is responsible for running the notifications pipeline
ParseNotifications
↓↓
ValidateNotifications
↓↓
ProcessNotifications
↓↓
SendNotifications
↓↓
UpdateNotificationTimes
func SendNotifications ¶
func SendNotifications(settings *evergreen.Settings, mciNotification *MCINotification, emails map[NotificationKey][]Email, mailer Mailer) (err error)
This function is responsible for managing the sending triggered email notifications
func TemplateEmailBody ¶
func TrySendNotification ¶
Helper function to send notifications
func TrySendNotificationToUser ¶
Helper function to send notification to a given user
func UpdateNotificationTimes ¶
func UpdateNotificationTimes() (err error)
This stores the last time threshold after which we search for possible new notification events
func ValidateNotifications ¶
func ValidateNotifications(mciNotification *MCINotification) error
This function is responsible for validating the notifications file
Types ¶
type BuildCompletionHandler ¶
type BuildCompletionHandler struct { BuildNotificationHandler Name string }
Handler for build completion notifications, i.e. send notifications whenever a build finishes. Implements NotificationHandler from notification_handler.go.
func (*BuildCompletionHandler) GetChangeInfo ¶
func (self *BuildCompletionHandler) GetChangeInfo( notification *TriggeredBuildNotification) ([]ChangeInfo, error)
func (*BuildCompletionHandler) GetNotifications ¶
func (self *BuildCompletionHandler) GetNotifications(ae *web.App, key *NotificationKey) ([]Email, error)
func (*BuildCompletionHandler) TemplateNotification ¶
func (self *BuildCompletionHandler) TemplateNotification(ae *web.App, notification *TriggeredBuildNotification) (Email, error)
type BuildEmail ¶
type BuildEmail struct { EmailBase Trigger TriggeredBuildNotification }
Implements Email interface for build-specific emails. Defines skip logic for emails specific to build
func (*BuildEmail) GetRecipients ¶
func (self *BuildEmail) GetRecipients(defaultRecipient string) []string
func (*BuildEmail) IsLikelySystemFailure ¶
func (self *BuildEmail) IsLikelySystemFailure() bool
func (*BuildEmail) ShouldSkip ¶
func (self *BuildEmail) ShouldSkip(skipVariants []string) bool
type BuildFailureHandler ¶
type BuildFailureHandler struct { BuildNotificationHandler Name string }
Handler for build failure notifications. Implements NotificationHandler from notification_handler.go.
func (*BuildFailureHandler) GetChangeInfo ¶
func (self *BuildFailureHandler) GetChangeInfo( notification *TriggeredBuildNotification) ([]ChangeInfo, error)
func (*BuildFailureHandler) GetNotifications ¶
func (self *BuildFailureHandler) GetNotifications(ae *web.App, key *NotificationKey) ([]Email, error)
func (*BuildFailureHandler) TemplateNotification ¶
func (self *BuildFailureHandler) TemplateNotification(ae *web.App, notification *TriggeredBuildNotification) (Email, error)
type BuildNotificationForTemplate ¶
type BuildNotificationForTemplate struct { Notification *TriggeredBuildNotification FailedTasks []build.TaskCache Subject string }
type BuildNotificationHandler ¶
type BuildNotificationHandler struct {
Type string
}
"Base class" for all build_*_handler.go structs. Contains code that's common to all the build_*_handlers. Note that this struct does NOT implement NotificationHandler
type BuildSuccessHandler ¶
type BuildSuccessHandler struct { BuildNotificationHandler Name string }
Handler for build success notifications. Implements NotificationHandler from notification_handler.go.
func (*BuildSuccessHandler) GetChangeInfo ¶
func (self *BuildSuccessHandler) GetChangeInfo( notification *TriggeredBuildNotification) ([]ChangeInfo, error)
func (*BuildSuccessHandler) GetNotifications ¶
func (self *BuildSuccessHandler) GetNotifications(ae *web.App, key *NotificationKey) ([]Email, error)
func (*BuildSuccessHandler) TemplateNotification ¶
func (self *BuildSuccessHandler) TemplateNotification(ae *web.App, notification *TriggeredBuildNotification) (Email, error)
type BuildSuccessToFailureHandler ¶
type BuildSuccessToFailureHandler struct { BuildNotificationHandler Name string }
Handler for notifications generated specifically when a build fails and the previous finished build succeeded. Implements NotificationHandler from notification_handler.go.
func (*BuildSuccessToFailureHandler) GetChangeInfo ¶
func (self *BuildSuccessToFailureHandler) GetChangeInfo( notification *TriggeredBuildNotification) ([]ChangeInfo, error)
func (*BuildSuccessToFailureHandler) GetNotifications ¶
func (self *BuildSuccessToFailureHandler) GetNotifications(ae *web.App, key *NotificationKey) ([]Email, error)
func (*BuildSuccessToFailureHandler) TemplateNotification ¶
func (self *BuildSuccessToFailureHandler) TemplateNotification(ae *web.App, notification *TriggeredBuildNotification) (Email, error)
type ChangeInfo ¶
type ChangeInfo struct { Revision string Author string Email string Pushtime string Project string Message string }
stores information pertaining to a repository's changes
type Email ¶
type Email interface { GetBody() string GetSubject() string // for system-related failures, we only want to notify the admins // regardless of who the default recipient is IsLikelySystemFailure() bool GetRecipients(defaultRecipient string) []string GetChangeInfo() []ChangeInfo // Should you skip sending this email given the provided variants to skip ShouldSkip(skipVariants []string) bool }
Interface around an email that may be sent as a notification. Provides getters for body, subject, and change info, and functions to determine if this email should be skipped.
type EmailBase ¶
type EmailBase struct { Body string Subject string ChangeInfo []ChangeInfo }
"Base class" for structs that implement the Email interface. Stores the basics that any email should have.
func (*EmailBase) GetChangeInfo ¶
func (self *EmailBase) GetChangeInfo() []ChangeInfo
func (*EmailBase) GetSubject ¶
type MCINotification ¶
type MCINotification struct { Notifications []Notification `yaml:"notifications"` Teams []Team `yaml:"teams"` PatchNotifications []Subscription `yaml:"patch_notifications"` }
store notifications file
func ParseNotifications ¶
func ParseNotifications(configName string) (*MCINotification, error)
This function is responsible for reading the notifications file
type Mailer ¶
func ConstructMailer ¶
func ConstructMailer(notifyConfig evergreen.NotifyConfig) Mailer
type Notification ¶
type Notification struct { Name string `yaml:"name"` Project string `yaml:"project"` Recipients []string `yaml:"recipients"` SkipVariants []string `yaml:"skip_variants"` }
stores supported notifications
type NotificationHandler ¶
type NotificationHandler interface { // Given a key, scan through database and generate the notifications that // have been triggered since the last time this function ran. Returns the // emails generated for this particular key. GetNotifications(ae *web.App, key *NotificationKey) ([]Email, error) }
General interface for how notify.go deals with a given type of notification. At a high level, structs that implement this interface are responsible for scanning the database to find which notifications to generate and returning an object matching the Email interface for each notification.
type NotificationKey ¶
type NotificationKey struct { Project string NotificationName string NotificationType string NotificationRequester string }
stores high level notifications key
func (NotificationKey) String ¶
func (nk NotificationKey) String() string
String method for notification key
type SmtpMailer ¶
type Subscription ¶
type Subscription struct { Project string `yaml:"project"` SkipVariants []string `yaml:"skip_variants"` NotifyOn []string `yaml:"notify_on"` }
stores notifications subscription for a team
type TaskCompletionHandler ¶
type TaskCompletionHandler struct { TaskNotificationHandler Name string }
Handler for task completion notifications, i.e. send notifications whenever a task finishes. Implements NotificationHandler from notification_handler.go.
func (*TaskCompletionHandler) GetChangeInfo ¶
func (self *TaskCompletionHandler) GetChangeInfo( notification *TriggeredTaskNotification) ([]ChangeInfo, error)
func (*TaskCompletionHandler) GetNotifications ¶
func (self *TaskCompletionHandler) GetNotifications(ae *web.App, key *NotificationKey) ([]Email, error)
func (*TaskCompletionHandler) TemplateNotification ¶
func (self *TaskCompletionHandler) TemplateNotification(ae *web.App, notification *TriggeredTaskNotification) (Email, error)
type TaskEmail ¶
type TaskEmail struct { EmailBase Trigger TriggeredTaskNotification }
Implements Email interface for task-specific emails. Defines skip logic for emails specific to tasks
func (*TaskEmail) GetRecipients ¶
func (*TaskEmail) IsLikelySystemFailure ¶
func (*TaskEmail) ShouldSkip ¶
type TaskFailureHandler ¶
type TaskFailureHandler struct { TaskNotificationHandler Name string }
Handler for task failure notifications. Implements NotificationHandler from notification_handler.go.
func (*TaskFailureHandler) GetChangeInfo ¶
func (self *TaskFailureHandler) GetChangeInfo( notification *TriggeredTaskNotification) ([]ChangeInfo, error)
func (*TaskFailureHandler) GetNotifications ¶
func (self *TaskFailureHandler) GetNotifications(ae *web.App, key *NotificationKey) ([]Email, error)
func (*TaskFailureHandler) TemplateNotification ¶
func (self *TaskFailureHandler) TemplateNotification(ae *web.App, notification *TriggeredTaskNotification) (Email, error)
type TaskNotificationForTemplate ¶
type TaskNotificationForTemplate struct { Notification *TriggeredTaskNotification LogsUrl string Details apimodels.TaskEndDetail FailedTests []task.TestResult Subject string }
type TaskNotificationHandler ¶
type TaskNotificationHandler struct {
Type string
}
"Base class" for all task_*_handler.go structs. Contains code that's common to all the task_*_handlers. Note that this struct does NOT implement NotificationHandler
type TaskSuccessHandler ¶
type TaskSuccessHandler struct { TaskNotificationHandler Name string }
Handler for notifying users that a task succeeded. Implements NotificationHandler from notification_handler.go.
func (*TaskSuccessHandler) GetChangeInfo ¶
func (self *TaskSuccessHandler) GetChangeInfo( notification *TriggeredTaskNotification) ([]ChangeInfo, error)
func (*TaskSuccessHandler) GetNotifications ¶
func (self *TaskSuccessHandler) GetNotifications(ae *web.App, key *NotificationKey) ([]Email, error)
func (*TaskSuccessHandler) TemplateNotification ¶
func (self *TaskSuccessHandler) TemplateNotification(ae *web.App, notification *TriggeredTaskNotification) (Email, error)
type TaskSuccessToFailureHandler ¶
type TaskSuccessToFailureHandler struct { TaskNotificationHandler Name string }
Handler for notifications generated specifically when a task fails and the previous finished task succeeded. Implements NotificationHandler from notification_handler.go.
func (*TaskSuccessToFailureHandler) GetChangeInfo ¶
func (self *TaskSuccessToFailureHandler) GetChangeInfo( notification *TriggeredTaskNotification) ([]ChangeInfo, error)
func (*TaskSuccessToFailureHandler) GetNotifications ¶
func (self *TaskSuccessToFailureHandler) GetNotifications(ae *web.App, key *NotificationKey) ([]Email, error)
func (*TaskSuccessToFailureHandler) TemplateNotification ¶
func (self *TaskSuccessToFailureHandler) TemplateNotification(ae *web.App, notification *TriggeredTaskNotification) (Email, error)
type Team ¶
type Team struct { Name string `yaml:"name"` Address string `yaml:"address"` Subscriptions []Subscription `yaml:"subscriptions"` }
stores 10gen team information
type TriggeredBuildNotification ¶
type TriggeredBuildNotification struct { Current *build.Build Previous *build.Build Info []ChangeInfo Key NotificationKey Preface string Transition string }
convenience wrapper about everything we want to know about a build notification before it goes off for templating.
type TriggeredTaskNotification ¶
type TriggeredTaskNotification struct { Current *task.Task Previous *task.Task Info []ChangeInfo Key NotificationKey Preface string Transition string }
convenience wrapper about everything we want to know about a task notification before it goes off for templating.
Source Files ¶
- build_completion_handler.go
- build_failure_handler.go
- build_handler.go
- build_success_handler.go
- build_success_to_failure_handler.go
- email.go
- email_template.go
- mailer.go
- notification_handler.go
- notify.go
- runner.go
- task_completion_handler.go
- task_failure_handler.go
- task_handler.go
- task_success_handler.go
- task_success_to_failure_handler.go