host

package
v0.0.0-...-a204096 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2016 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Collection is the name of the MongoDB collection that stores hosts.
	Collection = "hosts"
)

Variables

View Source
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")
)
View Source
var All = db.Query(nil)

All is a query that returns all hosts

IsActive is a query that returns all Evergreen hosts that are working or capable of being assigned work to do.

View Source
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.

IsDecommissioned is a query that returns all hosts without a running task that are marked for decommissioning.

View Source
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.

View Source
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.

IsLive is a query that returns all working hosts started by Evergreen

View Source
var IsProvisioningFailure = db.Query(bson.D{{StatusKey, evergreen.HostProvisionFailed}})

IsProvisioningFailure is a query that returns all hosts that failed to provision.

IsRunning is a query that returns all hosts that are running (i.e. status != terminated).

View Source
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.

View Source
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

IsUninitialized is a query that returns all uninitialized Evergreen hosts.

Functions

func ByAvailableForDistro

func ByAvailableForDistro(d string) db.Q

ByAvailableForDistro returns all running Evergreen hosts with no running task of a certain distro Id.

func ByDistroId

func ByDistroId(distroId string) db.Q

ByDistroId produces a query that returns all working hosts (not terminated and not quarantined) of the given distro.

func ByDynamicWithinTime

func ByDynamicWithinTime(startTime, endTime time.Time) db.Q

ByDynamicWithinTime is a query that returns all dynamic hosts running between a certain time and another time.

func ByExpiredSince

func ByExpiredSince(time time.Time) db.Q

ByExpiredSicne produces a query that returns any user-spawned hosts that will expired after the given time.

func ByExpiringBetween

func ByExpiringBetween(lowerBound time.Time, upperBound time.Time) db.Q

ByExpiringBetween produces a query that returns any user-spawned hosts that will expire between the specified times.

func ByHungSince

func ByHungSince(threshold time.Time) db.Q

ByHungSince produces a query that returns all working hosts that  started their tasks before the given time.

func ById

func ById(id string) db.Q

ById produces a query that returns a host with the given id.

func ByIds

func ByIds(ids []string) db.Q

ByIds produces a query that returns all hosts in the given list of ids.

func ByNotMonitoredSince

func ByNotMonitoredSince(threshold time.Time) db.Q

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

func ByRunningTaskId(taskId string) db.Q

ByRunningTaskId returns a host running the task with the given id.

func ByUnproductiveSince

func ByUnproductiveSince(threshold time.Time) db.Q

ByUnproductiveSince produces a query that returns all hosts that are not doing work and were created before the given time.

func ByUnprovisionedSince

func ByUnprovisionedSince(threshold time.Time) db.Q

ByUnprovisionedSince produces a query that returns all hosts Evergreen never finished setting up that were created before the given time.

func ByUnreachableBefore

func ByUnreachableBefore(threshold time.Time) db.Q

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

func ByUserWithRunningStatus(user string) db.Q

ByUserWithRunningStatus produces a query that returns all running hosts for the given user id.

func ByUserWithUnterminatedStatus

func ByUserWithUnterminatedStatus(user string) db.Q

ByUserWithUnterminatedStatus produces a query that returns all running hosts for the given user id.

func Count

func Count(query db.Q) (int, error)

Count returns the number of hosts that satisfy the given query.

func DecommissionInactiveStaticHosts

func DecommissionInactiveStaticHosts(activeStaticHosts []string) error

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.

func UpdateOne

func UpdateOne(query interface{}, update interface{}) error

UpdateOne updates one host.

func UpsertOne

func UpsertOne(query interface{}, update interface{}) (*mgo.ChangeInfo, error)

UpsertOne upserts a host.

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 Find

func Find(query db.Q) ([]Host, error)

Find gets all Hosts for the given query.

func FindOne

func FindOne(query db.Q) (*Host, error)

FindOne gets one Host for the given query.

func (*Host) ClearRunningTask

func (self *Host) ClearRunningTask() error

func (*Host) IdleTime

func (self *Host) IdleTime() time.Duration

IdleTime returns how long has this host been idle

func (*Host) Insert

func (self *Host) Insert() error

func (*Host) MarkAsProvisioned

func (self *Host) MarkAsProvisioned() error

func (*Host) Remove

func (self *Host) Remove() error

func (*Host) SetDNSName

func (self *Host) SetDNSName(dnsName string) error

SetDNSName updates the DNS name for a given host once

func (*Host) SetDecommissioned

func (self *Host) SetDecommissioned() error

func (*Host) SetExpirationNotification

func (self *Host) SetExpirationNotification(thresholdKey string) error

SetExpirationNotification updates the notification time for a spawn host

func (*Host) SetExpirationTime

func (self *Host) SetExpirationTime(expirationTime time.Time) error

SetExpirationTime updates the expiration time of a spawn host

func (*Host) SetInitializing

func (self *Host) SetInitializing() error

SetInitializing marks the host as initializing. Only allow this if the host is uninitialized.

func (*Host) SetQuarantined

func (self *Host) SetQuarantined(status string) error

func (*Host) SetRunning

func (self *Host) SetRunning() error

func (*Host) SetRunningTask

func (self *Host) SetRunningTask(taskId, agentRevision string,
	taskDispatchTime time.Time) error

Marks that the specified task was started on the host at the specified time.

func (*Host) SetStatus

func (self *Host) SetStatus(status string) error

func (*Host) SetTaskPid

func (self *Host) SetTaskPid(pid string) error

func (*Host) SetTerminated

func (self *Host) SetTerminated() error

func (*Host) SetUninitialized

func (self *Host) SetUninitialized() error

func (*Host) SetUnprovisioned

func (self *Host) SetUnprovisioned() error

func (*Host) SetUnreachable

func (self *Host) SetUnreachable() error

func (*Host) SetUserData

func (self *Host) SetUserData(userData string) error

SetUserData updates the userdata field of a spawn host

func (*Host) Terminate

func (self *Host) Terminate() error

func (*Host) UpdateReachability

func (h *Host) UpdateReachability(reachable bool) error

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

func (host *Host) UpdateRunningTask(prevTaskId, newTaskId string,
	finishTime time.Time) (err error)

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'

func (*Host) Upsert

func (self *Host) Upsert() (*mgo.ChangeInfo, error)

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.

Jump to

Keyboard shortcuts

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