event

package
v0.0.0-...-5f5e9cb Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2026 License: Apache-2.0 Imports: 20 Imported by: 88

Documentation

Overview

Package event models events in the system, which trigger actions to occur. Events are processed asynchronously by a job in the units package.

Index

Constants

View Source
const (
	ResourceTypeAdmin     = "ADMIN"
	EventTypeValueChanged = "CONFIG_VALUE_CHANGED"
)
View Source
const (
	ResourceTypeBuild = "BUILD"

	BuildStateChange         = "STATE_CHANGE"
	BuildGithubCheckFinished = "GITHUB_CHECK_FINISHED"
)
View Source
const (
	// resource type
	ResourceTypeDistro = "DISTRO"

	// event types
	EventDistroAdded      = "DISTRO_ADDED"
	EventDistroModified   = "DISTRO_MODIFIED"
	EventDistroAMIModfied = "DISTRO_AMI_MODIFIED"
	EventDistroRemoved    = "DISTRO_REMOVED"
)
View Source
const (
	// resource type
	ResourceTypeHost = "HOST"

	// event types
	EventHostCreated                                 = "HOST_CREATED"
	EventHostCreatedError                            = "HOST_CREATED_ERROR"
	EventSpawnHostCreatedError                       = "SPAWN_HOST_CREATED_ERROR"
	EventHostStarted                                 = "HOST_STARTED"
	EventHostStopped                                 = "HOST_STOPPED"
	EventHostRebooted                                = "HOST_REBOOTED"
	EventHostModified                                = "HOST_MODIFIED"
	EventHostAgentDeployed                           = "HOST_AGENT_DEPLOYED"
	EventHostAgentDeployFailed                       = "HOST_AGENT_DEPLOY_FAILED"
	EventHostAgentMonitorDeployed                    = "HOST_AGENT_MONITOR_DEPLOYED"
	EventHostAgentMonitorDeployFailed                = "HOST_AGENT_MONITOR_DEPLOY_FAILED"
	EventHostJasperRestarting                        = "HOST_JASPER_RESTARTING"
	EventHostJasperRestarted                         = "HOST_JASPER_RESTARTED"
	EventHostJasperRestartError                      = "HOST_JASPER_RESTART_ERROR"
	EventHostConvertingProvisioning                  = "HOST_CONVERTING_PROVISIONING"
	EventHostConvertedProvisioning                   = "HOST_CONVERTED_PROVISIONING"
	EventHostConvertingProvisioningError             = "HOST_CONVERTING_PROVISIONING_ERROR"
	EventHostStatusChanged                           = "HOST_STATUS_CHANGED"
	EventHostDNSNameSet                              = "HOST_DNS_NAME_SET"
	EventHostProvisionError                          = "HOST_PROVISION_ERROR"
	EventHostProvisionFailed                         = "HOST_PROVISION_FAILED"
	EventHostProvisioned                             = "HOST_PROVISIONED"
	EventHostRunningTaskSet                          = "HOST_RUNNING_TASK_SET"
	EventHostRunningTaskCleared                      = "HOST_RUNNING_TASK_CLEARED"
	EventHostTaskFinished                            = "HOST_TASK_FINISHED"
	EventHostTerminatedExternally                    = "HOST_TERMINATED_EXTERNALLY"
	EventHostExpirationWarningSent                   = "HOST_EXPIRATION_WARNING_SENT"
	EventHostTemporaryExemptionExpirationWarningSent = "HOST_TEMPORARY_EXEMPTION_EXPIRATION_WARNING_SENT"
	EventSpawnHostIdleNotification                   = "HOST_IDLE_NOTIFICATION"
	EventAlertableInstanceTypeWarningSent            = "HOST_ALERTABLE_INSTANCE_TYPE_WARNING_SENT"
	EventHostScriptExecuted                          = "HOST_SCRIPT_EXECUTED"
	EventHostScriptExecuteFailed                     = "HOST_SCRIPT_EXECUTE_FAILED"
	EventVolumeExpirationWarningSent                 = "VOLUME_EXPIRATION_WARNING_SENT"
	EventVolumeMigrationFailed                       = "VOLUME_MIGRATION_FAILED"
)
View Source
const (
	ResourceTypePatch = "PATCH"

	PatchStateChange        = "STATE_CHANGE"
	PatchChildrenCompletion = "CHILDREN_FINISHED"
)
View Source
const (
	EventResourceTypeProject         = "PROJECT"
	EventTypeProjectModified         = "PROJECT_MODIFIED"
	EventTypeProjectAdded            = "PROJECT_ADDED"
	EventTypeProjectAttachedToRepo   = "PROJECT_ATTACHED_TO_REPO"
	EventTypeProjectDetachedFromRepo = "PROJECT_DETACHED_FROM_REPO"
)
View Source
const (
	GithubPullRequestSubscriberType = "github_pull_request"
	GithubCheckSubscriberType       = "github_check"
	GithubMergeSubscriberType       = "github_merge"
	JIRAIssueSubscriberType         = "jira-issue"
	JIRACommentSubscriberType       = "jira-comment"
	EvergreenWebhookSubscriberType  = "evergreen-webhook"
	EmailSubscriberType             = "email"
	SlackSubscriberType             = "slack"
	SubscriberTypeNone              = "none"
	RunChildPatchSubscriberType     = "run-child-patch"
)
View Source
const (
	OwnerTypePerson                        OwnerType = "person"
	OwnerTypeProject                       OwnerType = "project"
	TaskDurationKey                                  = "task-duration-secs"
	TaskPercentChangeKey                             = "task-percent-change"
	BuildDurationKey                                 = "build-duration-secs"
	BuildPercentChangeKey                            = "build-percent-change"
	VersionDurationKey                               = "version-duration-secs"
	VersionPercentChangeKey                          = "version-percent-change"
	TestRegexKey                                     = "test-regex"
	RenotifyIntervalKey                              = "renotify-interval"
	GeneralSubscriptionPatchOutcome                  = "patch-outcome"
	GeneralSubscriptionPatchFirstFailure             = "patch-first-failure"
	GeneralSubscriptionBuildBreak                    = "build-break"
	GeneralSubscriptionSpawnhostExpiration           = "spawnhost-expiration"
	GeneralSubscriptionSpawnHostOutcome              = "spawnhost-outcome"

	ObjectTask    = "task"
	ObjectVersion = "version"
	ObjectBuild   = "build"
	ObjectHost    = "host"
	ObjectPatch   = "patch"

	TriggerOutcome = "outcome"
	// TriggerFamilyOutcome indicates that a patch or version completed,
	// and all their child patches (if there are any) have also completed.
	TriggerFamilyOutcome             = "family-outcome"
	TriggerGithubCheckOutcome        = "github-check-outcome"
	TriggerFailure                   = "failure"
	TriggerFamilyFailure             = "family-failure"
	TriggerSuccess                   = "success"
	TriggerFamilySuccess             = "family-success"
	TriggerRegression                = "regression"
	TriggerExceedsDuration           = "exceeds-duration"
	TriggerSuccessfulExceedsDuration = "successful-exceeds-duration"
	TriggerRuntimeChangeByPercent    = "runtime-change"
	TriggerExpiration                = "expiration"
	TriggerPatchStarted              = "started"
	TriggerTaskFirstFailureInVersion = "first-failure-in-version"
	TriggerTaskStarted               = "task-started"
	TriggerSpawnHostIdle             = "spawn-host-idle"
	TriggerAlertableInstanceType     = "alertable-instance-type"
)
View Source
const (
	SelectorObject       = "object"
	SelectorID           = "id"
	SelectorProject      = "project"
	SelectorOwner        = "owner"
	SelectorRequester    = "requester"
	SelectorStatus       = "status"
	SelectorDisplayName  = "display-name"
	SelectorBuildVariant = "build-variant"
	SelectorInVersion    = "in-version"
	SelectorInBuild      = "in-build"
)
View Source
const (
	// resource type
	ResourceTypeTask = "TASK"

	// event types
	TaskCreated                = "TASK_CREATED"
	TaskDispatched             = "TASK_DISPATCHED"
	TaskUndispatched           = "TASK_UNDISPATCHED"
	TaskStarted                = "TASK_STARTED"
	TaskFinished               = "TASK_FINISHED"
	TaskBlocked                = "TASK_BLOCKED"
	TaskRestarted              = "TASK_RESTARTED"
	TaskActivated              = "TASK_ACTIVATED"
	TaskDeactivated            = "TASK_DEACTIVATED"
	TaskAbortRequest           = "TASK_ABORT_REQUEST"
	ContainerAllocated         = "CONTAINER_ALLOCATED"
	TaskPriorityChanged        = "TASK_PRIORITY_CHANGED"
	TaskJiraAlertCreated       = "TASK_JIRA_ALERT_CREATED"
	TaskDependenciesOverridden = "TASK_DEPENDENCIES_OVERRIDDEN"
)
View Source
const (
	ResourceTypeVersion        = "VERSION"
	VersionStateChange         = "STATE_CHANGE"
	VersionGithubCheckFinished = "GITHUB_CHECK_FINISHED"
	VersionChildrenCompletion  = "CHILDREN_FINISHED"
)
View Source
const EventCollection = "events"
View Source
const (
	ResourceTypeUser = "USER"
)
View Source
const (
	SubscriptionsCollection = "subscriptions"
)

Variables

View Source
var (
	TimestampKey    = bsonutil.MustHaveTag(EventLogEntry{}, "Timestamp")
	ResourceIdKey   = bsonutil.MustHaveTag(EventLogEntry{}, "ResourceId")
	ResourceTypeKey = bsonutil.MustHaveTag(EventLogEntry{}, "ResourceType")

	TypeKey = bsonutil.MustHaveTag(EventLogEntry{}, "EventType")
	DataKey = bsonutil.MustHaveTag(EventLogEntry{}, "Data")
)

Functions

func AdminEventsBefore

func AdminEventsBefore(before time.Time, n int) db.Q

func AllRecentHostEventsAreSystemFailed

func AllRecentHostEventsAreSystemFailed(ctx context.Context, hostId string, hostProvisionTime time.Time, n int) bool

AllRecentHostEventsAreSystemFailed returns true if all recent host events are system failures, and false if any are not. Only takes into account task finished events that occurred since the last time the task started running.

func ByAdminGuid

func ByAdminGuid(guid string) db.Q

ByAdminGuid returns a query for the admin events with the given guid.

func CopyProjectSubscriptions

func CopyProjectSubscriptions(ctx context.Context, oldProject, newProject string) error

CopyProjectSubscriptions copies subscriptions from the first project for the second project.

func CountUnprocessedEvents

func CountUnprocessedEvents(ctx context.Context) (int, error)

func GetEventTypesForHost

func GetEventTypesForHost(ctx context.Context, hostID string, tag string) ([]string, error)

GetEventTypesForHost returns the event types that have occurred on the host.

func GetSubscriptionTarget

func GetSubscriptionTarget[T any](s Subscription) (*T, error)

GetSubscriptionTarget asserts a type on the subscription's subscriber's target and if it is not found, returns an error.

func HasNoRecentStoppedHostEvent

func HasNoRecentStoppedHostEvent(ctx context.Context, id string, ts time.Time) (bool, error)

HasNoRecentStoppedHostEvent returns true if no host event exists that is more recent than the passed in time stamp.

func HostEvents

func HostEvents(opts HostEventsOpts) db.Q

HostEvents builds a query that can be used to return the n = opts.Limit events that satisfy the filters and sorting method provided in opts.

func IsValidOwnerType

func IsValidOwnerType(in string) bool

func LogAdminEvent

func LogAdminEvent(ctx context.Context, section string, before, after evergreen.ConfigSection, user string) error

func LogAlertableInstanceTypeWarningSent

func LogAlertableInstanceTypeWarningSent(ctx context.Context, hostID string)

LogAlertableInstanceTypeWarningSent logs an event warning about the host using an alertable instance type.

func LogBuildGithubCheckFinishedEvent

func LogBuildGithubCheckFinishedEvent(ctx context.Context, id, status string)

func LogBuildStateChangeEvent

func LogBuildStateChangeEvent(ctx context.Context, id, status string)

func LogContainerTaskDispatched

func LogContainerTaskDispatched(ctx context.Context, taskID string, execution int, podID string)

LogContainerTaskDispatched logs an event for a container task being dispatched to a pod.

func LogContainerTaskFinished

func LogContainerTaskFinished(ctx context.Context, taskID string, execution int, podID, status string)

LogContainerTaskFinished logs an event for a container task being marked finished. If it was assigned to run on a pod, it logs an additional pod event indicating that its assigned task has finished.

func LogDistroAMIModified

func LogDistroAMIModified(ctx context.Context, distroId, userId string)

LogDistroAMIModified logs when the default region's AMI is modified.

func LogDistroAdded

func LogDistroAdded(ctx context.Context, distroId, userId string, data any)

LogDistroAdded should take in DistroData in order to preserve the ProviderSettingsList

func LogDistroEvent

func LogDistroEvent(ctx context.Context, distroId string, eventType string, eventData DistroEventData)

func LogDistroModified

func LogDistroModified(ctx context.Context, distroId, userId string, before, after any)

LogDistroModified should take in DistroData in order to preserve the ProviderSettingsList

func LogDistroRemoved

func LogDistroRemoved(ctx context.Context, distroId, userId string, data any)

LogDistroRemoved should take in DistroData in order to preserve the ProviderSettingsList

func LogHostAgentDeployFailed

func LogHostAgentDeployFailed(ctx context.Context, hostID string, err error)

func LogHostAgentDeployed

func LogHostAgentDeployed(ctx context.Context, hostID string)

func LogHostAgentMonitorDeployFailed

func LogHostAgentMonitorDeployFailed(ctx context.Context, hostID string, err error)

func LogHostAgentMonitorDeployed

func LogHostAgentMonitorDeployed(ctx context.Context, hostID string)

func LogHostConvertedProvisioning

func LogHostConvertedProvisioning(ctx context.Context, hostID, method string)

func LogHostConvertingProvisioning

func LogHostConvertingProvisioning(ctx context.Context, hostID, method, user string)

func LogHostConvertingProvisioningError

func LogHostConvertingProvisioningError(ctx context.Context, hostID string, err error)

func LogHostCreated

func LogHostCreated(ctx context.Context, hostId string)

LogHostCreated logs an event indicating that the host was created.

func LogHostCreatedError

func LogHostCreatedError(ctx context.Context, hostID, logs string)

LogHostCreatedError logs an event indicating that the host errored while it was being created.

func LogHostDNSNameSet

func LogHostDNSNameSet(ctx context.Context, hostID string, dnsName string)

func LogHostEvent

func LogHostEvent(ctx context.Context, hostId string, eventType string, eventData HostEventData)

func LogHostJasperRestartError

func LogHostJasperRestartError(ctx context.Context, hostID string, err error)

func LogHostJasperRestarted

func LogHostJasperRestarted(ctx context.Context, hostID, revision string)

func LogHostJasperRestarting

func LogHostJasperRestarting(ctx context.Context, hostID, user string)

func LogHostModifyError

func LogHostModifyError(ctx context.Context, hostID, logs string)

LogHostModifyError logs an event indicating that the host errored while being modified.

func LogHostModifySucceeded

func LogHostModifySucceeded(ctx context.Context, hostID, source string)

LogHostModifySucceeded logs an event indicating that the host was successfully modified.

func LogHostProvisionError

func LogHostProvisionError(ctx context.Context, hostID string)

LogHostProvisionError is used to log each failed provision attempt

func LogHostProvisionFailed

func LogHostProvisionFailed(ctx context.Context, hostID string, setupLogs string)

LogHostProvisionFailed is used when Evergreen gives up on provisioning a host after several retries.

func LogHostProvisioned

func LogHostProvisioned(ctx context.Context, hostID string)

func LogHostRebootError

func LogHostRebootError(ctx context.Context, hostID, source, logs string)

LogHostRebootError logs an event indicating that the host errored while rebooting.

func LogHostRebootSucceeded

func LogHostRebootSucceeded(ctx context.Context, hostID, source string)

LogHostRebootSucceeded logs an event indicating that the host was successfully rebooted.

func LogHostRunningTaskCleared

func LogHostRunningTaskCleared(ctx context.Context, hostID string, taskId string, taskExecution int)

func LogHostRunningTaskSet

func LogHostRunningTaskSet(ctx context.Context, hostID string, taskId string, taskExecution int)

func LogHostScriptExecuteFailed

func LogHostScriptExecuteFailed(ctx context.Context, hostID, logs string, err error)

func LogHostScriptExecuted

func LogHostScriptExecuted(ctx context.Context, hostID string, logs string)

func LogHostStartError

func LogHostStartError(ctx context.Context, hostID, source, logs string)

LogHostStartError logs an event indicating that the host errored while starting.

func LogHostStartSucceeded

func LogHostStartSucceeded(ctx context.Context, hostID string, source string)

LogHostStartSucceeded logs an event indicating that the host was successfully started.

func LogHostStatusChanged

func LogHostStatusChanged(ctx context.Context, hostId, oldStatus, newStatus, user string, logs string)

func LogHostStopError

func LogHostStopError(ctx context.Context, hostID, source, logs string)

LogHostStopError logs an event indicating that the host errored while stopping.

func LogHostStopSucceeded

func LogHostStopSucceeded(ctx context.Context, hostID, source string)

LogHostStopSucceeded logs an event indicating that the host was successfully stopped.

func LogHostTaskDispatched

func LogHostTaskDispatched(ctx context.Context, taskId string, execution int, hostId string)

LogHostTaskDispatched logs an event for a host task being dispatched.

func LogHostTaskFinished

func LogHostTaskFinished(ctx context.Context, taskId string, execution int, hostId, status string)

LogHostTaskFinished logs an event for a host task being marked finished. If it was assigned to run on a host, it logs an additional host event indicating that its assigned task has finished.

func LogHostTaskUndispatched

func LogHostTaskUndispatched(ctx context.Context, taskId string, execution int, hostId string)

LogHostTaskUndispatched logs an event for a host being marked undispatched.

func LogHostTemporaryExemptionExpirationWarningSent

func LogHostTemporaryExemptionExpirationWarningSent(ctx context.Context, hostID string)

LogHostTemporaryExemptionExpirationWarningSent logs an event warning about the host's temporary exemption, which is about to expire.

func LogHostTerminatedExternally

func LogHostTerminatedExternally(ctx context.Context, hostID, oldStatus string)

func LogJiraIssueCreated

func LogJiraIssueCreated(ctx context.Context, taskId string, execution int, jiraIssue string)

func LogManyEvents

func LogManyEvents(ctx context.Context, events []EventLogEntry) error

func LogManyHostsCreated

func LogManyHostsCreated(ctx context.Context, hostIDs []string)

LogManyHostsCreated is the same as LogHostCreated but for multiple hosts.

func LogManyTaskAbortRequests

func LogManyTaskAbortRequests(ctx context.Context, taskIds []string, userId string)

LogManyTaskAbortRequests updates the DB with task abort request events.

func LogManyTaskPriority

func LogManyTaskPriority(ctx context.Context, taskIds []string, userId string, priority int64)

LogManyTaskPriority updates the DB with a task started events.

func LogManyTasksBlocked

func LogManyTasksBlocked(ctx context.Context, data []TaskBlockedData)

LogManyTasksBlocked logs many task blocked events.

func LogManyUnorderedEventsWithContext

func LogManyUnorderedEventsWithContext(ctx context.Context, events []EventLogEntry) error

LogManyUnorderedEventsWithContext logs many events without any ordering on insertion. Do not use this if the events must be inserted in order.

func LogPatchChildrenCompletionEvent

func LogPatchChildrenCompletionEvent(ctx context.Context, id, status, author string)

func LogPatchStateChangeEvent

func LogPatchStateChangeEvent(ctx context.Context, id, newStatus string)

func LogPodAssignedTask

func LogPodAssignedTask(ctx context.Context, id, taskID string, execution int)

LogPodAssignedTask logs an event indicating that the pod has been assigned a task to run.

func LogPodEvent

func LogPodEvent(ctx context.Context, id string, kind PodEventType, data PodData)

LogPodEvent logs an event for a pod to the event log.

func LogPodRunningTaskCleared

func LogPodRunningTaskCleared(ctx context.Context, id, taskID string, execution int)

LogPodRunningTaskCleared logs an event indicating that the pod's current running task has been cleared, so it is no longer assigned to run the task.

func LogPodStatusChanged

func LogPodStatusChanged(ctx context.Context, id, oldStatus, newStatus, reason string)

LogPodStatusChanged logs an event indicating that the pod's status has been updated.

func LogSpawnHostCreatedError

func LogSpawnHostCreatedError(ctx context.Context, hostID, logs string)

LogSpawnHostCreatedError is the same as LogHostCreatedError but specifically for spawn hosts. The spawn host event is separate from the more general host creation errors to make notifications on spawn host creation errors more efficient.

func LogSpawnHostIdleNotification

func LogSpawnHostIdleNotification(ctx context.Context, hostID string)

LogSpawnHostIdleNotification logs an event for the spawn host being idle.

func LogSpawnhostExpirationWarningSent

func LogSpawnhostExpirationWarningSent(ctx context.Context, hostID string)

func LogTaskAbortRequest

func LogTaskAbortRequest(ctx context.Context, taskId string, execution int, userId string)

LogTaskAbortRequest updates the DB with a task abort request event.

func LogTaskActivated

func LogTaskActivated(ctx context.Context, taskId string, execution int, userId string)

LogTaskActivated updates the DB with a task activated event.

func LogTaskContainerAllocated

func LogTaskContainerAllocated(ctx context.Context, taskId string, execution int, containerAllocatedTime time.Time)

LogTaskContainerAllocated updates the DB with a container allocated event.

func LogTaskCreated

func LogTaskCreated(ctx context.Context, taskId string, execution int)

func LogTaskDependenciesOverridden

func LogTaskDependenciesOverridden(ctx context.Context, taskId string, execution int, userID string)

LogTaskDependenciesOverridden updates the DB with a task dependencies overridden event.

func LogTaskFinished

func LogTaskFinished(ctx context.Context, taskId string, execution int, status string)

LogTaskFinished logs an event indicating that the task has finished.

func LogTaskPriority

func LogTaskPriority(ctx context.Context, taskId string, execution int, userId string, priority int64)

func LogTaskRestarted

func LogTaskRestarted(ctx context.Context, taskId string, execution int, userId string)

LogTaskRestarted updates the DB with a task restarted event.

func LogTaskStarted

func LogTaskStarted(ctx context.Context, taskId string, execution int)

func LogUserEvent

func LogUserEvent(ctx context.Context, user string, eventType UserEventType, before, after any) error

LogUserEvent logs a DB User change to the event log collection.

func LogVersionChildrenCompletionEvent

func LogVersionChildrenCompletionEvent(ctx context.Context, id, status, author string)

func LogVersionGithubCheckFinishedEvent

func LogVersionGithubCheckFinishedEvent(ctx context.Context, id, newStatus string)

func LogVersionStateChangeEvent

func LogVersionStateChangeEvent(ctx context.Context, id, newStatus string)

func LogVolumeExpirationWarningSent

func LogVolumeExpirationWarningSent(ctx context.Context, volumeID string)

func LogVolumeMigrationFailed

func LogVolumeMigrationFailed(ctx context.Context, hostID string, err error)

LogVolumeMigrationFailed is used when a volume is unable to migrate to a new host.

func MostRecentPodEvents

func MostRecentPodEvents(id string, n int) db.Q

MostRecentPodEvents creates a query to find the n most recent pod events for the given pod ID.

func MostRecentTaskEvents

func MostRecentTaskEvents(id string, n int) db.Q

func RecentAdminEvents

func RecentAdminEvents(n int) db.Q

Admin Events RecentAdminEvents returns the N most recent admin events

func RemoveSubscription

func RemoveSubscription(ctx context.Context, id string) error

func ResourceTypeKeyIs

func ResourceTypeKeyIs(key string) bson.M

func RevertConfig

func RevertConfig(ctx context.Context, guid string, user string) error

RevertConfig reverts one config section to the before state of the specified GUID in the event log

func TaskEventsForId

func TaskEventsForId(id string) db.Q

Task Events

func TaskEventsInOrder

func TaskEventsInOrder(id string) db.Q

Types

type AdminEventData

type AdminEventData struct {
	GUID    string           `bson:"guid" json:"guid"`
	User    string           `bson:"user" json:"user"`
	Section string           `bson:"section" json:"section"`
	Changes ConfigDataChange `bson:"changes" json:"changes"`
}

AdminEventData holds all potential data properties of a logged admin event

type Attributes

type Attributes struct {
	Object       []string
	ID           []string
	Project      []string
	Owner        []string
	Requester    []string
	Status       []string
	DisplayName  []string
	BuildVariant []string
	InVersion    []string
	InBuild      []string
}

Attributes describes the properties of an event to be matched with subscription filters.

func (*Attributes) ToSelectorMap

func (a *Attributes) ToSelectorMap() map[string][]string

ToSelectorMap returns a map of selector types to the values they correspond to in Attributes.

type BuildEventData

type BuildEventData struct {
	Status            string `bson:"status,omitempty" json:"status,omitempty"`
	GithubCheckStatus string `bson:"github_check_status,omitempty" json:"github_check_status,omitempty"`
}

type ChildPatchSubscriber

type ChildPatchSubscriber struct {
	ParentStatus string `bson:"parent_status"`
	ChildPatchId string `bson:"child_patch_id"`
	Requester    string `bson:"requester"`
}

type ConfigDataChange

type ConfigDataChange struct {
	Before evergreen.ConfigSection `bson:"before" json:"before"`
	After  evergreen.ConfigSection `bson:"after" json:"after"`
}

type DistroEventData

type DistroEventData struct {
	DistroId string `bson:"d_id,omitempty" json:"d_id,omitempty"`
	User     string `bson:"user,omitempty" json:"user,omitempty"`
	Before   any    `bson:"before" json:"before"`
	After    any    `bson:"after" json:"after"`

	// Fields used by legacy UI
	Data   any    `bson:"dstr,omitempty" json:"dstr,omitempty"`
	UserId string `bson:"u_id,omitempty" json:"u_id,omitempty"`
}

DistroEventData implements EventData.

type EventLogEntry

type EventLogEntry struct {
	ID           string    `bson:"_id" json:"-"`
	ResourceType string    `bson:"r_type,omitempty" json:"resource_type,omitempty"`
	ProcessedAt  time.Time `bson:"processed_at" json:"processed_at"`

	Timestamp  time.Time `bson:"ts" json:"timestamp"`
	Expirable  bool      `bson:"expirable,omitempty" json:"expirable,omitempty"`
	ResourceId string    `bson:"r_id" json:"resource_id"`
	EventType  string    `bson:"e_type" json:"event_type"`
	Data       any       `bson:"data" json:"data"`
}

func Find

func Find(ctx context.Context, query db.Q) ([]EventLogEntry, error)

Find takes a collection storing events and a query, generated by one of the query functions, and returns a slice of events.

func FindAdmin

func FindAdmin(ctx context.Context, query db.Q) ([]EventLogEntry, error)

func FindAllByResourceID

func FindAllByResourceID(ctx context.Context, resourceID string) ([]EventLogEntry, error)

func FindByID

func FindByID(ctx context.Context, eventID string) (*EventLogEntry, error)

FindByID finds a single event matching the given event ID.

func FindLastProcessedEvent

func FindLastProcessedEvent(ctx context.Context) (*EventLogEntry, error)

func FindLatestAMIModifiedDistroEvent

func FindLatestAMIModifiedDistroEvent(ctx context.Context, id string) (EventLogEntry, error)

FindLatestAMIModifiedDistroEvent returns the most recent AMI event. Returns an empty struct if nothing exists.

func FindLatestAdminEvents

func FindLatestAdminEvents(ctx context.Context, n int, before time.Time) ([]EventLogEntry, error)

FindLatestAdminEvents return the n most recent admin events before the given timestamp.

func FindLatestPrimaryDistroEvents

func FindLatestPrimaryDistroEvents(ctx context.Context, id string, n int, before time.Time) ([]EventLogEntry, error)

FindLatestPrimaryDistroEvents return the most recent non-AMI events for the distro. The before parameter returns only events before the specified time and is used for pagination on the UI.

func FindPaginatedWithTotalCount

func FindPaginatedWithTotalCount(ctx context.Context, query db.Q, limit, page int) ([]EventLogEntry, int, error)

func FindUnprocessedEvents

func FindUnprocessedEvents(ctx context.Context, limit int) ([]EventLogEntry, error)

FindUnprocessedEvents returns all unprocessed events in EventCollection. Events are considered unprocessed if their "processed_at" time IsZero

func GetPaginatedHostEvents

func GetPaginatedHostEvents(ctx context.Context, opts PaginatedHostEventsOpts) ([]EventLogEntry, int, error)

GetPaginatedHostEvents returns a limited and paginated list of host events for the given filters sorted in ascending or descending order by timestamp, as well as the total number of host events.

func GetTaskActivatedEvent

func GetTaskActivatedEvent(taskId string, execution int, userId string) EventLogEntry

GetTaskActivatedEvent retrieves the task activated event.

func GetTaskDeactivatedEvent

func GetTaskDeactivatedEvent(taskId string, execution int, userId string) EventLogEntry

GetTaskDeactivatedEvent retrieves the task deactivated event.

func MostRecentPaginatedPodEvents

func MostRecentPaginatedPodEvents(ctx context.Context, id string, limit, page int) ([]EventLogEntry, int, error)

MostRecentPaginatedPodEvents returns a limited and paginated list of pod events for the given pod ID sorted in descending order by timestamp as well as the total number of events.

func (*EventLogEntry) Log

func (e *EventLogEntry) Log(ctx context.Context) error

func (*EventLogEntry) MarkProcessed

func (e *EventLogEntry) MarkProcessed(ctx context.Context) error

func (*EventLogEntry) MarshalBSON

func (e *EventLogEntry) MarshalBSON() ([]byte, error)

func (*EventLogEntry) Processed

func (e *EventLogEntry) Processed() (bool, time.Time)

Processed is whether or not this event has been processed. An event which has been processed has successfully have notifications intents created and stored, but does not indicate whether or not these notifications have been successfully sent to all recipients If true, the time is the time that this event was marked as processed. If false, time is the zero time

func (*EventLogEntry) SetBSON

func (e *EventLogEntry) SetBSON(raw mgobson.Raw) error

func (*EventLogEntry) UnmarshalBSON

func (e *EventLogEntry) UnmarshalBSON(in []byte) error

type Filter

type Filter struct {
	Object       string `bson:"object,omitempty"`
	ID           string `bson:"id,omitempty"`
	Project      string `bson:"project,omitempty"`
	Owner        string `bson:"owner,omitempty"`
	Requester    string `bson:"requester,omitempty"`
	Status       string `bson:"status,omitempty"`
	DisplayName  string `bson:"display_name,omitempty"`
	BuildVariant string `bson:"build_variant,omitempty"`
	InVersion    string `bson:"in_version,omitempty"`
	InBuild      string `bson:"in_build,omitempty"`
}

Filter specifies the event properties that are of interest.

func (*Filter) FromSelectors

func (f *Filter) FromSelectors(selectors []Selector) error

FromSelectors sets the filter's properties from the selectors' data.

type GithubCheckSubscriber

type GithubCheckSubscriber struct {
	Owner string `bson:"owner"`
	Repo  string `bson:"repo"`
	Ref   string `bson:"ref"`
}

func (*GithubCheckSubscriber) String

func (s *GithubCheckSubscriber) String() string

type GithubMergeSubscriber

type GithubMergeSubscriber struct {
	Owner   string `bson:"owner"`
	Repo    string `bson:"repo"`
	Ref     string `bson:"ref"`
	ChildId string `bson:"child"`
}

func (*GithubMergeSubscriber) String

func (s *GithubMergeSubscriber) String() string

type GithubPullRequestSubscriber

type GithubPullRequestSubscriber struct {
	Owner    string `bson:"owner"`
	Repo     string `bson:"repo"`
	PRNumber int    `bson:"pr_number"`
	Ref      string `bson:"ref"`
	ChildId  string `bson:"child"`
}

func (*GithubPullRequestSubscriber) String

func (s *GithubPullRequestSubscriber) String() string

type HostEventData

type HostEventData struct {
	AgentRevision      string        `bson:"a_rev,omitempty" json:"agent_revision,omitempty"`
	AgentBuild         string        `bson:"a_build,omitempty" json:"agent_build,omitempty"`
	JasperRevision     string        `bson:"j_rev,omitempty" json:"jasper_revision,omitempty"`
	OldStatus          string        `bson:"o_s,omitempty" json:"old_status,omitempty"`
	NewStatus          string        `bson:"n_s,omitempty" json:"new_status,omitempty"`
	Logs               string        `bson:"log,omitempty" json:"logs,omitempty"`
	Hostname           string        `bson:"hn,omitempty" json:"hostname,omitempty"`
	ProvisioningMethod string        `bson:"prov_method" json:"provisioning_method,omitempty"`
	TaskId             string        `bson:"t_id,omitempty" json:"task_id,omitempty"`
	TaskPid            string        `bson:"t_pid,omitempty" json:"task_pid,omitempty"`
	TaskStatus         string        `bson:"t_st,omitempty" json:"task_status,omitempty"`
	Execution          string        `bson:"execution,omitempty" json:"execution,omitempty"`
	MonitorOp          string        `bson:"monitor_op,omitempty" json:"monitor,omitempty"`
	User               string        `bson:"usr" json:"user,omitempty"`
	Successful         bool          `bson:"successful,omitempty" json:"successful"`
	Duration           time.Duration `bson:"duration,omitempty" json:"duration"`
	// Source is the source of a host modification. Only set in specific
	// conditions where a notification may need to know the cause of a host
	// being modified.
	Source string `bson:"source,omitempty" json:"source,omitempty"`
}

implements EventData

type HostEventsOpts

type HostEventsOpts struct {
	ID         string
	Tag        string
	Limit      int
	SortAsc    bool
	EventTypes []string
}

HostEventsOpts represent filter arguments to the HostEvents function.

type JIRAIssueSubscriber

type JIRAIssueSubscriber struct {
	Project   string `bson:"project"`
	IssueType string `bson:"issue_type"`
}

func (*JIRAIssueSubscriber) String

func (s *JIRAIssueSubscriber) String() string

type OwnerType

type OwnerType string

type PaginatedHostEventsOpts

type PaginatedHostEventsOpts struct {
	ID         string
	Tag        string
	Limit      int
	Page       int
	SortAsc    bool
	EventTypes []string
}

PaginatedHostEventsOpts represent filter arguments to the GetPaginatedHostEvents function.

type PatchEventData

type PatchEventData struct {
	Status string `bson:"status,omitempty" json:"status,omitempty"`
	Author string `bson:"author,omitempty" json:"author,omitempty"`
}

type PodData

type PodData struct {
	OldStatus string `bson:"old_status,omitempty" json:"old_status,omitempty"`
	NewStatus string `bson:"new_status,omitempty" json:"new_status,omitempty"`
	Reason    string `bson:"reason,omitempty" json:"reason,omitempty"`

	// Fields related to pods running tasks
	TaskID        string `bson:"task_id,omitempty" json:"task_id,omitempty"`
	TaskExecution int    `bson:"task_execution,omitempty" json:"task_execution,omitempty"`
	TaskStatus    string `bson:"task_status,omitempty" json:"task_status,omitempty"`
}

PodData contains information relevant to a pod event.

type PodEventType

type PodEventType string

PodEventType represents a type of event related to a pod.

const (
	// ResourceTypePod represents a pod as a resource associated with events.
	ResourceTypePod = "POD"

	// EventPodStatusChange represents an event where a pod's status is
	// modified.
	EventPodStatusChange PodEventType = "STATUS_CHANGE"
	// EventPodAssignedTask represents an event where a pod is assigned a task
	// to run.
	EventPodAssignedTask PodEventType = "ASSIGNED_TASK"
	// EventPodClearedTask represents an event where a pod's current running
	// task is cleared.
	EventPodClearedTask PodEventType = "CLEARED_TASK"
	// EventPodFinishedTask represents an event where a pod's assigned task has
	// finished running.
	EventPodFinishedTask PodEventType = "CONTAINER_TASK_FINISHED"
)

type Selector

type Selector struct {
	Type string `bson:"type"`
	Data string `bson:"data"`
}

type Subscriber

type Subscriber struct {
	Type string `bson:"type"`
	// sad violin
	Target any `bson:"target"`
}

func NewEmailSubscriber

func NewEmailSubscriber(t string) Subscriber

func NewGithubCheckAPISubscriber

func NewGithubCheckAPISubscriber(s GithubCheckSubscriber) Subscriber

func NewGithubMergeAPISubscriber

func NewGithubMergeAPISubscriber(s GithubMergeSubscriber) Subscriber

func NewGithubStatusAPISubscriber

func NewGithubStatusAPISubscriber(s GithubPullRequestSubscriber) Subscriber

func NewRunChildPatchSubscriber

func NewRunChildPatchSubscriber(s ChildPatchSubscriber) Subscriber

func NewSlackSubscriber

func NewSlackSubscriber(t string) Subscriber

func (*Subscriber) MarshalBSON

func (s *Subscriber) MarshalBSON() ([]byte, error)

func (*Subscriber) SetBSON

func (s *Subscriber) SetBSON(raw mgobson.Raw) error

func (*Subscriber) String

func (s *Subscriber) String() string

func (*Subscriber) UnmarshalBSON

func (s *Subscriber) UnmarshalBSON(in []byte) error

func (*Subscriber) Validate

func (s *Subscriber) Validate() error

type Subscription

type Subscription struct {
	ID             string            `bson:"_id"`
	ResourceType   string            `bson:"type"`
	Trigger        string            `bson:"trigger"`
	Selectors      []Selector        `bson:"selectors,omitempty"`
	RegexSelectors []Selector        `bson:"regex_selectors,omitempty"`
	Filter         Filter            `bson:"filter"`
	Subscriber     Subscriber        `bson:"subscriber"`
	OwnerType      OwnerType         `bson:"owner_type"`
	Owner          string            `bson:"owner"`
	TriggerData    map[string]string `bson:"trigger_data,omitempty"`
	LastUpdated    time.Time         `bson:"last_updated,omitempty"`
}

func CreateOrUpdateGeneralSubscription

func CreateOrUpdateGeneralSubscription(ctx context.Context, resourceType string, id string,
	subscriber Subscriber, user string) (*Subscription, error)

func FindSubscriptionByID

func FindSubscriptionByID(ctx context.Context, id string) (*Subscription, error)

func FindSubscriptionsByAttributes

func FindSubscriptionsByAttributes(ctx context.Context, resourceType string, eventAttributes Attributes) ([]Subscription, error)

FindSubscriptionsByAttributes finds all subscriptions of matching resourceType, and whose filter and regex selectors match the attributes of the event.

func FindSubscriptionsByOwner

func FindSubscriptionsByOwner(ctx context.Context, owner string, ownerType OwnerType) ([]Subscription, error)

func NewAlertableInstanceTypeWarningSubscription

func NewAlertableInstanceTypeWarningSubscription(hostId string, sub Subscriber) Subscription

NewAlertableInstanceTypeWarningSubscription returns a subscription for the spawn host using an alertable instance type.

func NewBuildBreakSubscriptionByOwner

func NewBuildBreakSubscriptionByOwner(owner string, sub Subscriber) Subscription

func NewExpiringBuildOutcomeSubscriptionByVersion

func NewExpiringBuildOutcomeSubscriptionByVersion(versionID string, sub Subscriber) Subscription

func NewExpiringPatchChildOutcomeSubscription

func NewExpiringPatchChildOutcomeSubscription(id string, sub Subscriber) Subscription

func NewExpiringPatchOutcomeSubscription

func NewExpiringPatchOutcomeSubscription(id string, sub Subscriber) Subscription

func NewFirstTaskFailureInVersionSubscriptionByOwner

func NewFirstTaskFailureInVersionSubscriptionByOwner(owner string, sub Subscriber) Subscription

func NewGithubCheckBuildOutcomeSubscriptionByVersion

func NewGithubCheckBuildOutcomeSubscriptionByVersion(versionID string, sub Subscriber) Subscription

func NewParentPatchSubscription

func NewParentPatchSubscription(id string, sub Subscriber) Subscription

func NewPatchOutcomeSubscriptionByOwner

func NewPatchOutcomeSubscriptionByOwner(owner string, sub Subscriber) Subscription

func NewSpawnHostIdleWarningSubscription

func NewSpawnHostIdleWarningSubscription(hostId string, sub Subscriber) Subscription

NewSpawnHostIdleWarningSubscription returns a subscription for the spawn host.

func NewSpawnHostOutcomeByOwner

func NewSpawnHostOutcomeByOwner(owner string, sub Subscriber) Subscription

func NewSpawnhostExpirationSubscription

func NewSpawnhostExpirationSubscription(owner string, sub Subscriber) Subscription

func NewSubscriptionByID

func NewSubscriptionByID(resourceType, trigger, id string, sub Subscriber) Subscription

func NewSubscriptionByOwner

func NewSubscriptionByOwner(owner string, sub Subscriber, resourceType, trigger string) Subscription

func NewVersionGithubCheckOutcomeSubscription

func NewVersionGithubCheckOutcomeSubscription(id string, sub Subscriber) Subscription

func (*Subscription) SetBSON

func (s *Subscription) SetBSON(raw mgobson.Raw) error

func (*Subscription) String

func (s *Subscription) String() string

func (*Subscription) UnmarshalBSON

func (d *Subscription) UnmarshalBSON(in []byte) error

func (*Subscription) Upsert

func (s *Subscription) Upsert(ctx context.Context) error

func (*Subscription) Validate

func (s *Subscription) Validate() error

func (*Subscription) ValidateSelectors

func (s *Subscription) ValidateSelectors() error

type TaskBlockedData

type TaskBlockedData struct {
	ID        string `bson:"-" json:"-"`
	Execution int    `bson:"-" json:"-"`
	BlockedOn string `bson:"-" json:"-"`
}

TaskBlockedData is event data for logging a single task blocked event.

type TaskEventData

type TaskEventData struct {
	Execution int    `bson:"execution" json:"execution"`
	HostId    string `bson:"h_id,omitempty" json:"host_id,omitempty"`
	PodID     string `bson:"pod_id,omitempty" json:"pod_id,omitempty"`
	UserId    string `bson:"u_id,omitempty" json:"user_id,omitempty"`
	Status    string `bson:"s,omitempty" json:"status,omitempty"`
	JiraIssue string `bson:"jira,omitempty" json:"jira,omitempty"`
	BlockedOn string `bson:"blocked_on,omitempty" json:"blocked_on,omitempty"`

	Timestamp time.Time `bson:"ts,omitempty" json:"timestamp,omitempty"`
	Priority  int64     `bson:"pri,omitempty" json:"priority,omitempty"`
}

implements Data

type UnmarshalEventLogEntry

type UnmarshalEventLogEntry struct {
	ID           any       `bson:"_id" json:"-"`
	ResourceType string    `bson:"r_type,omitempty" json:"resource_type,omitempty"`
	ProcessedAt  time.Time `bson:"processed_at" json:"processed_at"`

	Timestamp  time.Time   `bson:"ts" json:"timestamp"`
	Expirable  bool        `bson:"expirable,omitempty" json:"expirable,omitempty"`
	ResourceId string      `bson:"r_id" json:"resource_id"`
	EventType  string      `bson:"e_type" json:"event_type"`
	Data       mgobson.Raw `bson:"data" json:"data"`
}

type UserEventType

type UserEventType string

UserEventType represents types of changes possible to a DB user.

const (
	UserEventTypeRolesUpdate            UserEventType = "USER_ROLES_UPDATED"
	UserEventTypeFavoriteProjectsUpdate UserEventType = "USER_FAVORITE_PROJECTS_UPDATED"
)

type VersionEventData

type VersionEventData struct {
	Status            string `bson:"status,omitempty" json:"status,omitempty"`
	GithubCheckStatus string `bson:"github_check_status,omitempty" json:"github_check_status,omitempty"`
	Author            string `bson:"author,omitempty" json:"author,omitempty"`
}

type WebhookHeader

type WebhookHeader struct {
	Key   string `bson:"key"`
	Value string `bson:"value"`
}

type WebhookSubscriber

type WebhookSubscriber struct {
	URL        string          `bson:"url"`
	Secret     []byte          `bson:"secret"`
	Retries    int             `bson:"retries"`
	MinDelayMS int             `bson:"min_delay_ms"`
	TimeoutMS  int             `bson:"timeout_ms"`
	Headers    []WebhookHeader `bson:"headers"`
}

func (*WebhookSubscriber) GetHeader

func (s *WebhookSubscriber) GetHeader(key string) string

GetHeader gets the value for the given key.

func (*WebhookSubscriber) String

func (s *WebhookSubscriber) String() string

Jump to

Keyboard shortcuts

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