alerts

package
v0.0.0-...-1d50e38 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 30, 2017 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EmailProvider = "email"
	JiraProvider  = "jira"
)
View Source
const DescriptionTemplateString = `` /* 433-byte string literal not displayed */

DescriptionTemplateString defines the content of the alert ticket.

View Source
const EmailSubjectPrologue = "[Evergreen]"

Variables

View Source
var (
	// AvailableTaskTriggers is a list of all the supported task triggers, which is used by the UI
	// package to generate a control panel for configuring how to react to these triggers.
	AvailableTaskFailTriggers = []Trigger{TaskFailed{},
		FirstFailureInVersion{},
		FirstFailureInVariant{},
		FirstFailureInTaskType{},
		TaskFailTransition{},
	}

	AvailableProjectTriggers = []Trigger{
		LastRevisionNotFound{},
	}

	SpawnWarningTriggers = []Trigger{SpawnTwoHourWarning{}, SpawnTwelveHourWarning{}}
)
View Source
var DescriptionTemplate = template.Must(template.New("Desc").Parse(DescriptionTemplateString))

DescriptionTemplate is filled to create a JIRA alert ticket. Panics at start if invalid.

Functions

func RunHostProvisionFailTriggers

func RunHostProvisionFailTriggers(h *host.Host) error

func RunLastRevisionNotFoundTrigger

func RunLastRevisionNotFoundTrigger(proj *model.ProjectRef, v *version.Version) error

func RunSpawnWarningTriggers

func RunSpawnWarningTriggers(host *host.Host) error

func RunTaskFailureTriggers

func RunTaskFailureTriggers(taskId string) error

RunTaskTriggers queues alerts for any active triggers on the tasks's state change.

Types

type AlertContext

type AlertContext struct {
	AlertRequest *alert.AlertRequest
	ProjectRef   *model.ProjectRef
	Task         *task.Task
	Build        *build.Build
	Version      *version.Version
	Patch        *patch.Patch
	Host         *host.Host
	FailedTests  []task.TestResult
	Settings     *evergreen.Settings
}

AlertContext is the set of full documents in the DB that are associated with the values found in a given AlertRequest

type Deliverer

type Deliverer interface {
	Deliver(AlertContext, model.AlertConfig) error
}

Deliverer is an interface which handles the actual delivery of an alert. (e.g. sending an e-mail, posting to flowdock, etc)

type EmailDeliverer

type EmailDeliverer struct {
	SMTPSettings
	// contains filtered or unexported fields
}

EmailDeliverer is an implementation of Deliverer that sends notifications to an SMTP server

func (*EmailDeliverer) Deliver

func (es *EmailDeliverer) Deliver(alertCtx AlertContext, alertConf model.AlertConfig) error

type FirstFailureInTaskType

type FirstFailureInTaskType struct{}

FirstFailureInVersion is a trigger that queues an alert whenever a task fails for the first time for a task of a given name within a version. For example: "compile" fails on linux-64; ShouldExecute returns true "compile" fails on windows; ShouldExecute returns false because one was already sent for compile. "unit-tests" fails on windows; ShouldExecute returns true because nothing was sent yet for unit-tests. "unit-tests" fails on linux-64; ShouldExecute returns false

func (FirstFailureInTaskType) CreateAlertRecord

func (trig FirstFailureInTaskType) CreateAlertRecord(ctx triggerContext) *alertrecord.AlertRecord

func (FirstFailureInTaskType) Display

func (trig FirstFailureInTaskType) Display() string

func (FirstFailureInTaskType) Id

func (trig FirstFailureInTaskType) Id() string

func (FirstFailureInTaskType) ShouldExecute

func (trig FirstFailureInTaskType) ShouldExecute(ctx triggerContext) (bool, error)

type FirstFailureInVariant

type FirstFailureInVariant struct{}

FirstFailureInVersion is a trigger that queues an alert whenever a task fails for the first time within a variant. After one failure has triggered an alert for this event, subsequent failures will not trigger additional alerts.

func (FirstFailureInVariant) CreateAlertRecord

func (trig FirstFailureInVariant) CreateAlertRecord(ctx triggerContext) *alertrecord.AlertRecord

func (FirstFailureInVariant) Display

func (trig FirstFailureInVariant) Display() string

func (FirstFailureInVariant) Id

func (trig FirstFailureInVariant) Id() string

func (FirstFailureInVariant) ShouldExecute

func (trig FirstFailureInVariant) ShouldExecute(ctx triggerContext) (bool, error)

type FirstFailureInVersion

type FirstFailureInVersion struct{}

FirstFailureInVersion is a trigger that queues an alert whenever a task fails for the first time within a version. After one failure has triggered an alert for this event, subsequent failures will not trigger additional alerts.

func (FirstFailureInVersion) CreateAlertRecord

func (trig FirstFailureInVersion) CreateAlertRecord(ctx triggerContext) *alertrecord.AlertRecord

func (FirstFailureInVersion) Display

func (trig FirstFailureInVersion) Display() string

func (FirstFailureInVersion) Id

func (trig FirstFailureInVersion) Id() string

func (FirstFailureInVersion) ShouldExecute

func (trig FirstFailureInVersion) ShouldExecute(ctx triggerContext) (bool, error)

type LastRevisionNotFound

type LastRevisionNotFound struct{}

func (LastRevisionNotFound) CreateAlertRecord

func (lrnf LastRevisionNotFound) CreateAlertRecord(ctx triggerContext) *alertrecord.AlertRecord

func (LastRevisionNotFound) Display

func (lrnf LastRevisionNotFound) Display() string

func (LastRevisionNotFound) Id

func (lrnf LastRevisionNotFound) Id() string

func (LastRevisionNotFound) ShouldExecute

func (lrnf LastRevisionNotFound) ShouldExecute(ctx triggerContext) (bool, error)

type ProvisionFailed

type ProvisionFailed struct{}

func (ProvisionFailed) CreateAlertRecord

func (pf ProvisionFailed) CreateAlertRecord(ctx triggerContext) *alertrecord.AlertRecord

func (ProvisionFailed) Display

func (pf ProvisionFailed) Display() string

func (ProvisionFailed) Id

func (pf ProvisionFailed) Id() string

func (*ProvisionFailed) ShouldExecute

func (pf *ProvisionFailed) ShouldExecute(ctx triggerContext) (bool, error)

type QueueProcessor

type QueueProcessor struct {
	// contains filtered or unexported fields
}

QueueProcessor handles looping over any unprocessed alerts in the queue and delivers them

func (*QueueProcessor) Deliver

func (qp *QueueProcessor) Deliver(req *alert.AlertRequest, ctx *AlertContext) error

func (*QueueProcessor) Description

func (qp *QueueProcessor) Description() string

func (*QueueProcessor) Name

func (qp *QueueProcessor) Name() string

func (*QueueProcessor) Run

func (qp *QueueProcessor) Run(config *evergreen.Settings) error

Run loops while there are any unprocessed alerts and attempts to deliver them.

type SMTPSettings

type SMTPSettings struct {
	From     string
	Server   string
	Port     int
	UseSSL   bool
	Username string
	Password string
}

type SlowProvisionWarning

type SlowProvisionWarning struct{}

func (SlowProvisionWarning) CreateAlertRecord

func (sthw SlowProvisionWarning) CreateAlertRecord(ctx triggerContext) *alertrecord.AlertRecord

func (SlowProvisionWarning) Display

func (sthw SlowProvisionWarning) Display() string

func (SlowProvisionWarning) Id

func (sthw SlowProvisionWarning) Id() string

func (SlowProvisionWarning) ShouldExecute

func (sthw SlowProvisionWarning) ShouldExecute(ctx triggerContext) (bool, error)

type SpawnFailure

type SpawnFailure struct{}

func (SpawnFailure) CreateAlertRecord

func (sf SpawnFailure) CreateAlertRecord(ctx triggerContext) *alertrecord.AlertRecord

func (SpawnFailure) Display

func (sf SpawnFailure) Display() string

func (SpawnFailure) Id

func (sf SpawnFailure) Id() string

func (SpawnFailure) ShouldExecute

func (sf SpawnFailure) ShouldExecute(ctx triggerContext) (bool, error)

type SpawnTwelveHourWarning

type SpawnTwelveHourWarning struct{}

func (SpawnTwelveHourWarning) CreateAlertRecord

func (sthw SpawnTwelveHourWarning) CreateAlertRecord(ctx triggerContext) *alertrecord.AlertRecord

func (SpawnTwelveHourWarning) Display

func (sthw SpawnTwelveHourWarning) Display() string

func (SpawnTwelveHourWarning) Id

func (sthw SpawnTwelveHourWarning) Id() string

func (SpawnTwelveHourWarning) ShouldExecute

func (sthw SpawnTwelveHourWarning) ShouldExecute(ctx triggerContext) (bool, error)

type SpawnTwoHourWarning

type SpawnTwoHourWarning struct{}

func (SpawnTwoHourWarning) CreateAlertRecord

func (sthw SpawnTwoHourWarning) CreateAlertRecord(ctx triggerContext) *alertrecord.AlertRecord

func (SpawnTwoHourWarning) Display

func (sthw SpawnTwoHourWarning) Display() string

func (SpawnTwoHourWarning) Id

func (sthw SpawnTwoHourWarning) Id() string

func (SpawnTwoHourWarning) ShouldExecute

func (sthw SpawnTwoHourWarning) ShouldExecute(ctx triggerContext) (bool, error)

type TaskFailTransition

type TaskFailTransition struct{}

TaskFailTransition is a trigger that queues an alert iff the following conditions are met: 1) A task fails and the previous completion of this task on the same variant was passing or the task has never run before 2) The most recent alert for this trigger, if existing, was stored when the 'last passing task' at the time was older than the 'last passing task' for the newly failed task. 3) The previous run was a failure, and there has been Multipler*Batchtime time since the previous alert was sent.

func (TaskFailTransition) CreateAlertRecord

func (trig TaskFailTransition) CreateAlertRecord(ctx triggerContext) *alertrecord.AlertRecord

func (TaskFailTransition) Display

func (trig TaskFailTransition) Display() string

func (TaskFailTransition) Id

func (trig TaskFailTransition) Id() string

func (TaskFailTransition) ShouldExecute

func (trig TaskFailTransition) ShouldExecute(ctx triggerContext) (bool, error)

type TaskFailed

type TaskFailed struct{}

TaskFailed is a trigger that queues an alert whenever a task fails, regardless of any alerts generated by previous runs of the task or other tasks within the version/variant/task type.

func (TaskFailed) CreateAlertRecord

func (trig TaskFailed) CreateAlertRecord(_ triggerContext) *alertrecord.AlertRecord

func (TaskFailed) Display

func (trig TaskFailed) Display() string

func (TaskFailed) Id

func (tf TaskFailed) Id() string

func (TaskFailed) ShouldExecute

func (trig TaskFailed) ShouldExecute(ctx triggerContext) (bool, error)

type Trigger

type Trigger interface {
	// Id is a string that identifies this trigger logic. It's used to store in the database for
	// alerts that are queued to identify the reason the alert was generated.
	Id() string

	// Display is a human-readable description of the trigger logic. It may be used in log messages
	// for debugging or for presentation in a UI control panel.
	Display() string

	// ShouldExecute returns a boolean indicating if this trigger's logic has matched and should
	// result in an alert being queued. This logic may involve querying for bookkeeping
	// generated by CreateBookkeepingRecord in previous executions.
	ShouldExecute(ctx triggerContext) (bool, error)

	// CreateAlertRecord returns an instance of AlertRecord which, after insertion, should allow
	// this trigger to detect previous executions of itself in its ShouldExecute function.
	CreateAlertRecord(ctx triggerContext) *alertrecord.AlertRecord
}

Trigger is a rule that determines if an alert should be queued for some event.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL