예제 #1
0
func (trig TaskFailTransition) ShouldExecute(ctx triggerContext) (bool, error) {
	if ctx.task.Status != evergreen.TaskFailed {
		return false, nil
	}
	if ctx.previousCompleted == nil {
		return true, nil
	}
	if ctx.previousCompleted.Status == evergreen.TaskSucceeded {
		// the task transitioned to failure - but we will only trigger an alert if we haven't recorded
		// a sent alert for a transition after the same previously passing task.
		q := alertrecord.ByLastFailureTransition(ctx.task.DisplayName, ctx.task.BuildVariant, ctx.task.Project)
		lastAlerted, err := alertrecord.FindOne(q)
		if err != nil {
			return false, err
		}

		if lastAlerted == nil || (lastAlerted.RevisionOrderNumber < ctx.previousCompleted.RevisionOrderNumber) {
			// Either this alert has never been triggered before, or it was triggered for a
			// transition from failure after an older success than this one - so we need to
			// execute this trigger again.
			return true, nil
		}
	}
	return false, nil
}
예제 #2
0
func (trig FirstFailureInTaskType) ShouldExecute(ctx triggerContext) (bool, error) {
	if ctx.task.Status != evergreen.TaskFailed {
		return false, nil
	}
	rec, err := alertrecord.FindOne(alertrecord.ByFirstFailureInTaskType(ctx.task.Version, ctx.task.DisplayName))
	if err != nil {
		return false, nil
	}
	return rec == nil, nil
}
예제 #3
0
func (sthw SpawnTwelveHourWarning) ShouldExecute(ctx triggerContext) (bool, error) {
	if ctx.host == nil || ctx.host.ExpirationTime.IsZero() ||
		ctx.host.ExpirationTime.Sub(time.Now()) > (12*time.Hour) {
		return false, nil
	}
	rec, err := alertrecord.FindOne(alertrecord.ByHostAlertRecordType(ctx.host.Id, alertrecord.SpawnHostTwelveHourWarning))
	if err != nil {
		return false, err
	}
	return rec == nil, nil
}
예제 #4
0
func (sthw SlowProvisionWarning) ShouldExecute(ctx triggerContext) (bool, error) {
	// don't execute if the host is actually provisioned, or if it's been less than 20 minutes
	// since creation time
	if ctx.host.Provisioned == true || ctx.host.CreationTime.Before(time.Now().Add(-20*time.Minute)) {
		return false, nil
	}
	rec, err := alertrecord.FindOne(alertrecord.ByHostAlertRecordType(ctx.host.Id, alertrecord.SlowProvisionWarning))
	if err != nil {
		return false, err
	}
	return rec == nil, nil
}