Documentation
¶
Overview ¶
Package prjmanager implements public API for Project Manager.
The Project Manager keeps track of the LUCI Project config, incomplete Runs, and CLs in flight, and notifies Runs when the project config changes.
Index ¶
- Constants
- func EventboxRecipient(ctx context.Context, luciProject string) eventbox.Recipient
- type Notifier
- func (n *Notifier) NotifyCLUpdated(ctx context.Context, luciProject string, clid common.CLID, eversion int) error
- func (n *Notifier) NotifyCLsUpdated(ctx context.Context, luciProject string, cls []*changelist.CL) error
- func (n *Notifier) NotifyPurgeCompleted(ctx context.Context, luciProject string, operationID string, eta time.Time) error
- func (n *Notifier) NotifyRunCreated(ctx context.Context, runID common.RunID) error
- func (n *Notifier) NotifyRunFinished(ctx context.Context, runID common.RunID) error
- func (n *Notifier) Poke(ctx context.Context, luciProject string) error
- func (n *Notifier) SendNow(ctx context.Context, luciProject string, e *prjpb.Event) error
- func (n *Notifier) UpdateConfig(ctx context.Context, luciProject string) error
- type Project
- type ProjectLog
- type ProjectStateOffload
Constants ¶
const ( // ProjectKind is the Datastore entity kind for Project. ProjectKind = "Project" // ProjectLogKind is the Datastore entity kind for ProjectLog. ProjectLogKind = "ProjectLog" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Notifier ¶
type Notifier struct { // TasksBinding are used to register handlers of Project Manager Implementation & CL Purger to // avoid circular dependency. TasksBinding prjpb.TasksBinding }
Notifier notifies Project Manager.
func NewNotifier ¶
func NewNotifier(tqd *tq.Dispatcher) *Notifier
NewNotifier creates a new Project Manager notifier and registers it in the provided tq.Dispatcher.
func (*Notifier) NotifyCLUpdated ¶
func (n *Notifier) NotifyCLUpdated(ctx context.Context, luciProject string, clid common.CLID, eversion int) error
NotifyCLUpdated tells Project Manager to check latest version of a given CL.
func (*Notifier) NotifyCLsUpdated ¶
func (n *Notifier) NotifyCLsUpdated(ctx context.Context, luciProject string, cls []*changelist.CL) error
NotifyCLsUpdated is a batch of NotifyCLUpdated for the same Project Manager.
In each given CL, .ID and .EVersion must be set.
func (*Notifier) NotifyPurgeCompleted ¶
func (n *Notifier) NotifyPurgeCompleted(ctx context.Context, luciProject string, operationID string, eta time.Time) error
NotifyPurgeCompleted tells Project Manager that a CL purge has completed.
The ultimate result of CL purge is the updated state of a CL itself, thus no information is provided here.
TODO(crbug/1224170): remove eta parameter once CV does all the purging.
func (*Notifier) NotifyRunCreated ¶
NotifyRunCreated is sent by Project Manager to itself within a Run creation transaction.
Unlike other event-sending of Notifier, this one only creates an event and doesn't create a task. This is fine because:
- if Run creation transaction fails, then this event isn't actually created anyways.
- if Project Manager observes the Run creation success, then it'll act as if this event was received in the upcoming state transition. Yes, it won't process this event immediately, but at this point the event is a noop, so it'll be cleared out from the eventbox upon next invocation of Project Manager. So there is no need to create a TQ task.
- else, namely Run creation succeeds but Project Manager sees it as a failure OR Project Manager fails at any point before it can act on RunCreation, then the existing TQ task running Project Manager will be retried. So once again there is no need to create a TQ task.
func (*Notifier) NotifyRunFinished ¶
NotifyRunFinished tells Project Manager that a run has finalized its state.
func (*Notifier) Poke ¶
Poke tells Project Manager to poke all downstream actors and check its own state.
type Project ¶
type Project struct { // ID is LUCI project name. ID string `gae:"$id"` // EVersion is entity version. Every update should increment it by 1. EVersion int64 `gae:",noindex"` // UpdateTime is exact time of when this entity was last updated. // // It's not indexed to avoid hot areas in the index. UpdateTime time.Time `gae:",noindex"` // State serializes internal Project Manager state. // // The `LuciProject` field isn't set as it duplicates Project.ID. State *prjpb.PState // contains filtered or unexported fields }
Project is an entity per LUCI Project in Datastore.
func Load ¶
Load loads LUCI project state from Datastore.
If project doesn't exist in Datastore, returns nil, nil.
func (*Project) ConfigHash ¶
ConfigHash returns Project's Config hash.
func (*Project) IncompleteRuns ¶
IncompleteRuns are IDs of Runs which aren't yet completed.
type ProjectLog ¶
type ProjectLog struct { Project *datastore.Key `gae:"$parent"` // EVersion and other fields are the same as the Project & ProjectStateOffload // entities written at the same time. EVersion int64 `gae:"$id"` Status prjpb.Status `gae:",noindex"` ConfigHash string `gae:",noindex"` UpdateTime time.Time `gae:",noindex"` State *prjpb.PState // Reasons records why this Log entity was written. // // There can be more than one, all of which will be indexed. Reasons []prjpb.LogReason `gae:"reason"` // contains filtered or unexported fields }
ProjectLog stores historic state of a project.
type ProjectStateOffload ¶
type ProjectStateOffload struct { Project *datastore.Key `gae:"$parent"` // ID is alaways the same, set/read only by the datastore ORM. ID string `gae:"$id,const"` // Status of the project {STARTED, STOPPING, STOPPED (disabled)}. Status prjpb.Status `gae:",noindex"` // ConfigHash is the latest processed Project Config hash. ConfigHash string `gae:",noindex"` // contains filtered or unexported fields }
ProjectStateOffload stores rarely-changed project state duplicated from the main Project entity for use in transactions creating Runs.
Although this is already stored in the main Project entity, doing so would result in retries of Run creation transactions, since Project entity is frequently modified in busy projects.
On the other hand, ProjectStateOffload is highly likely to remain unchanged by the time Run creation transaction commits, thus avoiding needless retries.
Directories
¶
Path | Synopsis |
---|---|
Package clpurger purges CLs with a trigger for which Runs can't be started.
|
Package clpurger purges CLs with a trigger for which Runs can't be started. |
Package copyonwrite providers helpers for modifying slices in Copy-on-Write way.
|
Package copyonwrite providers helpers for modifying slices in Copy-on-Write way. |
Package itriager defines interface of a CL component triage process.
|
Package itriager defines interface of a CL component triage process. |
Package manager implements a ProjectManager.
|
Package manager implements a ProjectManager. |
Package pmtest implements tests for working with Project Manager.
|
Package pmtest implements tests for working with Project Manager. |
package prjinternal stores protos for event processing of ProjectManager.
|
package prjinternal stores protos for event processing of ProjectManager. |
Package state implements state machine of a Project Manager.
|
Package state implements state machine of a Project Manager. |
Package triager proposes concrete actions on a group of related CLs.
|
Package triager proposes concrete actions on a group of related CLs. |