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
- Variables
- func AdminEventsBefore(before time.Time, n int) db.Q
- func AllRecentHostEventsAreSystemFailed(ctx context.Context, hostId string, hostProvisionTime time.Time, n int) bool
- func ByAdminGuid(guid string) db.Q
- func CopyProjectSubscriptions(ctx context.Context, oldProject, newProject string) error
- func CountUnprocessedEvents(ctx context.Context) (int, error)
- func GetEventTypesForHost(ctx context.Context, hostID string, tag string) ([]string, error)
- func GetSubscriptionTarget[T any](s Subscription) (*T, error)
- func HasNoRecentStoppedHostEvent(ctx context.Context, id string, ts time.Time) (bool, error)
- func HostEvents(opts HostEventsOpts) db.Q
- func IsValidOwnerType(in string) bool
- func LogAdminEvent(ctx context.Context, section string, before, after evergreen.ConfigSection, ...) error
- func LogAlertableInstanceTypeWarningSent(ctx context.Context, hostID string)
- func LogBuildGithubCheckFinishedEvent(ctx context.Context, id, status string)
- func LogBuildStateChangeEvent(ctx context.Context, id, status string)
- func LogContainerTaskDispatched(ctx context.Context, taskID string, execution int, podID string)
- func LogContainerTaskFinished(ctx context.Context, taskID string, execution int, podID, status string)
- func LogDistroAMIModified(ctx context.Context, distroId, userId string)
- func LogDistroAdded(ctx context.Context, distroId, userId string, data any)
- func LogDistroEvent(ctx context.Context, distroId string, eventType string, ...)
- func LogDistroModified(ctx context.Context, distroId, userId string, before, after any)
- func LogDistroRemoved(ctx context.Context, distroId, userId string, data any)
- func LogHostAgentDeployFailed(ctx context.Context, hostID string, err error)
- func LogHostAgentDeployed(ctx context.Context, hostID string)
- func LogHostAgentMonitorDeployFailed(ctx context.Context, hostID string, err error)
- func LogHostAgentMonitorDeployed(ctx context.Context, hostID string)
- func LogHostConvertedProvisioning(ctx context.Context, hostID, method string)
- func LogHostConvertingProvisioning(ctx context.Context, hostID, method, user string)
- func LogHostConvertingProvisioningError(ctx context.Context, hostID string, err error)
- func LogHostCreated(ctx context.Context, hostId string)
- func LogHostCreatedError(ctx context.Context, hostID, logs string)
- func LogHostDNSNameSet(ctx context.Context, hostID string, dnsName string)
- func LogHostEvent(ctx context.Context, hostId string, eventType string, eventData HostEventData)
- func LogHostJasperRestartError(ctx context.Context, hostID string, err error)
- func LogHostJasperRestarted(ctx context.Context, hostID, revision string)
- func LogHostJasperRestarting(ctx context.Context, hostID, user string)
- func LogHostModifyError(ctx context.Context, hostID, logs string)
- func LogHostModifySucceeded(ctx context.Context, hostID, source string)
- func LogHostProvisionError(ctx context.Context, hostID string)
- func LogHostProvisionFailed(ctx context.Context, hostID string, setupLogs string)
- func LogHostProvisioned(ctx context.Context, hostID string)
- func LogHostRebootError(ctx context.Context, hostID, source, logs string)
- func LogHostRebootSucceeded(ctx context.Context, hostID, source string)
- func LogHostRunningTaskCleared(ctx context.Context, hostID string, taskId string, taskExecution int)
- func LogHostRunningTaskSet(ctx context.Context, hostID string, taskId string, taskExecution int)
- func LogHostScriptExecuteFailed(ctx context.Context, hostID, logs string, err error)
- func LogHostScriptExecuted(ctx context.Context, hostID string, logs string)
- func LogHostStartError(ctx context.Context, hostID, source, logs string)
- func LogHostStartSucceeded(ctx context.Context, hostID string, source string)
- func LogHostStatusChanged(ctx context.Context, hostId, oldStatus, newStatus, user string, logs string)
- func LogHostStopError(ctx context.Context, hostID, source, logs string)
- func LogHostStopSucceeded(ctx context.Context, hostID, source string)
- func LogHostTaskDispatched(ctx context.Context, taskId string, execution int, hostId string)
- func LogHostTaskFinished(ctx context.Context, taskId string, execution int, hostId, status string)
- func LogHostTaskUndispatched(ctx context.Context, taskId string, execution int, hostId string)
- func LogHostTemporaryExemptionExpirationWarningSent(ctx context.Context, hostID string)
- func LogHostTerminatedExternally(ctx context.Context, hostID, oldStatus string)
- func LogJiraIssueCreated(ctx context.Context, taskId string, execution int, jiraIssue string)
- func LogManyEvents(ctx context.Context, events []EventLogEntry) error
- func LogManyHostsCreated(ctx context.Context, hostIDs []string)
- func LogManyTaskAbortRequests(ctx context.Context, taskIds []string, userId string)
- func LogManyTaskPriority(ctx context.Context, taskIds []string, userId string, priority int64)
- func LogManyTasksBlocked(ctx context.Context, data []TaskBlockedData)
- func LogManyUnorderedEventsWithContext(ctx context.Context, events []EventLogEntry) error
- func LogPatchChildrenCompletionEvent(ctx context.Context, id, status, author string)
- func LogPatchStateChangeEvent(ctx context.Context, id, newStatus string)
- func LogPodAssignedTask(ctx context.Context, id, taskID string, execution int)
- func LogPodEvent(ctx context.Context, id string, kind PodEventType, data PodData)
- func LogPodRunningTaskCleared(ctx context.Context, id, taskID string, execution int)
- func LogPodStatusChanged(ctx context.Context, id, oldStatus, newStatus, reason string)
- func LogSpawnHostCreatedError(ctx context.Context, hostID, logs string)
- func LogSpawnHostIdleNotification(ctx context.Context, hostID string)
- func LogSpawnhostExpirationWarningSent(ctx context.Context, hostID string)
- func LogTaskAbortRequest(ctx context.Context, taskId string, execution int, userId string)
- func LogTaskActivated(ctx context.Context, taskId string, execution int, userId string)
- func LogTaskContainerAllocated(ctx context.Context, taskId string, execution int, ...)
- func LogTaskCreated(ctx context.Context, taskId string, execution int)
- func LogTaskDependenciesOverridden(ctx context.Context, taskId string, execution int, userID string)
- func LogTaskFinished(ctx context.Context, taskId string, execution int, status string)
- func LogTaskPriority(ctx context.Context, taskId string, execution int, userId string, ...)
- func LogTaskRestarted(ctx context.Context, taskId string, execution int, userId string)
- func LogTaskStarted(ctx context.Context, taskId string, execution int)
- func LogUserEvent(ctx context.Context, user string, eventType UserEventType, before, after any) error
- func LogVersionChildrenCompletionEvent(ctx context.Context, id, status, author string)
- func LogVersionGithubCheckFinishedEvent(ctx context.Context, id, newStatus string)
- func LogVersionStateChangeEvent(ctx context.Context, id, newStatus string)
- func LogVolumeExpirationWarningSent(ctx context.Context, volumeID string)
- func LogVolumeMigrationFailed(ctx context.Context, hostID string, err error)
- func MostRecentPodEvents(id string, n int) db.Q
- func MostRecentTaskEvents(id string, n int) db.Q
- func RecentAdminEvents(n int) db.Q
- func RemoveSubscription(ctx context.Context, id string) error
- func ResourceTypeKeyIs(key string) bson.M
- func RevertConfig(ctx context.Context, guid string, user string) error
- func TaskEventsForId(id string) db.Q
- func TaskEventsInOrder(id string) db.Q
- type AdminEventData
- type Attributes
- type BuildEventData
- type ChildPatchSubscriber
- type ConfigDataChange
- type DistroEventData
- type EventLogEntry
- func Find(ctx context.Context, query db.Q) ([]EventLogEntry, error)
- func FindAdmin(ctx context.Context, query db.Q) ([]EventLogEntry, error)
- func FindAllByResourceID(ctx context.Context, resourceID string) ([]EventLogEntry, error)
- func FindByID(ctx context.Context, eventID string) (*EventLogEntry, error)
- func FindLastProcessedEvent(ctx context.Context) (*EventLogEntry, error)
- func FindLatestAMIModifiedDistroEvent(ctx context.Context, id string) (EventLogEntry, error)
- func FindLatestAdminEvents(ctx context.Context, n int, before time.Time) ([]EventLogEntry, error)
- func FindLatestPrimaryDistroEvents(ctx context.Context, id string, n int, before time.Time) ([]EventLogEntry, error)
- func FindPaginatedWithTotalCount(ctx context.Context, query db.Q, limit, page int) ([]EventLogEntry, int, error)
- func FindUnprocessedEvents(ctx context.Context, limit int) ([]EventLogEntry, error)
- func GetPaginatedHostEvents(ctx context.Context, opts PaginatedHostEventsOpts) ([]EventLogEntry, int, error)
- func GetTaskActivatedEvent(taskId string, execution int, userId string) EventLogEntry
- func GetTaskDeactivatedEvent(taskId string, execution int, userId string) EventLogEntry
- func MostRecentPaginatedPodEvents(ctx context.Context, id string, limit, page int) ([]EventLogEntry, int, error)
- func (e *EventLogEntry) Log(ctx context.Context) error
- func (e *EventLogEntry) MarkProcessed(ctx context.Context) error
- func (e *EventLogEntry) MarshalBSON() ([]byte, error)
- func (e *EventLogEntry) Processed() (bool, time.Time)
- func (e *EventLogEntry) SetBSON(raw mgobson.Raw) error
- func (e *EventLogEntry) UnmarshalBSON(in []byte) error
- type Filter
- type GithubCheckSubscriber
- type GithubMergeSubscriber
- type GithubPullRequestSubscriber
- type HostEventData
- type HostEventsOpts
- type JIRAIssueSubscriber
- type OwnerType
- type PaginatedHostEventsOpts
- type PatchEventData
- type PodData
- type PodEventType
- type Selector
- type Subscriber
- func NewEmailSubscriber(t string) Subscriber
- func NewGithubCheckAPISubscriber(s GithubCheckSubscriber) Subscriber
- func NewGithubMergeAPISubscriber(s GithubMergeSubscriber) Subscriber
- func NewGithubStatusAPISubscriber(s GithubPullRequestSubscriber) Subscriber
- func NewRunChildPatchSubscriber(s ChildPatchSubscriber) Subscriber
- func NewSlackSubscriber(t string) Subscriber
- type Subscription
- func CreateOrUpdateGeneralSubscription(ctx context.Context, resourceType string, id string, subscriber Subscriber, ...) (*Subscription, error)
- func FindSubscriptionByID(ctx context.Context, id string) (*Subscription, error)
- func FindSubscriptionsByAttributes(ctx context.Context, resourceType string, eventAttributes Attributes) ([]Subscription, error)
- func FindSubscriptionsByOwner(ctx context.Context, owner string, ownerType OwnerType) ([]Subscription, error)
- func NewAlertableInstanceTypeWarningSubscription(hostId string, sub Subscriber) Subscription
- func NewBuildBreakSubscriptionByOwner(owner string, sub Subscriber) Subscription
- func NewExpiringBuildOutcomeSubscriptionByVersion(versionID string, sub Subscriber) Subscription
- func NewExpiringPatchChildOutcomeSubscription(id string, sub Subscriber) Subscription
- func NewExpiringPatchOutcomeSubscription(id string, sub Subscriber) Subscription
- func NewFirstTaskFailureInVersionSubscriptionByOwner(owner string, sub Subscriber) Subscription
- func NewGithubCheckBuildOutcomeSubscriptionByVersion(versionID string, sub Subscriber) Subscription
- func NewParentPatchSubscription(id string, sub Subscriber) Subscription
- func NewPatchOutcomeSubscriptionByOwner(owner string, sub Subscriber) Subscription
- func NewSpawnHostIdleWarningSubscription(hostId string, sub Subscriber) Subscription
- func NewSpawnHostOutcomeByOwner(owner string, sub Subscriber) Subscription
- func NewSpawnhostExpirationSubscription(owner string, sub Subscriber) Subscription
- func NewSubscriptionByID(resourceType, trigger, id string, sub Subscriber) Subscription
- func NewSubscriptionByOwner(owner string, sub Subscriber, resourceType, trigger string) Subscription
- func NewVersionGithubCheckOutcomeSubscription(id string, sub Subscriber) Subscription
- type TaskBlockedData
- type TaskEventData
- type UnmarshalEventLogEntry
- type UserEventType
- type VersionEventData
- type WebhookHeader
- type WebhookSubscriber
Constants ¶
const ( ResourceTypeAdmin = "ADMIN" EventTypeValueChanged = "CONFIG_VALUE_CHANGED" )
const ( ResourceTypeBuild = "BUILD" BuildStateChange = "STATE_CHANGE" BuildGithubCheckFinished = "GITHUB_CHECK_FINISHED" )
const ( // resource type ResourceTypeDistro = "DISTRO" // event types EventDistroAdded = "DISTRO_ADDED" EventDistroModified = "DISTRO_MODIFIED" EventDistroAMIModfied = "DISTRO_AMI_MODIFIED" EventDistroRemoved = "DISTRO_REMOVED" )
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" )
const ( ResourceTypePatch = "PATCH" PatchStateChange = "STATE_CHANGE" PatchChildrenCompletion = "CHILDREN_FINISHED" )
const ( EventResourceTypeProject = "PROJECT" EventTypeProjectModified = "PROJECT_MODIFIED" EventTypeProjectAdded = "PROJECT_ADDED" EventTypeProjectAttachedToRepo = "PROJECT_ATTACHED_TO_REPO" EventTypeProjectDetachedFromRepo = "PROJECT_DETACHED_FROM_REPO" )
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" )
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" )
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" )
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" )
const ( ResourceTypeVersion = "VERSION" VersionStateChange = "STATE_CHANGE" VersionGithubCheckFinished = "GITHUB_CHECK_FINISHED" VersionChildrenCompletion = "CHILDREN_FINISHED" )
const EventCollection = "events"
const (
ResourceTypeUser = "USER"
)
const (
SubscriptionsCollection = "subscriptions"
)
Variables ¶
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 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 ¶
ByAdminGuid returns a query for the admin events with the given guid.
func CopyProjectSubscriptions ¶
CopyProjectSubscriptions copies subscriptions from the first project for the second project.
func GetEventTypesForHost ¶
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 ¶
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 LogAdminEvent ¶
func LogAlertableInstanceTypeWarningSent ¶
LogAlertableInstanceTypeWarningSent logs an event warning about the host using an alertable instance type.
func LogContainerTaskDispatched ¶
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 ¶
LogDistroAMIModified logs when the default region's AMI is modified.
func LogDistroAdded ¶
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 ¶
LogDistroModified should take in DistroData in order to preserve the ProviderSettingsList
func LogDistroRemoved ¶
LogDistroRemoved should take in DistroData in order to preserve the ProviderSettingsList
func LogHostAgentDeployed ¶
func LogHostCreated ¶
LogHostCreated logs an event indicating that the host was created.
func LogHostCreatedError ¶
LogHostCreatedError logs an event indicating that the host errored while it was being created.
func LogHostEvent ¶
func LogHostEvent(ctx context.Context, hostId string, eventType string, eventData HostEventData)
func LogHostJasperRestarted ¶
func LogHostJasperRestarting ¶
func LogHostModifyError ¶
LogHostModifyError logs an event indicating that the host errored while being modified.
func LogHostModifySucceeded ¶
LogHostModifySucceeded logs an event indicating that the host was successfully modified.
func LogHostProvisionError ¶
LogHostProvisionError is used to log each failed provision attempt
func LogHostProvisionFailed ¶
LogHostProvisionFailed is used when Evergreen gives up on provisioning a host after several retries.
func LogHostProvisioned ¶
func LogHostRebootError ¶
LogHostRebootError logs an event indicating that the host errored while rebooting.
func LogHostRebootSucceeded ¶
LogHostRebootSucceeded logs an event indicating that the host was successfully rebooted.
func LogHostRunningTaskSet ¶
func LogHostScriptExecuted ¶
func LogHostStartError ¶
LogHostStartError logs an event indicating that the host errored while starting.
func LogHostStartSucceeded ¶
LogHostStartSucceeded logs an event indicating that the host was successfully started.
func LogHostStatusChanged ¶
func LogHostStopError ¶
LogHostStopError logs an event indicating that the host errored while stopping.
func LogHostStopSucceeded ¶
LogHostStopSucceeded logs an event indicating that the host was successfully stopped.
func LogHostTaskDispatched ¶
LogHostTaskDispatched logs an event for a host task being dispatched.
func LogHostTaskFinished ¶
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 ¶
LogHostTaskUndispatched logs an event for a host being marked undispatched.
func LogHostTemporaryExemptionExpirationWarningSent ¶
LogHostTemporaryExemptionExpirationWarningSent logs an event warning about the host's temporary exemption, which is about to expire.
func LogJiraIssueCreated ¶
func LogManyEvents ¶
func LogManyEvents(ctx context.Context, events []EventLogEntry) error
func LogManyHostsCreated ¶
LogManyHostsCreated is the same as LogHostCreated but for multiple hosts.
func LogManyTaskAbortRequests ¶
LogManyTaskAbortRequests updates the DB with task abort request events.
func LogManyTaskPriority ¶
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 LogPodAssignedTask ¶
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 ¶
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 ¶
LogPodStatusChanged logs an event indicating that the pod's status has been updated.
func LogSpawnHostCreatedError ¶
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 ¶
LogSpawnHostIdleNotification logs an event for the spawn host being idle.
func LogTaskAbortRequest ¶
LogTaskAbortRequest updates the DB with a task abort request event.
func LogTaskActivated ¶
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 LogTaskDependenciesOverridden ¶
func LogTaskDependenciesOverridden(ctx context.Context, taskId string, execution int, userID string)
LogTaskDependenciesOverridden updates the DB with a task dependencies overridden event.
func LogTaskFinished ¶
LogTaskFinished logs an event indicating that the task has finished.
func LogTaskPriority ¶
func LogTaskRestarted ¶
LogTaskRestarted updates the DB with a task restarted event.
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 LogVolumeMigrationFailed ¶
LogVolumeMigrationFailed is used when a volume is unable to migrate to a new host.
func MostRecentPodEvents ¶
MostRecentPodEvents creates a query to find the n most recent pod events for the given pod ID.
func RecentAdminEvents ¶
Admin Events RecentAdminEvents returns the N most recent admin events
func ResourceTypeKeyIs ¶
func RevertConfig ¶
RevertConfig reverts one config section to the before state of the specified GUID in the event log
func TaskEventsInOrder ¶
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 ChildPatchSubscriber ¶
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 ¶
Find takes a collection storing events and a query, generated by one of the query functions, and returns a slice of events.
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 ¶
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 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) 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) 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 ¶
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 ¶
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 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 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 Subscriber ¶
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) 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 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) String ¶
func (s *Subscription) String() string
func (*Subscription) UnmarshalBSON ¶
func (d *Subscription) UnmarshalBSON(in []byte) 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 WebhookHeader ¶
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