event

package
v0.0.0-...-1402089 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2024 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 (
	ResourceTypeCommitQueue  = "COMMIT_QUEUE"
	CommitQueueEnqueueFailed = "ENQUEUE_FAILED"
	CommitQueueStartTest     = "START_TEST"
	CommitQueueConcludeTest  = "CONCLUDE_TEST"
)
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"
	EventHostStarted                                 = "HOST_STARTED"
	EventHostStopped                                 = "HOST_STOPPED"
	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"
	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"
	EnqueuePatchSubscriberType      = "enqueue-patch"
	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"
	GeneralSubscriptionCommitQueue                   = "commit-queue"

	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"
)
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"
	MergeTaskUnscheduled       = "MERGE_TASK_UNSCHEDULED"
)
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, n int) bool

AllRecentHostEventsAreSystemFailed returns true if all recent host events are system failures, and false if any are not.

func ByAdminGuid

func ByAdminGuid(guid string) db.Q

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

func CopyProjectSubscriptions

func CopyProjectSubscriptions(oldProject, newProject string) error

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

func CountUnprocessedEvents

func CountUnprocessedEvents() (int, error)

func GetEventTypesForHost

func GetEventTypesForHost(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(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(section string, before, after evergreen.ConfigSection, user string) error

func LogBuildGithubCheckFinishedEvent

func LogBuildGithubCheckFinishedEvent(id, status string)

func LogBuildStateChangeEvent

func LogBuildStateChangeEvent(id, status string)

func LogCommitQueueConcludeTest

func LogCommitQueueConcludeTest(patchID, status string)

func LogCommitQueueConcludeWithErrorMessage

func LogCommitQueueConcludeWithErrorMessage(patchID, status, errMsg string)

func LogCommitQueueEnqueueFailed

func LogCommitQueueEnqueueFailed(patchID string, err error)

func LogCommitQueueStartTestEvent

func LogCommitQueueStartTestEvent(patchID string)

func LogContainerTaskDispatched

func LogContainerTaskDispatched(taskID string, execution int, podID string)

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

func LogContainerTaskFinished

func LogContainerTaskFinished(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(distroId, userId string)

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

func LogDistroAdded

func LogDistroAdded(distroId, userId string, data interface{})

LogDistroAdded should take in DistroData in order to preserve the ProviderSettingsList

func LogDistroEvent

func LogDistroEvent(distroId string, eventType string, eventData DistroEventData)

func LogDistroModified

func LogDistroModified(distroId, userId string, before, after interface{})

LogDistroModified should take in DistroData in order to preserve the ProviderSettingsList

func LogDistroRemoved

func LogDistroRemoved(distroId, userId string, data interface{})

LogDistroRemoved should take in DistroData in order to preserve the ProviderSettingsList

func LogHostAgentDeployFailed

func LogHostAgentDeployFailed(hostId string, err error)

func LogHostAgentDeployed

func LogHostAgentDeployed(hostId string)

func LogHostAgentMonitorDeployFailed

func LogHostAgentMonitorDeployFailed(hostId string, err error)

func LogHostAgentMonitorDeployed

func LogHostAgentMonitorDeployed(hostId string)

func LogHostConvertedProvisioning

func LogHostConvertedProvisioning(hostID, method string)

func LogHostConvertingProvisioning

func LogHostConvertingProvisioning(hostID, method, user string)

func LogHostConvertingProvisioningError

func LogHostConvertingProvisioningError(hostId string, err error)

func LogHostCreated

func LogHostCreated(hostId string)

LogHostCreated logs an event indicating that the host was created.

func LogHostCreatedError

func LogHostCreatedError(hostID, logs string)

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

func LogHostDNSNameSet

func LogHostDNSNameSet(hostId string, dnsName string)

func LogHostEvent

func LogHostEvent(hostId string, eventType string, eventData HostEventData)

func LogHostJasperRestartError

func LogHostJasperRestartError(hostId string, err error)

func LogHostJasperRestarted

func LogHostJasperRestarted(hostId, revision string)

func LogHostJasperRestarting

func LogHostJasperRestarting(hostId, user string)

func LogHostModifyError

func LogHostModifyError(hostID, logs string)

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

func LogHostModifySucceeded

func LogHostModifySucceeded(hostID, source string)

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

func LogHostProvisionError

func LogHostProvisionError(hostId string)

LogHostProvisionError is used to log each failed provision attempt

func LogHostProvisionFailed

func LogHostProvisionFailed(hostId string, setupLogs string)

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

func LogHostProvisioned

func LogHostProvisioned(hostId string)

func LogHostRunningTaskCleared

func LogHostRunningTaskCleared(hostId string, taskId string, taskExecution int)

func LogHostRunningTaskSet

func LogHostRunningTaskSet(hostId string, taskId string, taskExecution int)

func LogHostScriptExecuteFailed

func LogHostScriptExecuteFailed(hostID string, err error)

func LogHostScriptExecuted

func LogHostScriptExecuted(hostID string, logs string)

func LogHostStartError

func LogHostStartError(hostID, source, logs string)

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

func LogHostStartSucceeded

func LogHostStartSucceeded(hostID string, source string)

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

func LogHostStatusChanged

func LogHostStatusChanged(hostId, oldStatus, newStatus, user string, logs string)

func LogHostStopError

func LogHostStopError(hostID, source, logs string)

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

func LogHostStopSucceeded

func LogHostStopSucceeded(hostID, source string)

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

func LogHostTaskDispatched

func LogHostTaskDispatched(taskId string, execution int, hostId string)

LogHostTaskDispatched logs an event for a host task being dispatched.

func LogHostTaskFinished

func LogHostTaskFinished(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(taskId string, execution int, hostId string)

LogHostTaskUndispatched logs an event for a host being marked undispatched.

func LogHostTemporaryExemptionExpirationWarningSent

func LogHostTemporaryExemptionExpirationWarningSent(hostID string)

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

func LogHostTerminatedExternally

func LogHostTerminatedExternally(hostId, oldStatus string)

func LogJiraIssueCreated

func LogJiraIssueCreated(taskId string, execution int, jiraIssue string)

func LogManyEvents

func LogManyEvents(events []EventLogEntry) error

func LogManyHostsCreated

func LogManyHostsCreated(hostIDs []string)

LogManyHostsCreated is the same as LogHostCreated but for multiple hosts.

func LogManyTaskAbortRequests

func LogManyTaskAbortRequests(taskIds []string, userId string)

LogManyTaskAbortRequests updates the DB with task abort request events.

func LogManyTaskPriority

func LogManyTaskPriority(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 LogMergeTaskUnscheduled

func LogMergeTaskUnscheduled(taskId string, execution int, userID string)

LogMergeTaskUnscheduled updates the DB with a merge task unscheduled event.

func LogPatchChildrenCompletionEvent

func LogPatchChildrenCompletionEvent(id, status, author string)

func LogPatchStateChangeEvent

func LogPatchStateChangeEvent(id, newStatus string)

func LogPodAssignedTask

func LogPodAssignedTask(id, taskID string, execution int)

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

func LogPodEvent

func LogPodEvent(id string, kind PodEventType, data PodData)

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

func LogPodRunningTaskCleared

func LogPodRunningTaskCleared(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(id, oldStatus, newStatus, reason string)

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

func LogSpawnHostIdleNotification

func LogSpawnHostIdleNotification(hostID string)

LogSpawnHostIdleNotification logs an event for the spawn host being idle.

func LogSpawnhostExpirationWarningSent

func LogSpawnhostExpirationWarningSent(hostID string)

func LogTaskAbortRequest

func LogTaskAbortRequest(taskId string, execution int, userId string)

LogTaskAbortRequest updates the DB with a task abort request event.

func LogTaskActivated

func LogTaskActivated(taskId string, execution int, userId string)

LogTaskActivated updates the DB with a task activated event.

func LogTaskContainerAllocated

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

LogTaskContainerAllocated updates the DB with a container allocated event.

func LogTaskCreated

func LogTaskCreated(taskId string, execution int)

func LogTaskDependenciesOverridden

func LogTaskDependenciesOverridden(taskId string, execution int, userID string)

LogTaskDependenciesOverridden updates the DB with a task dependencies overridden event.

func LogTaskFinished

func LogTaskFinished(taskId string, execution int, status string)

LogTaskFinished logs an event indicating that the task has finished.

func LogTaskPriority

func LogTaskPriority(taskId string, execution int, userId string, priority int64)

func LogTaskRestarted

func LogTaskRestarted(taskId string, execution int, userId string)

LogTaskRestarted updates the DB with a task restarted event.

func LogTaskStarted

func LogTaskStarted(taskId string, execution int)

func LogUserEvent

func LogUserEvent(user string, eventType UserEventType, before, after interface{}) error

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

func LogVersionChildrenCompletionEvent

func LogVersionChildrenCompletionEvent(id, status, author string)

func LogVersionGithubCheckFinishedEvent

func LogVersionGithubCheckFinishedEvent(id, newStatus string)

func LogVersionStateChangeEvent

func LogVersionStateChangeEvent(id, newStatus string)

func LogVolumeExpirationWarningSent

func LogVolumeExpirationWarningSent(volumeID string)

func LogVolumeMigrationFailed

func LogVolumeMigrationFailed(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(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 CommitQueueEventData

type CommitQueueEventData struct {
	Status string `bson:"status,omitempty" json:"status,omitempty"`
	Error  string `bson:"error,omitempty" json:"error,omitempty"`
}

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   interface{} `bson:"before" json:"before"`
	After    interface{} `bson:"after" json:"after"`

	// Fields used by legacy UI
	Data   interface{} `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       interface{} `bson:"data" json:"data"`
}

func Find

func Find(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(query db.Q) ([]EventLogEntry, error)

func FindAllByResourceID

func FindAllByResourceID(resourceID string) ([]EventLogEntry, error)

func FindByID

func FindByID(eventID string) (*EventLogEntry, error)

FindByID finds a single event matching the given event ID.

func FindLastProcessedEvent

func FindLastProcessedEvent() (*EventLogEntry, error)

func FindLatestAMIModifiedDistroEvent

func FindLatestAMIModifiedDistroEvent(id string) (EventLogEntry, error)

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

func FindLatestPrimaryDistroEvents

func FindLatestPrimaryDistroEvents(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(query db.Q, limit, page int) ([]EventLogEntry, int, error)

func FindUnprocessedEvents

func FindUnprocessedEvents(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(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(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() error

func (*EventLogEntry) MarkProcessed

func (e *EventLogEntry) MarkProcessed() 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"`
}

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"`
	Type     string `bson:"type"`
}

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 PRInfo

type PRInfo struct {
	Owner           string `bson:"owner"`
	Repo            string `bson:"repo"`
	Ref             string `bson:"ref"`
	PRNum           int    `bson:"pr_number"`
	CommitTitle     string `bson:"commit_title"`
	MessageOverride string `bson:"message_override"`
}

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 interface{} `bson:"target"`
}

func NewEmailSubscriber

func NewEmailSubscriber(t string) Subscriber

func NewEnqueuePatchSubscriber

func NewEnqueuePatchSubscriber() 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(resourceType string, id string,
	subscriber Subscriber, user string) (*Subscription, error)

func FindSubscriptionByID

func FindSubscriptionByID(id string) (*Subscription, error)

func FindSubscriptionsByAttributes

func FindSubscriptionsByAttributes(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(owner string, ownerType OwnerType) ([]Subscription, error)

func NewBuildBreakSubscriptionByOwner

func NewBuildBreakSubscriptionByOwner(owner string, sub Subscriber) Subscription

func NewCommitQueueSubscriptionByOwner

func NewCommitQueueSubscriptionByOwner(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 NewExpiringPatchSuccessSubscription

func NewExpiringPatchSuccessSubscription(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() 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           interface{} `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