Documentation ¶
Index ¶
- Constants
- Variables
- func ByAvailableForDistro(d string) db.Q
- func ByDistroId(distroId string) db.Q
- func ByDynamicWithinTime(startTime, endTime time.Time) db.Q
- func ByExpiredSince(time time.Time) db.Q
- func ByExpiringBetween(lowerBound time.Time, upperBound time.Time) db.Q
- func ByHungSince(threshold time.Time) db.Q
- func ById(id string) db.Q
- func ByIds(ids []string) db.Q
- func ByNotMonitoredSince(threshold time.Time) db.Q
- func ByRunningTaskId(taskId string) db.Q
- func ByUnproductiveSince(threshold time.Time) db.Q
- func ByUnprovisionedSince(threshold time.Time) db.Q
- func ByUnreachableBefore(threshold time.Time) db.Q
- func ByUserWithRunningStatus(user string) db.Q
- func ByUserWithUnterminatedStatus(user string) db.Q
- func Count(query db.Q) (int, error)
- func DecommissionInactiveStaticHosts(activeStaticHosts []string) error
- func UpdateAll(query interface{}, update interface{}) error
- func UpdateOne(query interface{}, update interface{}) error
- func UpsertOne(query interface{}, update interface{}) (*mgo.ChangeInfo, error)
- type Host
- func (self *Host) ClearRunningTask() error
- func (self *Host) IdleTime() time.Duration
- func (self *Host) Insert() error
- func (self *Host) MarkAsProvisioned() error
- func (self *Host) Remove() error
- func (self *Host) SetDNSName(dnsName string) error
- func (self *Host) SetDecommissioned() error
- func (self *Host) SetExpirationNotification(thresholdKey string) error
- func (self *Host) SetExpirationTime(expirationTime time.Time) error
- func (self *Host) SetInitializing() error
- func (self *Host) SetQuarantined(status string) error
- func (self *Host) SetRunning() error
- func (self *Host) SetRunningTask(taskId, agentRevision string, taskDispatchTime time.Time) error
- func (self *Host) SetStatus(status string) error
- func (self *Host) SetTaskPid(pid string) error
- func (self *Host) SetTerminated() error
- func (self *Host) SetUninitialized() error
- func (self *Host) SetUnprovisioned() error
- func (self *Host) SetUnreachable() error
- func (self *Host) SetUserData(userData string) error
- func (self *Host) Terminate() error
- func (h *Host) UpdateReachability(reachable bool) error
- func (host *Host) UpdateRunningTask(prevTaskId, newTaskId string, finishTime time.Time) (err error)
- func (self *Host) Upsert() (*mgo.ChangeInfo, error)
- type ProvisionOptions
Constants ¶
const (
// Collection is the name of the MongoDB collection that stores hosts.
Collection = "hosts"
)
Variables ¶
var ( IdKey = bsonutil.MustHaveTag(Host{}, "Id") DNSKey = bsonutil.MustHaveTag(Host{}, "Host") UserKey = bsonutil.MustHaveTag(Host{}, "User") TagKey = bsonutil.MustHaveTag(Host{}, "Tag") DistroKey = bsonutil.MustHaveTag(Host{}, "Distro") ProviderKey = bsonutil.MustHaveTag(Host{}, "Provider") ProvisionedKey = bsonutil.MustHaveTag(Host{}, "Provisioned") RunningTaskKey = bsonutil.MustHaveTag(Host{}, "RunningTask") PidKey = bsonutil.MustHaveTag(Host{}, "Pid") TaskDispatchTimeKey = bsonutil.MustHaveTag(Host{}, "TaskDispatchTime") CreateTimeKey = bsonutil.MustHaveTag(Host{}, "CreationTime") ExpirationTimeKey = bsonutil.MustHaveTag(Host{}, "ExpirationTime") TerminationTimeKey = bsonutil.MustHaveTag(Host{}, "TerminationTime") LTCTimeKey = bsonutil.MustHaveTag(Host{}, "LastTaskCompletedTime") LTCKey = bsonutil.MustHaveTag(Host{}, "LastTaskCompleted") StatusKey = bsonutil.MustHaveTag(Host{}, "Status") AgentRevisionKey = bsonutil.MustHaveTag(Host{}, "AgentRevision") StartedByKey = bsonutil.MustHaveTag(Host{}, "StartedBy") InstanceTypeKey = bsonutil.MustHaveTag(Host{}, "InstanceType") NotificationsKey = bsonutil.MustHaveTag(Host{}, "Notifications") UserDataKey = bsonutil.MustHaveTag(Host{}, "UserData") LastReachabilityCheckKey = bsonutil.MustHaveTag(Host{}, "LastReachabilityCheck") UnreachableSinceKey = bsonutil.MustHaveTag(Host{}, "UnreachableSince") )
var All = db.Query(nil)
All is a query that returns all hosts
var AllStatic = db.Query( bson.M{ ProviderKey: evergreen.HostTypeStatic, })
var IsActive = db.Query( bson.M{ StartedByKey: evergreen.User, StatusKey: bson.M{ "$nin": []string{ evergreen.HostTerminated, evergreen.HostDecommissioned, evergreen.HostInitializing, }, }, }, )
IsActive is a query that returns all Evergreen hosts that are working or capable of being assigned work to do.
var IsAvailableAndFree = db.Query( bson.M{ "$or": noRunningTask, StatusKey: evergreen.HostRunning, StartedByKey: evergreen.User, }, ).Sort([]string{"-" + LTCTimeKey})
IsAvailableAndFree is a query that returns all running Evergreen hosts without an assigned task.
var IsDecommissioned = db.Query( bson.M{RunningTaskKey: "", StatusKey: evergreen.HostDecommissioned}, )
IsDecommissioned is a query that returns all hosts without a running task that are marked for decommissioning.
var IsFree = db.Query( bson.M{ "$or": noRunningTask, StartedByKey: evergreen.User, StatusKey: evergreen.HostRunning, }, )
IsFree is a query that returns all running Evergreen hosts without an assigned task.
var IsIdle = db.Query( bson.M{ "$or": noRunningTask, StatusKey: evergreen.HostRunning, StartedByKey: evergreen.User, }, )
IsIdle is a query that returns all running Evergreen hosts with no task.
var IsLive = db.Query( bson.M{ StartedByKey: evergreen.User, StatusKey: bson.M{"$in": evergreen.UphostStatus}, }, )
IsLive is a query that returns all working hosts started by Evergreen
var IsProvisioningFailure = db.Query(bson.D{{StatusKey, evergreen.HostProvisionFailed}})
IsProvisioningFailure is a query that returns all hosts that failed to provision.
var IsRunning = db.Query(bson.M{StatusKey: bson.M{"$ne": evergreen.HostTerminated}})
IsRunning is a query that returns all hosts that are running (i.e. status != terminated).
var IsRunningAndSpawned = db.Query( bson.M{ StartedByKey: bson.M{"$ne": evergreen.User}, StatusKey: bson.M{"$ne": evergreen.HostTerminated}, }, )
IsRunningAndSpawned is a query that returns all running hosts spawned by an Evergreen user.
var IsRunningTask = db.Query( bson.M{ StatusKey: bson.M{"$ne": evergreen.HostTerminated}, "$and": []bson.M{ {RunningTaskKey: bson.M{"$exists": true}}, {RunningTaskKey: bson.M{"$ne": ""}}, }, }, )
IsRunningTask is a query that returns all running hosts with a running task
var IsUninitialized = db.Query( bson.M{StatusKey: evergreen.HostUninitialized}, )
IsUninitialized is a query that returns all uninitialized Evergreen hosts.
Functions ¶
func ByAvailableForDistro ¶
ByAvailableForDistro returns all running Evergreen hosts with no running task of a certain distro Id.
func ByDistroId ¶
ByDistroId produces a query that returns all working hosts (not terminated and not quarantined) of the given distro.
func ByDynamicWithinTime ¶
ByDynamicWithinTime is a query that returns all dynamic hosts running between a certain time and another time.
func ByExpiredSince ¶
ByExpiredSicne produces a query that returns any user-spawned hosts that will expired after the given time.
func ByExpiringBetween ¶
ByExpiringBetween produces a query that returns any user-spawned hosts that will expire between the specified times.
func ByHungSince ¶
ByHungSince produces a query that returns all working hosts that started their tasks before the given time.
func ByNotMonitoredSince ¶
ByNotMonitoredSince produces a query that returns all hosts whose last reachability check was before the specified threshold, filtering out user-spawned hosts and hosts currently running tasks.
func ByRunningTaskId ¶
ByRunningTaskId returns a host running the task with the given id.
func ByUnproductiveSince ¶
ByUnproductiveSince produces a query that returns all hosts that are not doing work and were created before the given time.
func ByUnprovisionedSince ¶
ByUnprovisionedSince produces a query that returns all hosts Evergreen never finished setting up that were created before the given time.
func ByUnreachableBefore ¶
ByUnreachableBefore produces a query that returns a list of all hosts that are still unreachable, and have been in that state since before the given time threshold.
func ByUserWithRunningStatus ¶
ByUserWithRunningStatus produces a query that returns all running hosts for the given user id.
func ByUserWithUnterminatedStatus ¶
ByUserWithUnterminatedStatus produces a query that returns all running hosts for the given user id.
func DecommissionInactiveStaticHosts ¶
DecommissionInactiveStaticHosts decommissions static hosts in the database provided their ids aren't contained in the passed in activeStaticHosts slice
func UpdateAll ¶
func UpdateAll(query interface{}, update interface{}) error
UpdateAll updates all hosts.
Types ¶
type Host ¶
type Host struct { Id string `bson:"_id" json:"id"` Host string `bson:"host_id" json:"host"` User string `bson:"user" json:"user"` Tag string `bson:"tag" json:"tag"` Distro distro.Distro `bson:"distro" json:"distro"` Provider string `bson:"host_type" json:"host_type"` // true if the host has been set up properly Provisioned bool `bson:"provisioned" json:"provisioned"` ProvisionOptions *ProvisionOptions `bson:"provision_options,omitempty" json:"provision_options,omitempty"` // the task that is currently running on the host RunningTask string `bson:"running_task" json:"running_task"` // the pid of the task that is currently running on the host Pid string `bson:"pid" json:"pid"` // duplicate of the DispatchTime field in the above task TaskDispatchTime time.Time `bson:"task_dispatch_time" json:"task_dispatch_time"` ExpirationTime time.Time `bson:"expiration_time,omitempty" json:"expiration_time"` CreationTime time.Time `bson:"creation_time" json:"creation_time"` TerminationTime time.Time `bson:"termination_time" json:"termination_time"` LastTaskCompletedTime time.Time `bson:"last_task_completed_time" json:"last_task_completed_time"` LastTaskCompleted string `bson:"last_task" json:"last_task"` Status string `bson:"status" json:"status"` StartedBy string `bson:"started_by" json:"started_by"` // True if this host was created manually by a user (i.e. with spawnhost) UserHost bool `bson:"user_host" json:"user_host"` AgentRevision string `bson:"agent_revision" json:"agent_revision"` // for ec2 dynamic hosts, the instance type requested InstanceType string `bson:"instance_type" json:"instance_type,omitempty"` // stores information on expiration notifications for spawn hosts Notifications map[string]bool `bson:"notifications,omitempty" json:"notifications,omitempty"` // stores userdata that was placed on the host at spawn time UserData string `bson:"userdata" json:"userdata,omitempty"` // the last time that the host's reachability was checked LastReachabilityCheck time.Time `bson:"last_reachability_check" json:"last_reachability_check"` // if set, the time at which the host first became unreachable UnreachableSince time.Time `bson:"unreachable_since,omitempty" json:"unreachable_since"` }
func (*Host) ClearRunningTask ¶
func (*Host) MarkAsProvisioned ¶
func (*Host) SetDNSName ¶
SetDNSName updates the DNS name for a given host once
func (*Host) SetDecommissioned ¶
func (*Host) SetExpirationNotification ¶
SetExpirationNotification updates the notification time for a spawn host
func (*Host) SetExpirationTime ¶
SetExpirationTime updates the expiration time of a spawn host
func (*Host) SetInitializing ¶
SetInitializing marks the host as initializing. Only allow this if the host is uninitialized.
func (*Host) SetQuarantined ¶
func (*Host) SetRunning ¶
func (*Host) SetRunningTask ¶
Marks that the specified task was started on the host at the specified time.
func (*Host) SetTaskPid ¶
func (*Host) SetTerminated ¶
func (*Host) SetUninitialized ¶
func (*Host) SetUnprovisioned ¶
func (*Host) SetUnreachable ¶
func (*Host) SetUserData ¶
SetUserData updates the userdata field of a spawn host
func (*Host) UpdateReachability ¶
UpdateReachability sets a host as either running or unreachable, and updates the timestamp of the host's last reachability check. If the host is being set to unreachable, the "unreachable since" field is also set to the current time if it is unset.
func (*Host) UpdateRunningTask ¶
UpdateRunningTask takes two id strings - an old task and a new one - finds the host running the task with Id, 'prevTaskId' and updates its running task to 'newTaskId'; also setting the completion time of 'prevTaskId'
type ProvisionOptions ¶
type ProvisionOptions struct { // LoadCLI indicates (if set) that while provisioning the host, the CLI binary should // be placed onto the host after startup. LoadCLI bool `bson:"load_cli" json:"load_cli"` // TaskId if non-empty will trigger the CLI tool to fetch source and artifacts for the given task. // Ignored if LoadCLI is false. TaskId string `bson:"task_id" json:"task_id"` // Owner is the user associated with the host used to populate any necessary metadata. OwnerId string `bson:"owner_id" json:"owner_id"` }
ProvisionOptions is struct containing options about how a new host should be set up.