host

package
v0.0.0-...-900fa13 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2015 License: Apache-2.0 Imports: 10 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")
)
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,
	},
)

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.

IsUninitialized is a query that returns all uninitialized Evergreen hosts.

Functions

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 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 doign 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 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"`

	// 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"`
}

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 (self *Host) UpdateReachability(reachable bool) error

UpdateReachability sets a host as either running or unreachable, depending on the bool passed in. also update the last reachability check for the host

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)

Jump to

Keyboard shortcuts

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