Documentation ¶
Overview ¶
Package host models a single host managed by Evergreen's application server. These hosts can be used for different purposes, such as running tasks or serving as virtual workstations.
Index ¶
- Constants
- Variables
- func ByDistroIDs(distroIDs ...string) bson.M
- func ByDistroIDsOrAliasesRunning(distroNames ...string) bson.M
- func ByExpiringBetween(lowerBound time.Time, upperBound time.Time) bson.M
- func ByIPAndRunning(ip string) bson.M
- func ById(id string) bson.M
- func ByIds(ids []string) bson.M
- func ByNotMonitoredSince(threshold time.Time) bson.M
- func ByTaskSpec(group, buildVariant, project, version string) bson.M
- func ByUserRecentlyTerminated(user string, timestamp time.Time) bson.M
- func ByUserWithRunningStatus(user string) bson.M
- func ByUserWithUnterminatedStatus(user string) bson.M
- func CacheAllCloudProviderData(ctx context.Context, env evergreen.Environment, ...) error
- func CanUpdateSpawnHost(h *Host, usr *user.DBUser) bool
- func ChmodCommandWithSudo(script string, sudo bool) []string
- func ClearExpiredTemporaryExemptions(ctx context.Context) error
- func ConsolidateHostsForUser(ctx context.Context, oldUser, newUser string) error
- func Count(ctx context.Context, query bson.M, opts ...*options.CountOptions) (int, error)
- func CountActiveDynamicHosts(ctx context.Context) (int, error)
- func CountActiveHostsInDistro(ctx context.Context, distroID string) (int, error)
- func CountHostsCanOrWillRunTasksInDistro(ctx context.Context, distroID string) (int, error)
- func CountHostsCanRunTasks(ctx context.Context, distroID string) (int, error)
- func CountIdleStartedTaskHosts(ctx context.Context) (int, error)
- func CountNoExpirationVolumesForUser(userID string) (int, error)
- func CountSpawnhostsWithNoExpirationByUser(ctx context.Context, user string) (int, error)
- func DecommissionHostsWithDistroId(ctx context.Context, distroId string) error
- func DeleteMany(ctx context.Context, filter bson.M, options ...*options.DeleteOptions) error
- func DeleteOne(ctx context.Context, filter bson.M, options ...*options.DeleteOptions) error
- func FindDistroForHost(ctx context.Context, hostID string) (string, error)
- func FindTotalVolumeSizeByUser(user string) (int, error)
- func InsertMany(ctx context.Context, hosts []Host) error
- func InsertOne(ctx context.Context, h *Host) error
- func IsIntentHostId(id string) bool
- func MakeContainersAndParents(ctx context.Context, d distro.Distro, pool *evergreen.ContainerPool, ...) ([]Host, []Host, error)
- func MarkInactiveStaticHosts(ctx context.Context, activeStaticHosts []string, d *distro.Distro) error
- func MarkStaleBuildingAsFailed(ctx context.Context, distroID string) error
- func MinTaskGroupOrderRunningByTaskSpec(ctx context.Context, group, buildVariant, project, version string) (int, error)
- func NeedsAgentDeploy(currentTime time.Time) bson.M
- func NeedsAgentMonitorDeploy(currentTime time.Time) bson.M
- func NumHostsByTaskSpec(ctx context.Context, group, buildVariant, project, version string) (int, error)
- func RemoveStaleInitializing(ctx context.Context, distroID string) error
- func RemoveStrict(ctx context.Context, env evergreen.Environment, id string) error
- func ShCommandWithSudo(script string, sudo bool) []string
- func ShouldDeployAgent() bson.M
- func ShouldDeployAgentMonitor() bson.M
- func SyncPermanentExemptions(ctx context.Context, permanentlyExempt []string) error
- func UnsafeReplace(ctx context.Context, env evergreen.Environment, idToRemove string, ...) error
- func UnsetVolumeHost(id string) error
- func UpdateAll(ctx context.Context, query bson.M, update bson.M) error
- func UpdateOne(ctx context.Context, query bson.M, update bson.M) error
- func UpsertOne(ctx context.Context, query bson.M, update bson.M) (*mongo.UpdateResult, error)
- func ValidateRDPPassword(password string) bool
- type ClientOptions
- type CloudProviderData
- type ContainersOnParents
- type CreateOptions
- type DistroStats
- type DockerOptions
- type EC2ProviderSettings
- type FinishTime
- type Host
- func Aggregate(ctx context.Context, pipeline []bson.M, options ...*options.AggregateOptions) ([]Host, error)
- func AllHostsSpawnedByTasksToTerminate(ctx context.Context) ([]Host, error)
- func Find(ctx context.Context, query bson.M, options ...*options.FindOptions) ([]Host, error)
- func FindAllHostsSpawnedByTasks(ctx context.Context) ([]Host, error)
- func FindAllRunningContainers(ctx context.Context) ([]Host, error)
- func FindAllRunningParents(ctx context.Context) ([]Host, error)
- func FindAllRunningParentsByDistroID(ctx context.Context, distroID string) ([]Host, error)
- func FindAllRunningParentsOrdered(ctx context.Context) ([]Host, error)
- func FindByNeedsToRestartJasper(ctx context.Context) ([]Host, error)
- func FindByProvisioning(ctx context.Context) ([]Host, error)
- func FindByShouldConvertProvisioning(ctx context.Context) ([]Host, error)
- func FindByTemporaryExemptionsExpiringBetween(ctx context.Context, lowerBound time.Time, upperBound time.Time) ([]Host, error)
- func FindExceedsSleepScheduleTimeout(ctx context.Context) ([]Host, error)
- func FindHostWithVolume(ctx context.Context, volumeID string) (*Host, error)
- func FindHostsInRange(ctx context.Context, params HostsInRangeParams) ([]Host, error)
- func FindHostsScheduledToStart(ctx context.Context) ([]Host, error)
- func FindHostsScheduledToStop(ctx context.Context) ([]Host, error)
- func FindHostsSpawnedByBuild(ctx context.Context, buildID string) ([]Host, error)
- func FindHostsSpawnedByTask(ctx context.Context, taskID string, execution int, statuses []string) ([]Host, error)
- func FindHostsToTerminate(ctx context.Context) ([]Host, error)
- func FindLatestTerminatedHostWithHomeVolume(ctx context.Context, homeVolumeID string, startedBy string) (*Host, error)
- func FindMissingNextSleepScheduleTime(ctx context.Context) ([]Host, error)
- func FindOne(ctx context.Context, query bson.M, options ...*options.FindOneOptions) (*Host, error)
- func FindOneByIdOrTag(ctx context.Context, id string) (*Host, error)
- func FindOneByPersistentDNSName(ctx context.Context, dnsName string) (*Host, error)
- func FindOneByTaskIdAndExecution(ctx context.Context, id string, execution int) (*Host, error)
- func FindOneId(ctx context.Context, id string) (*Host, error)
- func FindRunningHosts(ctx context.Context, includeSpawnHosts bool) ([]Host, error)
- func FindSpawnhostsWithNoExpirationToExtend(ctx context.Context) ([]Host, error)
- func FindStaticNeedsNewSSHKeys(ctx context.Context, settings *evergreen.Settings) ([]Host, error)
- func FindTerminatedHostsRunningTasks(ctx context.Context) ([]Host, error)
- func FindUnexpirableRunning() ([]Host, error)
- func FindUpHostWithHomeVolume(ctx context.Context, homeVolumeID string) (*Host, error)
- func FindUserDataSpawnHostsProvisioning(ctx context.Context) ([]Host, error)
- func GetHostByIdOrTagWithTask(ctx context.Context, hostID string) (*Host, error)
- func GetHostsByFromIDWithStatus(ctx context.Context, id, status, user string, limit int) ([]Host, error)
- func GetPaginatedRunningHosts(ctx context.Context, opts HostsFilterOptions) ([]Host, *int, int, error)
- func IdleHostsWithDistroID(ctx context.Context, distroID string) ([]Host, error)
- func NewIntent(options CreateOptions) *Host
- func (h *Host) AddPublicKeyScript(pubKey string) string
- func (h *Host) AddSSHKeyName(ctx context.Context, name string) error
- func (h *Host) AddTags(tags []Tag)
- func (h *Host) AddVolumeToHost(ctx context.Context, newVolume *VolumeAttachment) error
- func (h *Host) AgentBinary() string
- func (h *Host) AgentCommand(settings *evergreen.Settings, executablePath string) []string
- func (h *Host) AgentMonitorOptions(settings *evergreen.Settings) *options.Create
- func (h *Host) ChangeJasperDirsOwnerCommand() string
- func (h *Host) CheckTaskDataFetched(ctx context.Context, env evergreen.Environment) error
- func (h *Host) CheckUserDataProvisioningStartedCommand() string
- func (h *Host) ClearDockerStdinData(ctx context.Context) error
- func (h *Host) ClearRunningAndSetLastTask(ctx context.Context, t *task.Task) error
- func (h *Host) ClearRunningTask(ctx context.Context) error
- func (h *Host) ClearRunningTaskWithContext(ctx context.Context, env evergreen.Environment) error
- func (h *Host) CountContainersRunningAtTime(ctx context.Context, timestamp time.Time) (int, error)
- func (h *Host) CreateSecret(ctx context.Context, clear bool) error
- func (h *Host) CreateServicePassword(ctx context.Context) error
- func (h *Host) CurlCommand(env evergreen.Environment) (string, error)
- func (h *Host) CurlCommandWithDefaultRetry(env evergreen.Environment) (string, error)
- func (h *Host) CurlCommandWithRetry(env evergreen.Environment, numRetries, maxRetrySecs int) (string, error)
- func (h *Host) DeleteJasperCredentials(ctx context.Context, env evergreen.Environment) error
- func (h *Host) DeleteTags(keys []string)
- func (h *Host) FetchAndReinstallJasperCommands(settings *evergreen.Settings) string
- func (h *Host) FetchJasperCommand(config evergreen.HostJasperConfig) string
- func (h *Host) ForceReinstallJasperCommand(settings *evergreen.Settings) string
- func (h *Host) GenerateFetchProvisioningScriptUserData(ctx context.Context, env evergreen.Environment) (*userdata.Options, error)
- func (h *Host) GenerateJasperCredentials(ctx context.Context, env evergreen.Environment) (*certdepot.Credentials, error)
- func (h *Host) GeneratePersistentDNSName(ctx context.Context, domain string) (string, error)
- func (h *Host) GenerateUserDataProvisioningScript(ctx context.Context, settings *evergreen.Settings, ...) (string, error)
- func (h *Host) GetAMI() string
- func (h *Host) GetActiveContainers(ctx context.Context) ([]Host, error)
- func (h *Host) GetContainers(ctx context.Context) ([]Host, error)
- func (h *Host) GetCreateOptions() CreateOptions
- func (h *Host) GetElapsedCommunicationTime() time.Duration
- func (h *Host) GetJasperProcess(ctx context.Context, env evergreen.Environment, processID string) (complete bool, output string, err error)
- func (h *Host) GetParent(ctx context.Context) (*Host, error)
- func (h *Host) GetSSHOptions(settings *evergreen.Settings) ([]string, error)
- func (h *Host) GetSSHPort() int
- func (h *Host) GetSubnetID() string
- func (h *Host) GetTaskGroupString() string
- func (h *Host) GetTemporaryExemption(extendBy time.Duration) (time.Time, error)
- func (h *Host) HomeVolume() *VolumeAttachment
- func (h *Host) HostVolumeDeviceNames() []string
- func (h *Host) IdleTime() time.Duration
- func (h *Host) IncContainerBuildAttempt() error
- func (h *Host) IncIdleTime(idleTime time.Duration) error
- func (h *Host) IncTaskCount() error
- func (h *Host) IncrementNumAgentCleanupFailures(ctx context.Context) error
- func (h *Host) Insert(ctx context.Context) error
- func (h *Host) InsertWithContext(ctx context.Context, env evergreen.Environment) error
- func (h *Host) IsContainer() bool
- func (h *Host) IsEphemeral() bool
- func (h *Host) IsFree() bool
- func (h *Host) IsIdleParent(ctx context.Context) (bool, error)
- func (h *Host) IsSleepScheduleEnabled() bool
- func (h *Host) IsSubjectToHostCreationThrottle() bool
- func (h *Host) IsTearingDown() bool
- func (h *Host) IsWaitingForAgent() bool
- func (h *Host) JasperBinaryFilePath(config evergreen.HostJasperConfig) string
- func (h *Host) JasperClient(ctx context.Context, env evergreen.Environment) (remote.Manager, error)
- func (h *Host) JasperClientCredentials(ctx context.Context, env evergreen.Environment) (*certdepot.Credentials, error)
- func (h *Host) JasperCredentials(ctx context.Context, env evergreen.Environment) (*certdepot.Credentials, error)
- func (h *Host) JasperCredentialsExpiration(ctx context.Context, env evergreen.Environment) (time.Time, error)
- func (h *Host) MakeJasperDirsCommand() string
- func (h *Host) MarkAsProvisioned(ctx context.Context) error
- func (h *Host) MarkAsReprovisioned(ctx context.Context) error
- func (h *Host) MarkAsReprovisioning(ctx context.Context) error
- func (h *Host) MarkReachable(ctx context.Context) error
- func (h *Host) MarkShouldExpire(ctx context.Context, expireOnValue string) error
- func (h *Host) MarkShouldNotExpire(ctx context.Context, expireOnValue, userTimeZone string) error
- func (h *Host) MarkUserDataProvisioningDoneCommand() string
- func (h *Host) NeedsPortBindings() bool
- func (h *Host) QuietUninstallJasperCommand(config evergreen.HostJasperConfig) string
- func (h *Host) Remove(ctx context.Context) error
- func (h *Host) RemoveVolumeFromHost(ctx context.Context, volumeId string) error
- func (h *Host) Replace(ctx context.Context) error
- func (h *Host) ResetLastCommunicated(ctx context.Context) error
- func (h *Host) RestartJasperCommand(config evergreen.HostJasperConfig) string
- func (h *Host) RunJasperProcess(ctx context.Context, env evergreen.Environment, opts *options.Create) ([]string, error)
- func (h *Host) RunSSHCommand(ctx context.Context, cmd string) (string, error)
- func (h *Host) RunSSHCommandWithTimeout(ctx context.Context, cmd string, timeout time.Duration) (string, error)
- func (h *Host) RunSSHShellScript(ctx context.Context, script string, sudo bool, sudoUser string) (string, error)
- func (h *Host) RunSSHShellScriptWithTimeout(ctx context.Context, script string, sudo bool, sudoUser string, ...) (string, error)
- func (h *Host) SaveJasperCredentials(ctx context.Context, env evergreen.Environment, creds *certdepot.Credentials) error
- func (h *Host) SetAgentRevision(ctx context.Context, agentRevision string) error
- func (h *Host) SetAgentStartTime(ctx context.Context) error
- func (h *Host) SetBillingStartTime(ctx context.Context, startTime time.Time) error
- func (h *Host) SetDNSName(ctx context.Context, dnsName string) error
- func (h *Host) SetDecommissioned(ctx context.Context, user string, decommissionIfBusy bool, logs string) error
- func (h *Host) SetDisplayName(ctx context.Context, newName string) error
- func (h *Host) SetExpirationTime(ctx context.Context, expirationTime time.Time) error
- func (h *Host) SetExtId(ctx context.Context) error
- func (h *Host) SetHomeVolumeID(ctx context.Context, volumeID string) error
- func (h *Host) SetInstanceType(ctx context.Context, instanceType string) error
- func (h *Host) SetNeedsAgentDeploy(ctx context.Context, needsDeploy bool) error
- func (h *Host) SetNeedsNewAgent(ctx context.Context, needsAgent bool) error
- func (h *Host) SetNeedsNewAgentMonitor(ctx context.Context, needsAgentMonitor bool) error
- func (h *Host) SetNeedsReprovisionToNew(ctx context.Context, user string) error
- func (h *Host) SetNeedsToRestartJasper(ctx context.Context, user string) error
- func (h *Host) SetNextScheduledStartAndStopTimes(ctx context.Context, nextStart, nextStop time.Time) error
- func (h *Host) SetNextScheduledStartTime(ctx context.Context, t time.Time) error
- func (h *Host) SetNextScheduledStopTime(ctx context.Context, t time.Time) error
- func (h *Host) SetPersistentDNSInfo(ctx context.Context, dnsName, ipv4Addr string) error
- func (h *Host) SetPortMapping(ctx context.Context, portsMap PortMap) error
- func (h *Host) SetProvisionedNotRunning(ctx context.Context) error
- func (h *Host) SetProvisioning(ctx context.Context) error
- func (h *Host) SetQuarantined(ctx context.Context, user string, logs string) error
- func (h *Host) SetRunning(ctx context.Context, user string) error
- func (h *Host) SetStatus(ctx context.Context, newStatus, user, logs string) error
- func (h *Host) SetStatusAtomically(ctx context.Context, newStatus, user string, logs string) error
- func (h *Host) SetStopped(ctx context.Context, shouldKeepOff bool, user string) error
- func (h *Host) SetStopping(ctx context.Context, user string) error
- func (h *Host) SetTags(ctx context.Context) error
- func (h *Host) SetTaskGroupTeardownStartTime(ctx context.Context) error
- func (h *Host) SetTemporaryExemption(ctx context.Context, exemptUntil time.Time) error
- func (h *Host) SetTerminated(ctx context.Context, user, reason string) error
- func (h *Host) SetUnprovisioned(ctx context.Context) error
- func (h *Host) SetUserDataHostProvisioned(ctx context.Context) error
- func (h *Host) SetVolumes(ctx context.Context, volumes []VolumeAttachment) error
- func (h *Host) SetupCommand() string
- func (h *Host) SetupServiceUserCommands(ctx context.Context) (string, error)
- func (h *Host) ShouldNotifyStoppedSpawnHostIdle() (bool, error)
- func (h *Host) SpawnHostGetTaskDataCommand(ctx context.Context, githubAppToken string, moduleTokens []string) []string
- func (h *Host) SpawnHostPullTaskSyncCommand() []string
- func (h *Host) SpawnHostSetupCommands(settings *evergreen.Settings) (string, error)
- func (h *Host) StartAgentMonitorRequest(ctx context.Context, settings *evergreen.Settings) (string, error)
- func (h *Host) StartJasperProcess(ctx context.Context, env evergreen.Environment, opts *options.Create) (string, error)
- func (h *Host) StopAgentMonitor(ctx context.Context, env evergreen.Environment) error
- func (h *Host) TaskStartMessage() message.Fields
- func (h *Host) TeardownTimeExceededMax() bool
- func (h *Host) Terminate(ctx context.Context, user, reason string) error
- func (h *Host) UnmarshalBSON(in []byte) error
- func (h *Host) UnsetHomeVolume(ctx context.Context) error
- func (h *Host) UnsetNumAgentCleanupFailures(ctx context.Context) error
- func (h *Host) UnsetPersistentDNSInfo(ctx context.Context) error
- func (h *Host) UnsetTaskGroupTeardownStartTime(ctx context.Context) error
- func (h *Host) UpdateCachedDistroProviderSettings(ctx context.Context, settingsDocuments []*birch.Document) error
- func (h *Host) UpdateJasperCredentialsID(ctx context.Context, id string) error
- func (h *Host) UpdateLastCommunicated(ctx context.Context) error
- func (h *Host) UpdateLastContainerFinishTime(ctx context.Context, t time.Time) error
- func (h *Host) UpdateParentIDs(ctx context.Context) error
- func (h *Host) UpdateRunningTaskWithContext(ctx context.Context, env evergreen.Environment, t *task.Task) error
- func (h *Host) UpdateSleepSchedule(ctx context.Context, schedule SleepScheduleInfo, now time.Time) error
- func (h *Host) UpdateStartingToRunning(ctx context.Context) error
- func (h *Host) Upsert(ctx context.Context) (*mongo.UpdateResult, error)
- func (h *Host) UserDataProvisioningDoneFile() string
- func (h *Host) UserDataProvisioningStartedFile() string
- func (h *Host) ValidateExpirationExtension(extension time.Duration) error
- func (h *Host) WastedComputeTime() time.Duration
- func (h *Host) WithAgentMonitor(ctx context.Context, env evergreen.Environment, ...) error
- func (h *Host) WriteJasperCredentialsFilesCommands(splunk send.SplunkConnectionInfo, creds *certdepot.Credentials) (string, error)
- func (h *Host) WriteJasperPreconditionScriptsCommands() string
- type HostGroup
- func (hosts HostGroup) CountContainersOnParents(ctx context.Context) (int, error)
- func (hosts HostGroup) FindUphostContainersOnParents(ctx context.Context) ([]Host, error)
- func (hosts HostGroup) GetHostIds() []string
- func (hosts HostGroup) Stats() HostGroupStats
- func (hosts HostGroup) Uphosts() HostGroup
- type HostGroupStats
- type HostModifyOptions
- type HostsByClient
- type HostsFilterOptions
- type HostsInRangeParams
- type IdleHostsByDistroID
- type InactiveHostCounts
- type PortMap
- type ProviderStats
- type ProvisionOptions
- type ReprovisionType
- type SleepScheduleInfo
- func (s *SleepScheduleInfo) GetNextScheduledStartAndStopTimes(now time.Time) (nextStart, nextStop time.Time, err error)
- func (s *SleepScheduleInfo) GetNextScheduledStartTime(now time.Time) (time.Time, error)
- func (s *SleepScheduleInfo) GetNextScheduledStopTime(now time.Time) (time.Time, error)
- func (s *SleepScheduleInfo) IsExempt(now time.Time) bool
- func (i SleepScheduleInfo) IsZero() bool
- func (i *SleepScheduleInfo) Validate() error
- type SleepScheduleOptions
- type SpawnHostUsage
- type SpawnOptions
- type StatsByDistro
- type StatsByProvider
- type Tag
- type VirtualWorkstationCounter
- type Volume
- func FindOneVolume(query interface{}) (*Volume, error)
- func FindSortedVolumesByUser(userID string) ([]Volume, error)
- func FindUnattachedExpirableVolumes() ([]Volume, error)
- func FindVolumeByID(id string) (*Volume, error)
- func FindVolumesByUser(userID string) ([]Volume, error)
- func FindVolumesToDelete(expirationTime time.Time) ([]Volume, error)
- func FindVolumesWithNoExpirationToExtend() ([]Volume, error)
- func FindVolumesWithTerminatedHost() ([]Volume, error)
- func ValidateVolumeCanBeAttached(ctx context.Context, volumeID string) (*Volume, error)
- func (v *Volume) Insert() error
- func (v *Volume) Remove() error
- func (v *Volume) SetDisplayName(displayName string) error
- func (v *Volume) SetExpiration(expiration time.Time) error
- func (v *Volume) SetHost(id string) error
- func (v *Volume) SetMigrating(migrating bool) error
- func (v *Volume) SetNoExpiration(noExpiration bool) error
- func (v *Volume) SetSize(size int32) error
- type VolumeAttachment
Constants ¶
const ( // Collection is the name of the MongoDB collection that stores hosts. Collection = "hosts" VolumesCollection = "volumes" )
const ( // MaxAgentUnresponsiveInterval is the maximum amount of time that can elapse before the // agent is considered dead. Once it has been successfully started (e.g. // once an agent has been deployed from the server), the agent must // regularly contact the server to ensure it is still alive. MaxAgentUnresponsiveInterval = 5 * time.Minute // MaxAgentMonitorUnresponsiveInterval is the maximum amount of time that can elapse // before the agent monitor is considered dead. When the host is // provisioning, the agent must contact the app server within this duration // for the agent monitor to be alive (i.e. the agent monitor has // successfully started its job of starting and managing the agent). After // initial contact, the agent must regularly contact the server so that this // duration does not elapse. Otherwise, the agent monitor is considered dead // (because it has failed to keep an agent alive that can contact the // server). MaxAgentMonitorUnresponsiveInterval = 15 * time.Minute // MaxStaticHostUnresponsiveInterval is the maximum amount of time that can // elapse before a static host is considered unresponsive and unfixable. If // the host is running and healthy, the agent must regularly contact the app // server within this duration. Otherwise, the host will be considered // unhealthy and require manual intervention to investigate why it's // unresponsive. // This timeout is intentionally very conservative to mitigate false // positives when automatically detecting unhealthy static hosts. MaxStaticHostUnresponsiveInterval = 120 * time.Minute MaxTagKeyLength = 128 MaxTagValueLength = 256 ErrorParentNotFound = "parent not found" ErrorHostAlreadyTerminated = "not changing status of already terminated host" )
const DefaultSSHPort = 22
DefaultSSHPort is the default port to connect to hosts using SSH.
const OutputBufferSize = 1000
const PreStartThreshold = 10 * time.Minute
PreStartThreshold is how long in advance Evergreen can check for hosts that are scheduled to start up soon.
const SleepScheduleActionTimeout = 30 * time.Minute
Variables ¶
var ( IdKey = bsonutil.MustHaveTag(Host{}, "Id") DNSKey = bsonutil.MustHaveTag(Host{}, "Host") SecretKey = bsonutil.MustHaveTag(Host{}, "Secret") UserKey = bsonutil.MustHaveTag(Host{}, "User") ServicePasswordKey = bsonutil.MustHaveTag(Host{}, "ServicePassword") TagKey = bsonutil.MustHaveTag(Host{}, "Tag") DistroKey = bsonutil.MustHaveTag(Host{}, "Distro") ProviderKey = bsonutil.MustHaveTag(Host{}, "Provider") IPKey = bsonutil.MustHaveTag(Host{}, "IP") IPv4Key = bsonutil.MustHaveTag(Host{}, "IPv4") PersistentDNSNameKey = bsonutil.MustHaveTag(Host{}, "PersistentDNSName") PublicIPv4Key = bsonutil.MustHaveTag(Host{}, "PublicIPv4") ProvisionedKey = bsonutil.MustHaveTag(Host{}, "Provisioned") ProvisionTimeKey = bsonutil.MustHaveTag(Host{}, "ProvisionTime") ExtIdKey = bsonutil.MustHaveTag(Host{}, "ExternalIdentifier") DisplayNameKey = bsonutil.MustHaveTag(Host{}, "DisplayName") RunningTaskFullKey = bsonutil.MustHaveTag(Host{}, "RunningTaskFull") RunningTaskKey = bsonutil.MustHaveTag(Host{}, "RunningTask") RunningTaskExecutionKey = bsonutil.MustHaveTag(Host{}, "RunningTaskExecution") RunningTaskGroupKey = bsonutil.MustHaveTag(Host{}, "RunningTaskGroup") RunningTaskGroupOrderKey = bsonutil.MustHaveTag(Host{}, "RunningTaskGroupOrder") TaskGroupTeardownStartTimeKey = bsonutil.MustHaveTag(Host{}, "TaskGroupTeardownStartTime") RunningTaskBuildVariantKey = bsonutil.MustHaveTag(Host{}, "RunningTaskBuildVariant") RunningTaskVersionKey = bsonutil.MustHaveTag(Host{}, "RunningTaskVersion") RunningTaskProjectKey = bsonutil.MustHaveTag(Host{}, "RunningTaskProject") CreateTimeKey = bsonutil.MustHaveTag(Host{}, "CreationTime") ExpirationTimeKey = bsonutil.MustHaveTag(Host{}, "ExpirationTime") NoExpirationKey = bsonutil.MustHaveTag(Host{}, "NoExpiration") TerminationTimeKey = bsonutil.MustHaveTag(Host{}, "TerminationTime") LTCTimeKey = bsonutil.MustHaveTag(Host{}, "LastTaskCompletedTime") LTCTaskKey = bsonutil.MustHaveTag(Host{}, "LastTask") LTCGroupKey = bsonutil.MustHaveTag(Host{}, "LastGroup") LTCBVKey = bsonutil.MustHaveTag(Host{}, "LastBuildVariant") LTCVersionKey = bsonutil.MustHaveTag(Host{}, "LastVersion") LTCProjectKey = bsonutil.MustHaveTag(Host{}, "LastProject") StatusKey = bsonutil.MustHaveTag(Host{}, "Status") AgentRevisionKey = bsonutil.MustHaveTag(Host{}, "AgentRevision") NeedsNewAgentKey = bsonutil.MustHaveTag(Host{}, "NeedsNewAgent") NeedsNewAgentMonitorKey = bsonutil.MustHaveTag(Host{}, "NeedsNewAgentMonitor") NumAgentCleanupFailuresKey = bsonutil.MustHaveTag(Host{}, "NumAgentCleanupFailures") JasperCredentialsIDKey = bsonutil.MustHaveTag(Host{}, "JasperCredentialsID") NeedsReprovisionKey = bsonutil.MustHaveTag(Host{}, "NeedsReprovision") StartedByKey = bsonutil.MustHaveTag(Host{}, "StartedBy") InstanceTypeKey = bsonutil.MustHaveTag(Host{}, "InstanceType") VolumesKey = bsonutil.MustHaveTag(Host{}, "Volumes") LastCommunicationTimeKey = bsonutil.MustHaveTag(Host{}, "LastCommunicationTime") UserHostKey = bsonutil.MustHaveTag(Host{}, "UserHost") ZoneKey = bsonutil.MustHaveTag(Host{}, "Zone") ProvisionOptionsKey = bsonutil.MustHaveTag(Host{}, "ProvisionOptions") TaskCountKey = bsonutil.MustHaveTag(Host{}, "TaskCount") StartTimeKey = bsonutil.MustHaveTag(Host{}, "StartTime") BillingStartTimeKey = bsonutil.MustHaveTag(Host{}, "BillingStartTime") AgentStartTimeKey = bsonutil.MustHaveTag(Host{}, "AgentStartTime") TotalIdleTimeKey = bsonutil.MustHaveTag(Host{}, "TotalIdleTime") HasContainersKey = bsonutil.MustHaveTag(Host{}, "HasContainers") ParentIDKey = bsonutil.MustHaveTag(Host{}, "ParentID") DockerOptionsKey = bsonutil.MustHaveTag(Host{}, "DockerOptions") ContainerImagesKey = bsonutil.MustHaveTag(Host{}, "ContainerImages") ContainerBuildAttemptKey = bsonutil.MustHaveTag(Host{}, "ContainerBuildAttempt") LastContainerFinishTimeKey = bsonutil.MustHaveTag(Host{}, "LastContainerFinishTime") SpawnOptionsKey = bsonutil.MustHaveTag(Host{}, "SpawnOptions") ContainerPoolSettingsKey = bsonutil.MustHaveTag(Host{}, "ContainerPoolSettings") InstanceTagsKey = bsonutil.MustHaveTag(Host{}, "InstanceTags") SSHKeyNamesKey = bsonutil.MustHaveTag(Host{}, "SSHKeyNames") SSHPortKey = bsonutil.MustHaveTag(Host{}, "SSHPort") HomeVolumeIDKey = bsonutil.MustHaveTag(Host{}, "HomeVolumeID") PortBindingsKey = bsonutil.MustHaveTag(Host{}, "PortBindings") IsVirtualWorkstationKey = bsonutil.MustHaveTag(Host{}, "IsVirtualWorkstation") SleepScheduleKey = bsonutil.MustHaveTag(Host{}, "SleepSchedule") SpawnOptionsTaskIDKey = bsonutil.MustHaveTag(SpawnOptions{}, "TaskID") SpawnOptionsTaskExecutionNumberKey = bsonutil.MustHaveTag(SpawnOptions{}, "TaskExecutionNumber") SpawnOptionsBuildIDKey = bsonutil.MustHaveTag(SpawnOptions{}, "BuildID") SpawnOptionsTimeoutKey = bsonutil.MustHaveTag(SpawnOptions{}, "TimeoutTeardown") SpawnOptionsSpawnedByTaskKey = bsonutil.MustHaveTag(SpawnOptions{}, "SpawnedByTask") VolumeIDKey = bsonutil.MustHaveTag(Volume{}, "ID") VolumeDisplayNameKey = bsonutil.MustHaveTag(Volume{}, "DisplayName") VolumeCreatedByKey = bsonutil.MustHaveTag(Volume{}, "CreatedBy") VolumeTypeKey = bsonutil.MustHaveTag(Volume{}, "Type") VolumeSizeKey = bsonutil.MustHaveTag(Volume{}, "Size") VolumeExpirationKey = bsonutil.MustHaveTag(Volume{}, "Expiration") VolumeNoExpirationKey = bsonutil.MustHaveTag(Volume{}, "NoExpiration") VolumeHostKey = bsonutil.MustHaveTag(Volume{}, "Host") VolumeMigratingKey = bsonutil.MustHaveTag(Volume{}, "Migrating") VolumeAttachmentIDKey = bsonutil.MustHaveTag(VolumeAttachment{}, "VolumeID") VolumeDeviceNameKey = bsonutil.MustHaveTag(VolumeAttachment{}, "DeviceName") DockerOptionsStdinDataKey = bsonutil.MustHaveTag(DockerOptions{}, "StdinData") SleepScheduleNextStopTimeKey = bsonutil.MustHaveTag(SleepScheduleInfo{}, "NextStopTime") SleepScheduleNextStartTimeKey = bsonutil.MustHaveTag(SleepScheduleInfo{}, "NextStartTime") SleepSchedulePermanentlyExemptKey = bsonutil.MustHaveTag(SleepScheduleInfo{}, "PermanentlyExempt") SleepScheduleTemporarilyExemptUntilKey = bsonutil.MustHaveTag(SleepScheduleInfo{}, "TemporarilyExemptUntil") SleepScheduleShouldKeepOffKey = bsonutil.MustHaveTag(SleepScheduleInfo{}, "ShouldKeepOff") )
var ( HostsByDistroDistroIDKey = bsonutil.MustHaveTag(IdleHostsByDistroID{}, "DistroID") HostsByDistroIdleHostsKey = bsonutil.MustHaveTag(IdleHostsByDistroID{}, "IdleHosts") HostsByDistroRunningHostsCountKey = bsonutil.MustHaveTag(IdleHostsByDistroID{}, "RunningHostsCount") )
var All = bson.M{}
All is a query that returns all hosts
var DistroIdStatusIndex = bson.D{ { Key: bsonutil.GetDottedKeyName(DistroKey, distro.IdKey), Value: 1, }, { Key: StatusKey, Value: 1, }, }
DistroIdStatusIndex is the distro_id_1_status_1 index.
var IsIdle = bson.M{ RunningTaskKey: bson.M{"$exists": false}, StatusKey: evergreen.HostRunning, StartedByKey: evergreen.User, }
IsIdle is a query that returns all running Evergreen hosts with no task.
var IsRunningTask = bson.M{ RunningTaskKey: bson.M{"$exists": true}, StatusKey: bson.M{ "$ne": evergreen.HostTerminated, }, }
IsRunningTask is a query that returns all running hosts with a running task
var IsTerminated = bson.M{ RunningTaskKey: bson.M{"$exists": false}, StatusKey: evergreen.HostTerminated, }
IsTerminated is a query that returns all hosts that are terminated (and not running a task).
var IsUninitialized = bson.M{StatusKey: evergreen.HostUninitialized}
IsUninitialized is a query that returns all unstarted + uninitialized Evergreen hosts.
var StartedByStatusIndex = bson.D{ { Key: StartedByKey, Value: 1, }, { Key: StatusKey, Value: 1, }, }
StartedByStatusIndex is the started_by_1_status_1 index.
var StatusIndex = bson.D{ { Key: StatusKey, Value: 1, }, { Key: bsonutil.GetDottedKeyName(SpawnOptionsKey, SpawnOptionsSpawnedByTaskKey), Value: 1, }, }
StatusIndex is the index that is prefixed with the host status.
Functions ¶
func ByDistroIDs ¶
ByDistroIDs produces a query that returns all up hosts of the given distros.
func ByDistroIDsOrAliasesRunning ¶
ByDistroIDOrAliasesRunning returns a query that returns all hosts with matching distro IDs or aliases.
func ByExpiringBetween ¶
ByExpiringBetween produces a query that returns any host not running tasks that will expire between the specified times.
func ByIPAndRunning ¶
ByIPAndRunning produces a query that returns a running host with the given ip address.
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 ByTaskSpec ¶
ByTaskSpec returns a query that finds all running hosts that are running a task with the given group, buildvariant, project, and version.
func ByUserRecentlyTerminated ¶
ByUserRecentlyTerminated produces a query that returns all terminated hosts whose TerminationTimeKey is after the given timestamp.
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 CacheAllCloudProviderData ¶
func CacheAllCloudProviderData(ctx context.Context, env evergreen.Environment, hosts map[string]CloudProviderData) error
CacheAllCloudProviderData performs the same updates as (Host).CacheCloudProviderData but is optimized for updating many hosts at once.
func CanUpdateSpawnHost ¶
CanUpdateSpawnHost is a shared utility function to determine a users permissions to modify a spawn host
func ChmodCommandWithSudo ¶
func ClearExpiredTemporaryExemptions ¶
ClearExpiredTemporaryExemptions clears all temporary exemptions from the sleep schedule that have expired.
func ConsolidateHostsForUser ¶
ConsolidateHostsForUser moves any unterminated hosts/volumes owned by oldUser to be assigned to the newUser.
func CountActiveDynamicHosts ¶
CountActiveDynamicHosts counts the number of task hosts that are active in the cloud provider and can be created dynamically.
func CountActiveHostsInDistro ¶
CountActiveDynamicHosts counts the number of task hosts that are active in the cloud provider in a particular distro.
func CountHostsCanOrWillRunTasksInDistro ¶
CountHostsCanOrWillRunTasksInDistro counts all task hosts in a distro that can run or will eventually run tasks.
func CountHostsCanRunTasks ¶
CountHostsCanRunTasks returns the number of hosts that can accept and run tasks for a given distro. This number is surfaced on the task queue.
func CountIdleStartedTaskHosts ¶
CountIdleStartedTaskHosts returns the count of task hosts that are starting and not currently running a task.
func CountSpawnhostsWithNoExpirationByUser ¶
CountSpawnhostsWithNoExpirationByUser returns a count of all hosts associated with a given users that are considered up and should never expire.
func DecommissionHostsWithDistroId ¶
DecommissionHostsWithDistroId marks all up hosts intended for running tasks that have a matching distro ID as decommissioned.
func DeleteMany ¶
DeleteMany removes all hosts matching the filter from the hosts collection.
func InsertMany ¶
InsertMany inserts the hosts into the hosts collection.
func IsIntentHostId ¶
IsIntentHostId returns whether or not the host ID is for an intent host backed by an ephemeral cloud host. This function does not work for intent hosts representing Docker containers.
func MarkInactiveStaticHosts ¶
func MarkInactiveStaticHosts(ctx context.Context, activeStaticHosts []string, d *distro.Distro) error
MarkInactiveStaticHosts marks static hosts in the database as terminated provided their ids aren't contained in the passed in activeStaticHosts slice. This is called in the scheduler, and marks any static host in the system that was removed from the distro as "terminated".
Previously this operation marked these hosts as "decommissioned," which is not a state that makes sense for static hosts.
If the distro is the empty string ("") then this operation affects all distros. If distro aliases are included, then this operation affects also hosts with the alias.
func MarkStaleBuildingAsFailed ¶
MarkStaleBuildingAsFailed marks building hosts that have been stuck building for too long as failed in order to indicate that they're stale and should be terminated.
func MinTaskGroupOrderRunningByTaskSpec ¶
func MinTaskGroupOrderRunningByTaskSpec(ctx context.Context, group, buildVariant, project, version string) (int, error)
MinTaskGroupOrderRunningByTaskSpec returns the smallest task group order number for tasks with the given group, buildvariant, project, and version that are running on hosts. Returns 0 in the case of missing task group order numbers or no hosts.
func NeedsAgentDeploy ¶
NeedsAgentDeploy finds hosts which need the agent to be deployed because either they do not have an agent yet or their agents have not communicated recently.
func NeedsAgentMonitorDeploy ¶
NeedsAgentMonitorDeploy finds hosts which do not have an agent monitor yet or which should have an agent monitor but their agent has not communicated recently.
func NumHostsByTaskSpec ¶
func NumHostsByTaskSpec(ctx context.Context, group, buildVariant, project, version string) (int, error)
NumHostsByTaskSpec returns the number of running hosts that are running a task with the given group, buildvariant, project, and version.
func RemoveStaleInitializing ¶
Removes host intents that have been initializing for more than 3 minutes.
If you pass the empty string as a distroID, it will remove stale host intents for *all* distros.
func RemoveStrict ¶
RemoveStrict deletes a host and errors if the host is not found.
func ShCommandWithSudo ¶
func ShouldDeployAgent ¶
ShouldDeployAgent returns legacy hosts with NeedsNewAgent set to true and are in a state in which they can deploy agents.
func ShouldDeployAgentMonitor ¶
ShouldDeployAgentMonitor returns running hosts that need a new agent monitor.
func SyncPermanentExemptions ¶
SyncPermanentExemptions finds two sets of unexpirable hosts based on the authoritative list of permanently exempt hosts. The function returns:
- Hosts that are on the list of permanent exemptions but are not marked as permanently exempt (i.e. should be marked as permanently exempt).
- Hosts that are marked as permanently exempt but are not on the list of permanent exemptions (i.e. should be marked as not permanently exempt).
func UnsafeReplace ¶
func UnsafeReplace(ctx context.Context, env evergreen.Environment, idToRemove string, toInsert *Host) error
UnsafeReplace atomically removes the host given by the idToRemove and inserts a new host toInsert. This is typically done to replace the old host with a new one. While the atomic swap is safer than doing it non-atomically, it is not sufficient to guarantee application correctness, because other threads may still be using the old host document.
func UnsetVolumeHost ¶
func ValidateRDPPassword ¶
XXX: if modifying any of the password validation logic, you changes must also be ported into public/static/js/directives/directives.spawn.js
Types ¶
type ClientOptions ¶
type CloudProviderData ¶
type CloudProviderData struct { Zone string StartedAt time.Time PublicDNS string PublicIPv4 string PrivateIPv4 string IPv6 string Volumes []VolumeAttachment }
CloudProviderData represents data to cache in the host from its cloud provider.
type ContainersOnParents ¶
func GetContainersOnParents ¶
getNumContainersOnParents returns a slice of running parents and their respective number of current containers currently running in order of longest expected finish time
type CreateOptions ¶
type CreateOptions struct { Distro distro.Distro ProvisionOptions *ProvisionOptions ExpirationTime time.Time Region string UserName string UserHost bool HasContainers bool ParentID string ContainerPoolSettings *evergreen.ContainerPool SpawnOptions SpawnOptions DockerOptions DockerOptions InstanceTags []Tag InstanceType string NoExpiration bool SleepScheduleInfo IsVirtualWorkstation bool IsCluster bool HomeVolumeSize int HomeVolumeID string }
CreateOptions is a struct of options that are commonly passed around when creating a new cloud host.
type DistroStats ¶
type DistroStats []StatsByDistro
func GetStatsByDistro ¶
func GetStatsByDistro() (DistroStats, error)
GetStatsByDistro returns counts of up hosts broken down by distro
func (DistroStats) CountMap ¶
func (d DistroStats) CountMap() map[string]int
func (DistroStats) MaxHostsExceeded ¶
func (d DistroStats) MaxHostsExceeded() map[string]int
func (DistroStats) TasksMap ¶
func (d DistroStats) TasksMap() map[string]int
type DockerOptions ¶
type DockerOptions struct { // Optional parameters to define a registry name and authentication RegistryName string `mapstructure:"docker_registry_name" bson:"docker_registry_name,omitempty" json:"docker_registry_name,omitempty"` RegistryUsername string `mapstructure:"docker_registry_user" bson:"docker_registry_user,omitempty" json:"docker_registry_user,omitempty"` RegistryPassword string `mapstructure:"docker_registry_pw" bson:"docker_registry_pw,omitempty" json:"docker_registry_pw,omitempty"` // Image is required and specifies the image for the container. // This can be a URL or an image base, to be combined with a registry. Image string `mapstructure:"image_url" bson:"image_url,omitempty" json:"image_url,omitempty"` // Method is either "pull" or "import" and defines how to retrieve the image. Method string `mapstructure:"build_type" bson:"build_type,omitempty" json:"build_type,omitempty"` // Command is the command to run on the docker (if not specified, will use the default entrypoint). Command string `mapstructure:"command" bson:"command,omitempty" json:"command,omitempty"` // If PublishPorts is true, any port that's exposed in the image will be published PublishPorts bool `mapstructure:"publish_ports" bson:"publish_ports,omitempty" json:"publish_ports,omitempty"` // If extra hosts are provided,these will be added to /etc/hosts on the container (in the form of hostname:IP) ExtraHosts []string `mapstructure:"extra_hosts" bson:"extra_hosts,omitempty" json:"extra_hosts,omitempty"` // If the container is created from host create, we want to skip building the image with agent SkipImageBuild bool `mapstructure:"skip_build" bson:"skip_build,omitempty" json:"skip_build,omitempty"` // list of container environment variables KEY=VALUE EnvironmentVars []string `mapstructure:"environment_vars" bson:"environment_vars,omitempty" json:"environment_vars,omitempty"` // StdinData is the data to pass to the container command's stdin. StdinData []byte `mapstructure:"stdin_data" bson:"stdin_data,omitempty" json:"stdin_data,omitempty"` }
DockerOptions contains options for starting a container. This fulfills the ProviderSettings interface to populate container information from the distro settings.
func (*DockerOptions) FromDistroSettings ¶
func (opts *DockerOptions) FromDistroSettings(d distro.Distro, _ string) error
FromDistroSettings loads the Docker container options from the provider settings.
func (*DockerOptions) Validate ¶
func (opts *DockerOptions) Validate() error
Validate checks that the settings from the config file are sane.
type EC2ProviderSettings ¶
type FinishTime ¶
FinishTime is a struct for storing pairs of host IDs and last container finish times
func AggregateLastContainerFinishTimes ¶
func AggregateLastContainerFinishTimes(ctx context.Context) ([]FinishTime, error)
AggregateLastContainerFinishTimes returns the latest finish time for each host with containers
type Host ¶
type Host struct { Id string `bson:"_id" json:"id"` // Host is the ephemeral DNS name of the host. Host string `bson:"host_id" json:"host"` User string `bson:"user" json:"user"` Secret string `bson:"secret" json:"secret"` ServicePassword string `bson:"service_password,omitempty" json:"service_password,omitempty" mapstructure:"service_password,omitempty"` Tag string `bson:"tag" json:"tag"` Distro distro.Distro `bson:"distro" json:"distro"` Provider string `bson:"host_type" json:"host_type"` // IP holds the IPv6 address when applicable. IP string `bson:"ip_address" json:"ip_address"` // IPv4 is the host's private IPv4 address. IPv4 string `bson:"ipv4_address" json:"ipv4_address"` // PersistentDNSName is the long-lived DNS name of the host, which should // never change once set. PersistentDNSName string `bson:"persistent_dns_name,omitempty" json:"persistent_dns_name,omitempty"` // PublicIPv4 is the host's IPv4 address. PublicIPv4 string `bson:"public_ipv4_address,omitempty" json:"public_ipv4_address,omitempty"` // secondary (external) identifier for the host ExternalIdentifier string `bson:"ext_identifier" json:"ext_identifier"` DisplayName string `bson:"display_name" json:"display_name"` // Availability zone of the host. Zone string `bson:"zone" json:"zone"` // True if the app server has done all necessary host setup work (although // the host may need to do additional provisioning before it is running). Provisioned bool `bson:"provisioned" json:"provisioned"` ProvisionTime time.Time `bson:"prov_time,omitempty" json:"prov_time,omitempty"` ProvisionOptions *ProvisionOptions `bson:"provision_options,omitempty" json:"provision_options,omitempty"` // the task that is currently running on the host RunningTask string `bson:"running_task,omitempty" json:"running_task,omitempty"` RunningTaskExecution int `bson:"running_task_execution" json:"running_task_execution"` RunningTaskBuildVariant string `bson:"running_task_bv,omitempty" json:"running_task_bv,omitempty"` RunningTaskVersion string `bson:"running_task_version,omitempty" json:"running_task_version,omitempty"` RunningTaskProject string `bson:"running_task_project,omitempty" json:"running_task_project,omitempty"` RunningTaskGroup string `bson:"running_task_group,omitempty" json:"running_task_group,omitempty"` RunningTaskGroupOrder int `bson:"running_task_group_order,omitempty" json:"running_task_group_order,omitempty"` // TaskGroupTeardownStartTime represents the time when the teardown of task groups process started for the host. TaskGroupTeardownStartTime time.Time `bson:"teardown_start_time,omitempty" json:"teardown_start_time,omitempty"` // the task the most recently finished running on the host LastTask string `bson:"last_task" json:"last_task"` LastGroup string `bson:"last_group,omitempty" json:"last_group,omitempty"` LastBuildVariant string `bson:"last_bv,omitempty" json:"last_bv,omitempty"` LastVersion string `bson:"last_version,omitempty" json:"last_version,omitempty"` LastProject string `bson:"last_project,omitempty" json:"last_project,omitempty"` // the full task struct that is running on the host (only populated by certain aggregations) RunningTaskFull *task.Task `bson:"task_full,omitempty" json:"task_full,omitempty"` ExpirationTime time.Time `bson:"expiration_time,omitempty" json:"expiration_time"` NoExpiration bool `bson:"no_expiration" json:"no_expiration"` // creation is when the host document was inserted to the DB, start is when it was started on the cloud provider CreationTime time.Time `bson:"creation_time" json:"creation_time"` StartTime time.Time `bson:"start_time" json:"start_time"` // BillingStartTime is when billing started for the host. BillingStartTime time.Time `bson:"billing_start_time" json:"billing_start_time"` // AgentStartTime is when the agent first initiates contact with the app // server. AgentStartTime time.Time `bson:"agent_start_time" json:"agent_start_time"` TerminationTime time.Time `bson:"termination_time" json:"termination_time"` TaskCount int `bson:"task_count" json:"task_count"` LastTaskCompletedTime time.Time `bson:"last_task_completed_time" json:"last_task_completed_time"` LastCommunicationTime time.Time `bson:"last_communication" json:"last_communication"` 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"` NeedsNewAgent bool `bson:"needs_agent" json:"needs_agent"` NeedsNewAgentMonitor bool `bson:"needs_agent_monitor" json:"needs_agent_monitor"` // NumAgentCleanupFailures represents the number of consecutive failed attempts a host has gone through // while trying to clean up an agent on a quarantined host. NumAgentCleanupFailures int `bson:"num_agent_cleanup_failures" json:"num_agent_cleanup_failures"` // NeedsReprovision is set if the host needs to be reprovisioned. // These fields must be unset if no provisioning is needed anymore. NeedsReprovision ReprovisionType `bson:"needs_reprovision,omitempty" json:"needs_reprovision,omitempty"` // JasperCredentialsID is used to match hosts to their Jasper credentials // for non-legacy hosts. JasperCredentialsID string `bson:"jasper_credentials_id" json:"jasper_credentials_id"` // InstanceType is the EC2 host's requested instance type. This is kept // up-to-date even if the instance type is changed. InstanceType string `bson:"instance_type" json:"instance_type,omitempty"` // The volumeID and device name for each volume attached to the host Volumes []VolumeAttachment `bson:"volumes,omitempty" json:"volumes,omitempty"` // accrues the value of idle time. TotalIdleTime time.Duration `bson:"total_idle_time,omitempty" json:"total_idle_time,omitempty" yaml:"total_idle_time,omitempty"` // managed containers require different information based on host type // True if this host is a parent of containers HasContainers bool `bson:"has_containers,omitempty" json:"has_containers,omitempty"` // stores URLs of container images already downloaded on a parent ContainerImages map[string]bool `bson:"container_images,omitempty" json:"container_images,omitempty"` // stores the ID of the host a container is on ParentID string `bson:"parent_id,omitempty" json:"parent_id,omitempty"` // stores last expected finish time among all containers on the host LastContainerFinishTime time.Time `bson:"last_container_finish_time,omitempty" json:"last_container_finish_time,omitempty"` // ContainerPoolSettings ContainerPoolSettings *evergreen.ContainerPool `bson:"container_pool_settings,omitempty" json:"container_pool_settings,omitempty"` ContainerBuildAttempt int `bson:"container_build_attempt" json:"container_build_attempt"` // SpawnOptions holds data which the monitor uses to determine when to terminate hosts spawned by tasks. SpawnOptions SpawnOptions `bson:"spawn_options,omitempty" json:"spawn_options,omitempty"` // DockerOptions stores information for creating a container with a specific image and command DockerOptions DockerOptions `bson:"docker_options,omitempty" json:"docker_options,omitempty"` // PortBindings is populated if PublishPorts is specified when creating docker container from task PortBindings PortMap `bson:"port_bindings,omitempty" json:"port_bindings,omitempty"` // InstanceTags stores user-specified tags for instances InstanceTags []Tag `bson:"instance_tags,omitempty" json:"instance_tags,omitempty"` // SSHKeyNames contains the names of the SSH key that have been distributed // to this host. SSHKeyNames []string `bson:"ssh_key_names,omitempty" json:"ssh_key_names,omitempty"` // SSHPort is the port to use when connecting to the host with SSH. SSHPort int `bson:"ssh_port,omitempty" json:"ssh_port,omitempty"` IsVirtualWorkstation bool `bson:"is_virtual_workstation" json:"is_virtual_workstation"` // HomeVolumeSize is the size of the home volume in GB HomeVolumeSize int `bson:"home_volume_size" json:"home_volume_size"` HomeVolumeID string `bson:"home_volume_id" json:"home_volume_id"` // SleepSchedule stores host sleep schedule information. SleepSchedule SleepScheduleInfo `bson:"sleep_schedule,omitempty" json:"sleep_schedule,omitempty"` }
func Aggregate ¶
func Aggregate(ctx context.Context, pipeline []bson.M, options ...*options.AggregateOptions) ([]Host, error)
Aggregate performs the aggregation pipeline on the host collection and returns the resulting hosts. Implement the aggregation directly if the result of the pipeline is not an array of hosts.
func AllHostsSpawnedByTasksToTerminate ¶
AllHostsSpawnedByTasksToTerminate finds all hosts spawned by tasks that should be terminated.
func FindAllHostsSpawnedByTasks ¶
FindAllHostsSpawnedByTasks finds all running hosts spawned by the `host.create` command.
func FindAllRunningContainers ¶
FindAllRunningContainers finds all the containers that are currently running
func FindAllRunningParents ¶
FindAllRunningParents finds all running hosts that have child containers
func FindAllRunningParentsByDistroID ¶
FindAllRunningParentsByDistroID finds all running hosts of a given distro ID with child containers.
func FindAllRunningParentsOrdered ¶
FindAllRunningParentsOrdered finds all running hosts with child containers, sorted in order of soonest to latest LastContainerFinishTime
func FindByNeedsToRestartJasper ¶
FindByNeedsToRestartJasper finds all hosts that are ready and waiting to restart their Jasper service.
func FindByProvisioning ¶
FindByProvisioning finds all hosts that are not yet provisioned by the app server.
func FindByShouldConvertProvisioning ¶
FindByShouldConvertProvisioning finds all hosts that are ready and waiting to convert their provisioning type.
func FindByTemporaryExemptionsExpiringBetween ¶
func FindByTemporaryExemptionsExpiringBetween(ctx context.Context, lowerBound time.Time, upperBound time.Time) ([]Host, error)
FindByTemporaryExemptionsExpiringBetween finds all spawn hosts with a temporary exemption from the sleep schedule that will expire between the specified times.
func FindExceedsSleepScheduleTimeout ¶
FindExceedsSleepScheduleTimeout finds hosts that are subject to the sleep schedule and are scheduled to stop/start, but have taken a long time to do so.
func FindHostWithVolume ¶
FindHostWithVolume finds the host associated with the specified volume ID.
func FindHostsInRange ¶
func FindHostsInRange(ctx context.Context, params HostsInRangeParams) ([]Host, error)
FindHostsInRange is a method to find a filtered list of hosts
func FindHostsScheduledToStart ¶
FindHostsToSleep finds all unexpirable hosts that are due to start soon due to their sleep schedule settings.
func FindHostsScheduledToStop ¶
FindHostsScheduledToStop finds all unexpirable hosts that are due to stop due to their sleep schedule settings.
func FindHostsSpawnedByBuild ¶
FindHostsSpawnedByBuild finds hosts spawned by the `createhost` command scoped to a given build.
func FindHostsSpawnedByTask ¶
func FindHostsSpawnedByTask(ctx context.Context, taskID string, execution int, statuses []string) ([]Host, error)
FindHostsSpawnedByTask finds hosts spawned by the `host.create` command scoped to a given task.
func FindLatestTerminatedHostWithHomeVolume ¶
func FindLatestTerminatedHostWithHomeVolume(ctx context.Context, homeVolumeID string, startedBy string) (*Host, error)
FindLatestTerminatedHostWithHomeVolume finds the user's most recently terminated host associated with the specified home volume ID.
func FindMissingNextSleepScheduleTime ¶
FindMissingNextSleepScheduleTime finds hosts that are subject to the sleep schedule but are missing a next scheduled stop/start time.
func FindOneByIdOrTag ¶
FindOneByIdOrTag finds a host where the given id is stored in either the _id or tag field. (The tag field is used for the id from the host's original intent host.)
func FindOneByPersistentDNSName ¶
FindOneByPersistentDNSName returns hosts that have a matching persistent DNS name.
func FindOneByTaskIdAndExecution ¶
FindOneByTaskIdAndExecution returns a single host with the given running task ID and execution.
func FindRunningHosts ¶
FindRunningHosts is the underlying query behind the hosts page's table
func FindSpawnhostsWithNoExpirationToExtend ¶
FindSpawnhostsWithNoExpirationToExtend returns all hosts that are set to never expire but have their expiration time within the next day and are still up.
func FindStaticNeedsNewSSHKeys ¶
FindStaticNeedsNewSSHKeys finds all static hosts that do not have the same set of SSH keys as those in the global settings.
func FindTerminatedHostsRunningTasks ¶
FindTerminatedHostsRunningTasks finds all hosts that were running tasks when they were terminated.
func FindUnexpirableRunning ¶
FindUnexpirableRunning returns all unexpirable spawn hosts that are currently running.
func FindUpHostWithHomeVolume ¶
FindUpHostWithHomeVolume finds the up host associated with the specified home volume ID.
func FindUserDataSpawnHostsProvisioning ¶
FindUserDataSpawnHostsProvisioning finds all spawn hosts that have been provisioned by the app server but are still being provisioned by user data.
func GetHostByIdOrTagWithTask ¶
GetHostByIdOrTagWithTask finds a host by ID or tag and includes the full running task with the host.
func GetPaginatedRunningHosts ¶
func GetPaginatedRunningHosts(ctx context.Context, opts HostsFilterOptions) ([]Host, *int, int, error)
GetPaginatedRunningHosts gets running hosts with pagination and applies any filters.
func IdleHostsWithDistroID ¶
IdleHostsWithDistroID, given a distroID, returns a slice of all idle hosts in that distro
func NewIntent ¶
func NewIntent(options CreateOptions) *Host
NewIntent creates an intent host using the given host settings. An intent host is a host that does not exist yet in the cloud but will be eventually started by the system. This function takes distro information, the name of the instance, the provider of the instance and a CreateOptions and returns an intent host.
func (*Host) AddPublicKeyScript ¶
AddPublicKeyScript returns the shell script to add a public key to the authorized keys file on the host. If the public key already exists on the host, the authorized keys file will not be modified.
func (*Host) AddSSHKeyName ¶
AddSSHKeyName adds the SSH key name for the host if it doesn't already have it.
func (*Host) AddTags ¶
AddTags adds the specified tags to the host document, or modifies an existing tag if it can be modified. Does not allow changes to tags set by Evergreen.
func (*Host) AddVolumeToHost ¶
func (h *Host) AddVolumeToHost(ctx context.Context, newVolume *VolumeAttachment) error
func (*Host) AgentBinary ¶
AgentBinary returns the path to the evergreen agent binary.
func (*Host) AgentCommand ¶
AgentCommand returns the arguments to start the agent. If executablePath is not specified, it will be assumed to be in the regular place (only pass this for container distros)
func (*Host) AgentMonitorOptions ¶
AgentMonitorOptions assembles the input to a Jasper request to start the agent monitor.
func (*Host) ChangeJasperDirsOwnerCommand ¶
changeJasperDirsOwnerCommand returns the command to ensure that the Jasper directories have proper permissions.
func (*Host) CheckTaskDataFetched ¶
func (*Host) CheckUserDataProvisioningStartedCommand ¶
CheckUserDataProvisioningStarted checks whether the provisioning script has already run on a user data host. If it has, it exits. Otherwise, it creates the file marking it as started.
func (*Host) ClearDockerStdinData ¶
ClearDockerStdinData clears the Docker stdin data from the host.
func (*Host) ClearRunningAndSetLastTask ¶
ClearRunningAndSetLastTask unsets the running task on the host and updates the last task fields.
func (*Host) ClearRunningTask ¶
ClearRunningTask unsets the running task on the host and logs an event indicating it is no longer running the task.
func (*Host) ClearRunningTaskWithContext ¶
ClearRunningTaskWithContext unsets the running task on the log. It does not log an event for clearing the task.
func (*Host) CountContainersRunningAtTime ¶
CountContainersRunningAtTime counts how many containers were running on the given parent host at the specified time, using the host StartTime and TerminationTime fields.
func (*Host) CreateSecret ¶
CreateSecret generates a host secret and updates the host both locally and in the database, with the option to clear the secret rather than set a new one.
func (*Host) CreateServicePassword ¶
CreateServicePassword creates the password for the host's service user.
func (*Host) CurlCommand ¶
func (h *Host) CurlCommand(env evergreen.Environment) (string, error)
CurlCommand returns the command to download the evergreen client.
func (*Host) CurlCommandWithDefaultRetry ¶
func (h *Host) CurlCommandWithDefaultRetry(env evergreen.Environment) (string, error)
CurlCommandWithDefaultRetry is the same as CurlCommandWithRetry using the default retry parameters.
func (*Host) CurlCommandWithRetry ¶
func (h *Host) CurlCommandWithRetry(env evergreen.Environment, numRetries, maxRetrySecs int) (string, error)
CurlCommandWithRetry is the same as CurlCommand but retries the request.
func (*Host) DeleteJasperCredentials ¶
DeleteJasperCredentials deletes the Jasper credentials for the host and updates the host both in memory and in the database.
func (*Host) DeleteTags ¶
DeleteTags removes tags specified by their keys, only if those keys are allowed to be deleted. Does not allow changes to tags set by Evergreen.
func (*Host) FetchAndReinstallJasperCommands ¶
FetchAndReinstallJasperCommands returns the command to fetch Jasper and restart the service with the latest version.
func (*Host) FetchJasperCommand ¶
func (h *Host) FetchJasperCommand(config evergreen.HostJasperConfig) string
FetchJasperCommand builds the command to download and extract the Jasper binary into the distro-specific binary directory.
func (*Host) ForceReinstallJasperCommand ¶
ForceReinstallJasperCommand returns the command to stop the Jasper service (if it's running), delete the current Jasper service configuration (if it exists), install the new configuration, and restart the service.
func (*Host) GenerateFetchProvisioningScriptUserData ¶
func (h *Host) GenerateFetchProvisioningScriptUserData(ctx context.Context, env evergreen.Environment) (*userdata.Options, error)
GenerateFetchProvisioningScriptUserData creates the user data script to fetch the host provisioning script.
func (*Host) GenerateJasperCredentials ¶
func (h *Host) GenerateJasperCredentials(ctx context.Context, env evergreen.Environment) (*certdepot.Credentials, error)
GenerateJasperCredentials creates the Jasper credentials for the given host without saving them to the database. If credentials already exist in the database, they are deleted.
func (*Host) GeneratePersistentDNSName ¶
GeneratePersistentDNSName returns the host's persistent DNS name, or generates a new one if it doesn't have one currently assigned.
func (*Host) GenerateUserDataProvisioningScript ¶
func (h *Host) GenerateUserDataProvisioningScript(ctx context.Context, settings *evergreen.Settings, creds *certdepot.Credentials, githubAppToken string, moduleTokens []string) (string, error)
GenerateUserDataProvisioningScript creates a script to provision a host that is provisioning in user data. If, for some reason, this script gets interrupted, there's no guarantee that it will succeed if run again, since we cannot enforce idempotency on the setup script.
func (*Host) GetActiveContainers ¶
func (*Host) GetContainers ¶
GetContainers finds all the containers belonging to this host errors if this host is not a parent
func (*Host) GetCreateOptions ¶
func (h *Host) GetCreateOptions() CreateOptions
func (*Host) GetElapsedCommunicationTime ¶
GetElapsedCommunicationTime returns how long since this host has communicated with evergreen or vice versa
func (*Host) GetJasperProcess ¶
func (h *Host) GetJasperProcess(ctx context.Context, env evergreen.Environment, processID string) (complete bool, output string, err error)
GetJasperProcess makes a request to the host's Jasper service to get a started process's status. Processes with an output logger return output.
func (*Host) GetParent ¶
GetParent finds the parent of this container errors if host is not a container or if parent cannot be found
func (*Host) GetSSHOptions ¶
GetSSHOptions returns the options to SSH into this host from an application server.
func (*Host) GetSSHPort ¶
GetSSHPort returns the host's SSH port. If no port has been specified, it returns the standard SSH port.
func (*Host) GetSubnetID ¶
GetSubnetID returns the subnet ID for the host if available, otherwise returns the empty string.
func (*Host) GetTaskGroupString ¶
func (*Host) GetTemporaryExemption ¶
GetTemporaryExemption validates and calculates a temporary exemption from the host's sleep schedule.
func (*Host) HomeVolume ¶
func (h *Host) HomeVolume() *VolumeAttachment
func (*Host) HostVolumeDeviceNames ¶
func (*Host) IdleTime ¶
IdleTime returns how long has this host has been sitting idle. In this context idle time means the duration the host has not been running a task even though it could have been. The time before the host was ready to run a task does not count as idle time because the host needs time to come up.
func (*Host) IncContainerBuildAttempt ¶
func (*Host) IncIdleTime ¶
IncIdleTime increments the host's TotalIdleTime. Noop if idleTime is non-positive.
func (*Host) IncTaskCount ¶
func (*Host) IncrementNumAgentCleanupFailures ¶
IncrementNumAgentCleanupFailures will increment the NumAgentCleanupFailures field by 1.
func (*Host) InsertWithContext ¶
InsertWithContext is the same as Insert but accepts a context for the operation.
func (*Host) IsContainer ¶
func (*Host) IsEphemeral ¶
func (*Host) IsFree ¶
IsFree checks that the host is not running a task and is not in the process of tearing down.
func (*Host) IsIdleParent ¶
IsIdleParent determines whether a host has only inactive containers
func (*Host) IsSleepScheduleEnabled ¶
IsSleepScheduleEnabled returns whether or not a sleep schedule is enabled for the host, taking into account that some hosts are not subject to the sleep schedule (e.g. expirable hosts).
func (*Host) IsSubjectToHostCreationThrottle ¶
func (*Host) IsTearingDown ¶
IsTearingDown determines if TeardownStartTime is not zero time, therefore indicating that the host is tearing down
func (*Host) IsWaitingForAgent ¶
IsWaitingForAgent provides a local predicate for the logic for whether the host needs either a new agent or agent monitor.
func (*Host) JasperBinaryFilePath ¶
func (h *Host) JasperBinaryFilePath(config evergreen.HostJasperConfig) string
JasperBinaryFilePath returns the full path to the Jasper binary.
func (*Host) JasperClient ¶
JasperClient returns a remote client that communicates with this host's Jasper service.
func (*Host) JasperClientCredentials ¶
func (h *Host) JasperClientCredentials(ctx context.Context, env evergreen.Environment) (*certdepot.Credentials, error)
JasperClientCredentials gets the Jasper credentials for a client to communicate with the host's running Jasper service. These credentials should be used only to connect to the host's Jasper service.
func (*Host) JasperCredentials ¶
func (h *Host) JasperCredentials(ctx context.Context, env evergreen.Environment) (*certdepot.Credentials, error)
JasperCredentials gets the Jasper credentials for this host's running Jasper service from the database. These credentials should not be used to connect to the Jasper service - use JasperClientCredentials for this purpose.
func (*Host) JasperCredentialsExpiration ¶
func (h *Host) JasperCredentialsExpiration(ctx context.Context, env evergreen.Environment) (time.Time, error)
JasperCredentialsExpiration returns the time at which the host's Jasper credentials will expire.
func (*Host) MakeJasperDirsCommand ¶
MakeJasperDirsCommand creates the directories with the correct permissions to provision the host with Jasper.
func (*Host) MarkAsReprovisioned ¶
MarkAsReprovisioned indicates that the host was successfully reprovisioned.
func (*Host) MarkAsReprovisioning ¶
MarkAsReprovisioning puts the host in a state that means it is ready to be reprovisioned immediately.
func (*Host) MarkShouldExpire ¶
MarkShouldExpire resets a host's expiration to expire like a normal spawn host, after 24 hours.
func (*Host) MarkShouldNotExpire ¶
MarkShouldNotExpire marks a host as one that should not expire and updates its expiration time to avoid early reaping. If the host is marked unexpirable and has invalid/missing sleep schedule settings, it is assigned the default sleep schedule.
func (*Host) MarkUserDataProvisioningDoneCommand ¶
MarkUserDataDoneProvisioningCommand creates the command to make the marker file indicating user data provisioning has finished executing.
func (*Host) NeedsPortBindings ¶
func (*Host) QuietUninstallJasperCommand ¶
func (h *Host) QuietUninstallJasperCommand(config evergreen.HostJasperConfig) string
QuietUninstallJasperCommand returns the command to uninstall the Jasper service. If the service is already not installed, this no-ops.
func (*Host) Remove ¶
Remove removes the host document from the DB. While it's fine to use this in tests, this should generally not be called in production code since deleting the host document makes it difficult to trace what happened to it. Instead, it's preferable to set a host to a failure state (e.g. building-failed, decommissioned) so that it can be cleaned up by host termination.
func (*Host) RemoveVolumeFromHost ¶
func (*Host) Replace ¶
Replace overwrites an existing host document with a new one. If no existing host is found, the new one will be inserted anyway.
func (*Host) ResetLastCommunicated ¶
ResetLastCommunicated sets the LastCommunicationTime to be zero.
func (*Host) RestartJasperCommand ¶
func (h *Host) RestartJasperCommand(config evergreen.HostJasperConfig) string
RestartJasperCommand returns the command to restart the Jasper service with the existing configuration.
func (*Host) RunJasperProcess ¶
func (h *Host) RunJasperProcess(ctx context.Context, env evergreen.Environment, opts *options.Create) ([]string, error)
RunJasperProcess makes a request to the host's Jasper service to create the process with the given options, wait for its completion, and returns the output from it.
func (*Host) RunSSHCommand ¶
RunSSHCommand runs an SSH command on the host with the default SSH timeout.
func (*Host) RunSSHCommandWithTimeout ¶
func (h *Host) RunSSHCommandWithTimeout(ctx context.Context, cmd string, timeout time.Duration) (string, error)
RunSSHCommandWithTimeout runs an SSH command on the host with the given timeout.
func (*Host) RunSSHShellScript ¶
func (h *Host) RunSSHShellScript(ctx context.Context, script string, sudo bool, sudoUser string) (string, error)
RunSSHShellScript runs a shell script on a remote host over SSH with the default SSH timeout.
func (*Host) RunSSHShellScriptWithTimeout ¶
func (h *Host) RunSSHShellScriptWithTimeout(ctx context.Context, script string, sudo bool, sudoUser string, timeout time.Duration) (string, error)
RunSSHShellScript runs a shell script on a remote host over SSH with the given timeout.
func (*Host) SaveJasperCredentials ¶
func (h *Host) SaveJasperCredentials(ctx context.Context, env evergreen.Environment, creds *certdepot.Credentials) error
SaveJasperCredentials saves the given Jasper credentials in the database for the host.
func (*Host) SetAgentRevision ¶
SetAgentRevision sets the updated agent revision for the host
func (*Host) SetBillingStartTime ¶
func (*Host) SetDNSName ¶
SetDNSName updates the DNS name for a given host once
func (*Host) SetDecommissioned ¶
func (h *Host) SetDecommissioned(ctx context.Context, user string, decommissionIfBusy bool, logs string) error
SetDecommissioned sets the host as decommissioned. If decommissionIfBusy isn't set, we only update the host if there is no running task.
func (*Host) SetDisplayName ¶
func (*Host) SetExpirationTime ¶
SetExpirationTime updates the expiration time of a spawn host
func (*Host) SetHomeVolumeID ¶
func (*Host) SetInstanceType ¶
SetInstanceType updates the host's instance type in the database.
func (*Host) SetNeedsAgentDeploy ¶
SetNeedsAgentDeploy indicates that the host's agent or agent monitor needs to be deployed.
func (*Host) SetNeedsNewAgent ¶
SetNeedsNewAgent sets the "needs new agent" flag on the host.
func (*Host) SetNeedsNewAgentMonitor ¶
SetNeedsNewAgentMonitor sets the "needs new agent monitor" flag on the host to indicate that the host needs to have the agent monitor deployed.
func (*Host) SetNeedsReprovisionToNew ¶
SetNeedsReprovisionToNew marks a host that is currently using new provisioning to provision again.
func (*Host) SetNeedsToRestartJasper ¶
SetNeedsToRestartJasper sets this host as needing to have its Jasper service restarted as long as the host does not already need a different reprovisioning change. If the host is ready to reprovision now (i.e. no agent monitor is running), it is put in the reprovisioning state.
func (*Host) SetNextScheduledStartAndStopTimes ¶
func (h *Host) SetNextScheduledStartAndStopTimes(ctx context.Context, nextStart, nextStop time.Time) error
SetNextScheduledStartAndStopTimes sets both the next time the host is planned to start and the next time the host is planned to stop for its sleep schedule.
func (*Host) SetNextScheduledStartTime ¶
SetNextScheduledStartTime sets the next time the host is planned to start for its sleep schedule.
func (*Host) SetNextScheduledStopTime ¶
SetNextScheduledStopTime sets the next time the host is planned to stop for its sleep schedule.
func (*Host) SetPersistentDNSInfo ¶
SetPersistentDNSInfo sets the host's persistent DNS name and the associated IP address.
func (*Host) SetPortMapping ¶
probably don't want to store the port mapping exactly this way
func (*Host) SetProvisionedNotRunning ¶
SetProvisionedNotRunning marks the host as having been provisioned by the app server but the host is not necessarily running yet.
func (*Host) SetProvisioning ¶
SetProvisioning marks the host as initializing. Only allow this if the host is uninitialized.
func (*Host) SetQuarantined ¶
func (*Host) SetStatus ¶
SetStatus updates a host's status on behalf of the given user. Clears last running task for hosts that are being moved to running, since this information is likely outdated.
func (*Host) SetStatusAtomically ¶
SetStatusAtomically is the same as SetStatus but only updates the host if its status in the database matches currentStatus.
func (*Host) SetStopped ¶
SetStopped sets a host to stopped. If shouldKeepOff is true, it will also keep the host off and ignore any sleep schedule until it's started up again by a user.
func (*Host) SetTaskGroupTeardownStartTime ¶
SetTaskGroupTeardownStartTime sets the TaskGroupTeardownStartTime to the current time for the host
func (*Host) SetTemporaryExemption ¶
SetTemporaryExemption sets a temporary exemption from the host's sleep schedule.
func (*Host) SetTerminated ¶
func (*Host) SetUserDataHostProvisioned ¶
SetUserDataHostProvisioned sets the host to running if it was bootstrapped with user data but has not yet been marked as done provisioning.
func (*Host) SetVolumes ¶
func (h *Host) SetVolumes(ctx context.Context, volumes []VolumeAttachment) error
func (*Host) SetupCommand ¶
SetupCommand returns the command to run the host setup script.
func (*Host) SetupServiceUserCommands ¶
SetupServiceUserCommands returns the commands to create a passwordless service user in the Administrator group in Windows. It also creates the service user's password if none is set.
func (*Host) ShouldNotifyStoppedSpawnHostIdle ¶
ShouldNotifyStoppedSpawnHostIdle returns true if the stopped spawn host has been idle long enough to notify the user.
func (*Host) SpawnHostGetTaskDataCommand ¶
func (h *Host) SpawnHostGetTaskDataCommand(ctx context.Context, githubAppToken string, moduleTokens []string) []string
SpawnHostGetTaskDataCommand returns the command that fetches the task data for a spawn host.
func (*Host) SpawnHostPullTaskSyncCommand ¶
SpawnHostPullTaskSyncCommand returns the command that pulls the task sync directory for a spawn host.
func (*Host) SpawnHostSetupCommands ¶
SpawnHostSetupCommands returns the commands to handle setting up a spawn host with the evergreen binary and config file for the owner.
func (*Host) StartAgentMonitorRequest ¶
func (h *Host) StartAgentMonitorRequest(ctx context.Context, settings *evergreen.Settings) (string, error)
StartAgentMonitorRequest builds the Jasper client request that starts the agent monitor on the host. The host secret is created if it doesn't exist yet.
func (*Host) StartJasperProcess ¶
func (h *Host) StartJasperProcess(ctx context.Context, env evergreen.Environment, opts *options.Create) (string, error)
StartJasperProcess makes a request to the host's Jasper service to start a process with the given options without waiting for its completion.
func (*Host) StopAgentMonitor ¶
StopAgentMonitor stops the agent monitor (if it is running) on the host via its Jasper service. On legacy hosts, this is a no-op. Stopping the agent monitor manually like this is only necessary for legacy reasons. There are some static hosts that have been quarantined for a long time, and they could have very old versions of the agent monitor running on them. Newer versions of the agent monitor shut themselves down when appropriate, making this operation unnecessary. However, we have no guarantee on how long ago hosts were quarantined and when they might be unquarantined, meaning we can't get rid of this unless we know every single static host has is running a relatively recent version of the agent monitor.
func (*Host) TaskStartMessage ¶
func (*Host) TeardownTimeExceededMax ¶
TeardownTimeExceededMax checks if the time since the host's task group teardown start time has exceeded the maximum teardown threshold.
func (*Host) Terminate ¶
Terminate marks a host as terminated, sets the termination time, and unsets the host volumes.
func (*Host) UnmarshalBSON ¶
func (*Host) UnsetHomeVolume ¶
UnsetHomeVolume disassociates a home volume from a (stopped) host. This is for internal use, and should only be used on hosts that will be terminated imminently; otherwise, the host will fail to boot.
func (*Host) UnsetNumAgentCleanupFailures ¶
UnsetNumAgentCleanupFailures unsets the NumAgentCleanupFailures field.
func (*Host) UnsetPersistentDNSInfo ¶
UnsetPersistentDNSInfo unsets the host's persistent DNS name and the associated IP address.
func (*Host) UnsetTaskGroupTeardownStartTime ¶
UnsetTaskGroupTeardownStartTime unsets the TaskGroupTeardownStartTime for the host.
func (*Host) UpdateCachedDistroProviderSettings ¶
func (*Host) UpdateJasperCredentialsID ¶
UpdateJasperCredentialsID sets the ID of the host's Jasper credentials.
func (*Host) UpdateLastCommunicated ¶
UpdateLastCommunicated sets the host's last communication time to the current time.
func (*Host) UpdateLastContainerFinishTime ¶
UpdateLastContainerFinishTime updates latest finish time for a host with containers
func (*Host) UpdateRunningTaskWithContext ¶
func (h *Host) UpdateRunningTaskWithContext(ctx context.Context, env evergreen.Environment, t *task.Task) error
UpdateRunningTaskWithContext updates the running task for the host. It does not log an event for task assignment.
func (*Host) UpdateSleepSchedule ¶
func (h *Host) UpdateSleepSchedule(ctx context.Context, schedule SleepScheduleInfo, now time.Time) error
UpdateSleepSchedule updates the sleep schedule of an existing host. Note that if some fields in the sleep schedule are not being modified, the sleep schedule must still contain all the unmodified fields. For example, if this host is on a temporary exemption when their daily schedule is updated, the new schedule must still have the temporary exemption populated.
func (*Host) UpdateStartingToRunning ¶
UpdateStartingToRunning changes the host status from provisioning to running, as well as logging that the host has finished provisioning.
func (*Host) UserDataProvisioningDoneFile ¶
UserDataProvisioningDoneFile returns the path to the user data provisioning done marker file.
func (*Host) UserDataProvisioningStartedFile ¶
UserDataProvisioningStartedFile returns the path to the user data provisioning started marker file.
func (*Host) ValidateExpirationExtension ¶
ValidateExpirationExtension will prevent expirable spawn hosts from being extended past 30 days from its creation and not earlier than the current time.
func (*Host) WastedComputeTime ¶
WastedComputeTime returns the duration of compute we've paid for that wasn't used to run a task. This is the duration since the last task to run on the host completed or, if no task has run, the host's uptime. The time the host is alive before it's able to run a task also counts as wasted compute.
func (*Host) WithAgentMonitor ¶
func (h *Host) WithAgentMonitor(ctx context.Context, env evergreen.Environment, handleAgentMonitor func(procs []jasper.Process) error) error
WithAgentMonitor runs the given handler on all agent monitor processes running on the host.
func (*Host) WriteJasperCredentialsFilesCommands ¶
func (h *Host) WriteJasperCredentialsFilesCommands(splunk send.SplunkConnectionInfo, creds *certdepot.Credentials) (string, error)
WriteJasperCredentialsFilesCommands builds the command to write the Jasper credentials and Splunk credentials to files.
func (*Host) WriteJasperPreconditionScriptsCommands ¶
WriteJasperPreconditionScriptsCommands returns the command to write the Jasper precondition scripts to files.
type HostGroup ¶
type HostGroup []Host
func AllActiveHosts ¶
AllActiveHosts produces a HostGroup for all hosts with UpHost status as well as quarantined hosts. These do not count spawn hosts.
func (HostGroup) CountContainersOnParents ¶
CountContainersOnParents counts how many containers are children of the given group of hosts
func (HostGroup) FindUphostContainersOnParents ¶
FindUphostContainersOnParents returns the containers that are children of the given hosts
func (HostGroup) GetHostIds ¶
GetHostIds returns a slice of host IDs for the given group of hosts
func (HostGroup) Stats ¶
func (hosts HostGroup) Stats() HostGroupStats
type HostGroupStats ¶
type HostGroupStats struct { Quarantined int `bson:"quarantined" json:"quarantined" yaml:"quarantined"` Decommissioned int `bson:"decommissioned" json:"decommissioned" yaml:"decommissioned"` Idle int `bson:"idle" json:"idle" yaml:"idle"` Active int `bson:"active" json:"active" yaml:"active"` Provisioning int `bson:"provisioning" json:"provisioning" yaml:"provisioning"` Total int `bson:"total" json:"total" yaml:"total"` }
type HostModifyOptions ¶
type HostModifyOptions struct { AddInstanceTags []Tag `json:"add_instance_tags"` DeleteInstanceTags []string `json:"delete_instance_tags"` InstanceType string `json:"instance_type"` NoExpiration *bool `json:"no_expiration"` // whether host should never expire SleepScheduleOptions `bson:",inline"` AddHours time.Duration `json:"add_hours"` // duration to extend expiration AddTemporaryExemptionHours int `json:"add_temporary_exemption_hours"` AttachVolume string `json:"attach_volume"` DetachVolume string `json:"detach_volume"` SubscriptionType string `json:"subscription_type"` NewName string `json:"new_name"` AddKey string `json:"add_key"` }
type HostsByClient ¶
type HostsByClient struct { Options ClientOptions `bson:"_id"` Hosts []Host `bson:"hosts"` }
HostsByClient represents an aggregation of hosts with common cloud provider client options.
func FindStartingHostsByClient ¶
func FindStartingHostsByClient(ctx context.Context, limit int) ([]HostsByClient, error)
FindStartingHostsByClient returns a list mapping cloud provider client options to hosts with those client options that are starting up. The limit limits the number of hosts that can be returned. The limit is applied separately for task hosts and spawn hosts/host.create hosts.
type HostsFilterOptions ¶
type HostsFilterOptions struct { HostID string DistroID string CurrentTaskID string Statuses []string StartedBy string SortBy string SortDir int Page int Limit int }
HostsFilterOptions represents the filtering arguments for fetching hosts.
type HostsInRangeParams ¶
type IdleHostsByDistroID ¶
type IdleHostsByDistroID struct { DistroID string `bson:"distro_id"` IdleHosts []Host `bson:"idle_hosts"` RunningHostsCount int `bson:"running_hosts_count"` }
func IdleEphemeralGroupedByDistroID ¶
func IdleEphemeralGroupedByDistroID(ctx context.Context, env evergreen.Environment) ([]IdleHostsByDistroID, error)
IdleEphemeralGroupedByDistroID groups and collates the following by distro.Id: - []host.Host of ephemeral hosts without containers which having no running task, ordered by {host.CreationTime: 1} - the total number of ephemeral hosts that are capable of running tasks
func (*IdleHostsByDistroID) MarshalBSON ¶
func (h *IdleHostsByDistroID) MarshalBSON() ([]byte, error)
func (*IdleHostsByDistroID) UnmarshalBSON ¶
func (h *IdleHostsByDistroID) UnmarshalBSON(in []byte) error
type InactiveHostCounts ¶
func CountInactiveHostsByProvider ¶
func CountInactiveHostsByProvider(ctx context.Context) ([]InactiveHostCounts, error)
type PortMap ¶
PortMap maps container port to the parent host ports (container port is formatted as <port>/<protocol>)
func GetPortMap ¶
type ProviderStats ¶
type ProviderStats []StatsByProvider
func GetProviderCounts ¶
func GetProviderCounts() (ProviderStats, error)
GetProviderCounts returns data on the number of hosts by different provider stats.
func (ProviderStats) Map ¶
func (p ProviderStats) Map() map[string]int
type ProvisionOptions ¶
type ProvisionOptions struct { // TaskId if non-empty will trigger the CLI tool to fetch source and // artifacts for the given task. TaskId string `bson:"task_id" json:"task_id"` // TaskSync, if set along with TaskId, will fetch the task's sync data on // the spawn host instead of fetching the source and artifacts. This is TaskSync bool `bson:"task_sync" json:"task_sync"` // Owner is the user associated with the host used to populate any necessary metadata. OwnerId string `bson:"owner_id" json:"owner_id"` // SetupScript runs after other host provisioning is done (i.e. loading task data/artifacts). SetupScript string `bson:"setup_script" json:"setup_script"` }
ProvisionOptions is struct containing options about how a new spawn host should be set up.
type ReprovisionType ¶
type ReprovisionType string
Reprovision represents a state change in how the host is provisioned.
const ( ReprovisionNone ReprovisionType = "" // ProvisionNew indicates a transition from legacy provisioning to // non-legacy provisioning. ReprovisionToNew ReprovisionType = "convert-to-new" // ReprovisionToLegacy indicates a transition from non-legacy // provisioning to legacy provisioning. ReprovisionToLegacy ReprovisionType = "convert-to-legacy" // ReprovisionRestartJasper indicates that the host's Jasper service should // restart. ReprovisionRestartJasper ReprovisionType = "restart-jasper" )
Constants representing host provisioning changes.
type SleepScheduleInfo ¶
type SleepScheduleInfo struct { // WholeWeekdaysOff represents whole weekdays for the host to sleep. WholeWeekdaysOff []time.Weekday `bson:"whole_weekdays_off,omitempty" json:"whole_weekdays_off,omitempty"` // DailyStartTime and DailyStopTime represent a daily schedule for when to // start a stopped host back up. The format is "HH:MM". DailyStartTime string `bson:"daily_start_time,omitempty" json:"daily_start_time,omitempty"` // DailyStopTime represents a daily schedule for when to stop a host. The // format is "HH:MM". DailyStopTime string `bson:"daily_stop_time,omitempty" json:"daily_stop_time,omitempty"` // TimeZone is the time zone for this host's sleep schedule. TimeZone string `bson:"time_zone" json:"time_zone"` // TemporarilyExemptUntil stores when a user's temporary exemption ends, if // any has been set. The sleep schedule will not take effect until // this timestamp passes. TemporarilyExemptUntil time.Time `bson:"temporarily_exempt_until,omitempty" json:"temporarily_exempt_until,omitempty"` // PermanentlyExempt determines if a host is permanently exempt from the // sleep schedule. If true, the sleep schedule will never take effect. PermanentlyExempt bool `bson:"permanently_exempt" json:"permanently_exempt"` // ShouldKeepOff indicates if the host should be kept off, regardless of the // other sleep schedule settings. This exists to permit a host to remain off // indefinitely until the host's owner is ready to turn it on and resume its // usual sleep schedule. Since this option allows the user to re-enable // their sleep schedule whenever they want, this is distinct from being // permanently exempt, which means the sleep schedule never takes effect. ShouldKeepOff bool `bson:"should_keep_off" json:"should_keep_off"` // NextStopTime is the next time that the host should stop for its sleep // schedule. NextStopTime time.Time `bson:"next_stop_time,omitempty" json:"next_stop_time,omitempty"` // NextStartTime is the next time that the host should start for its sleep // schedule. NextStartTime time.Time `bson:"next_start_time,omitempty" json:"next_start_time,omitempty"` }
SleepScheduleInfo stores information about a host's sleep schedule and related bookkeeping information.
func NewSleepScheduleInfo ¶
func NewSleepScheduleInfo(opts SleepScheduleOptions) (*SleepScheduleInfo, error)
NewSleepScheduleInfo creates a new sleep schedule for a host that does not already have one defined.
func (*SleepScheduleInfo) GetNextScheduledStartAndStopTimes ¶
func (s *SleepScheduleInfo) GetNextScheduledStartAndStopTimes(now time.Time) (nextStart, nextStop time.Time, err error)
GetNextScheduledStartAndStopTimes is a convenience function to return both the next time a host should be started and the next time a host should be stopped according to its sleep schedule.
func (*SleepScheduleInfo) GetNextScheduledStartTime ¶
GetNextScheduledStartTime returns the next time a host should be started according to its sleep schedule.
func (*SleepScheduleInfo) GetNextScheduledStopTime ¶
GetNextScheduledStopTime returns the next time a host should be stopped according to its sleep schedule.
func (*SleepScheduleInfo) IsExempt ¶
func (s *SleepScheduleInfo) IsExempt(now time.Time) bool
IsExempt returns whether or not the sleep schedule has an exemption.
func (SleepScheduleInfo) IsZero ¶
func (i SleepScheduleInfo) IsZero() bool
IsZero implements the bsoncodec.Zeroer interface for the sake of defining the zero value for BSON marshalling.
func (*SleepScheduleInfo) Validate ¶
func (i *SleepScheduleInfo) Validate() error
Validate checks that the sleep schedule provided by the user is valid, or the host is permanently exempt.
type SleepScheduleOptions ¶
type SleepScheduleOptions struct { // WholeWeekdaysOff are when the host is off for its sleep schedule. WholeWeekdaysOff []time.Weekday `bson:"whole_weekdays_off,omitempty" json:"whole_weekdays_off,omitempty"` // DailyStartTime is the daily time to start the host for each day the host is on // during its sleep schedule. The format is "HH:MM". DailyStartTime string `bson:"daily_start_time,omitempty" json:"daily_start_time,omitempty"` // DailyStopTime is the daily time to stop the host for each day the host is // on during its sleep schedule. The format is "HH:MM". DailyStopTime string `bson:"daily_stop_time,omitempty" json:"daily_stop_time,omitempty"` // TimeZone is the time zone in which the sleep schedule runs. TimeZone string `bson:"time_zone" json:"time_zone"` }
SleepScheduleOptions represent options that a user can set for creating a sleep schedule.
func (*SleepScheduleOptions) HasSchedule ¶
func (o *SleepScheduleOptions) HasSchedule() bool
HasSchedule returns whether a sleep schedule has been defined (with or without an explicit time zone).
func (*SleepScheduleOptions) IsZero ¶
func (o *SleepScheduleOptions) IsZero() bool
func (*SleepScheduleOptions) SetDefaultSchedule ¶
func (o *SleepScheduleOptions) SetDefaultSchedule()
SetDefaultSchedule sets a default sleep schedule if none is provided. This does not specify a default time zone, which must be set using SetDefaultTimeZone.
func (*SleepScheduleOptions) SetDefaultTimeZone ¶
func (o *SleepScheduleOptions) SetDefaultTimeZone(timezone string)
SetDefaultTimeZone sets a default time zone if other sleep schedule options are specified and the time zone is not explicitly set. If prefers the given default timezone if it's not empty, but otherwise falls back to using a default time zone.
func (*SleepScheduleOptions) Validate ¶
func (o *SleepScheduleOptions) Validate() error
Validate checks that the sleep schedule provided by the user is valid.
type SpawnHostUsage ¶
type SpawnHostUsage struct { TotalHosts int `bson:"total_hosts"` TotalStoppedHosts int `bson:"total_stopped_hosts"` TotalUnexpirableHosts int `bson:"total_unexpirable_hosts"` NumUsersWithHosts int `bson:"num_users_with_hosts"` TotalVolumes int `bson:"total_volumes"` TotalVolumeSize int `bson:"total_volume_size"` NumUsersWithVolumes int `bson:"num_users_with_volumes"` InstanceTypes map[string]int `bson:"instance_types"` }
func AggregateSpawnhostData ¶
func AggregateSpawnhostData(ctx context.Context) (*SpawnHostUsage, error)
AggregateSpawnhostData returns basic metrics on spawn host/volume usage.
type SpawnOptions ¶
type SpawnOptions struct { // TimeoutTeardown is the time that this host should be torn down. In most cases, a host // should be torn down due to its task or build. TimeoutTeardown is a backstop to ensure that Evergreen // tears down a host if a task hangs or otherwise does not finish within an expected period of time. TimeoutTeardown time.Time `bson:"timeout_teardown,omitempty" json:"timeout_teardown,omitempty"` // TimeoutTeardown is the time after which Evergreen should give up trying to set up this host. TimeoutSetup time.Time `bson:"timeout_setup,omitempty" json:"timeout_setup,omitempty"` // TaskID is the task_id of the task to which this host is pinned. When the task finishes, // this host should be torn down. Only one of TaskID or BuildID should be set. TaskID string `bson:"task_id,omitempty" json:"task_id,omitempty"` // TaskExecutionNumber is the execution number of the task that spawned this host. This // field is deliberately NOT omitempty in order to support the aggregation in // allHostsSpawnedByFinishedTasks(). TaskExecutionNumber int `bson:"task_execution_number" json:"task_execution_number"` // BuildID is the build_id of the build to which this host is pinned. When the build finishes, // this host should be torn down. Only one of TaskID or BuildID should be set. BuildID string `bson:"build_id,omitempty" json:"build_id,omitempty"` // Retries is the number of times Evergreen should try to spawn this host. Retries int `bson:"retries,omitempty" json:"retries,omitempty"` // Respawns is the number of spawn attempts remaining if the host is externally terminated after // being spawned. Respawns int `bson:"respawns,omitempty" json:"respawns,omitempty"` // SpawnedByTask indicates that this host has been spawned by a task. SpawnedByTask bool `bson:"spawned_by_task,omitempty" json:"spawned_by_task,omitempty"` }
SpawnOptions holds data which the monitor uses to determine when to terminate hosts spawned by tasks.
type StatsByDistro ¶
type StatsByDistro struct { // ID of the distro the below stats are for Distro string `bson:"distro" json:"distro,omitempty"` // Provider is the provider type of the distro Provider string `bson:"provider" json:"provider,omitempty"` // Host status that the below stats are for Status string `bson:"status" json:"status"` // Number of hosts in this status Count int `bson:"count" json:"count"` // Number of tasks running on hosts in the above group (should only be nonzero for running hosts) NumTasks int `bson:"num_tasks_running" json:"num_tasks_running"` // MaxHosts reports the pool size of the distro. MaxHosts int `bson:"max_hosts" json:"max_hosts"` }
func (*StatsByDistro) MarshalBSON ¶
func (d *StatsByDistro) MarshalBSON() ([]byte, error)
func (*StatsByDistro) UnmarshalBSON ¶
func (d *StatsByDistro) UnmarshalBSON(in []byte) error
type StatsByProvider ¶
type Tag ¶
type Tag struct { Key string `bson:"key" json:"key"` Value string `bson:"value" json:"value"` CanBeModified bool `bson:"can_be_modified" json:"can_be_modified"` }
func MakeHostTags ¶
MakeHostTags creates and validates a map of supplied instance tags.
type VirtualWorkstationCounter ¶
type VirtualWorkstationCounter struct { InstanceType string `bson:"instance_type" json:"instance_type"` Count int `bson:"count" json:"count"` }
func CountVirtualWorkstationsByInstanceType ¶
func CountVirtualWorkstationsByInstanceType(ctx context.Context) ([]VirtualWorkstationCounter, error)
type Volume ¶
type Volume struct { ID string `bson:"_id" json:"id"` DisplayName string `bson:"display_name" json:"display_name"` CreatedBy string `bson:"created_by" json:"created_by"` Type string `bson:"type" json:"type"` Size int32 `bson:"size" json:"size"` Throughput int32 `bson:"throughput,omitempty" json:"throughput,omitempty"` IOPS int32 `bson:"iops,omitempty" json:"iops,omitempty"` AvailabilityZone string `bson:"availability_zone" json:"availability_zone"` Expiration time.Time `bson:"expiration" json:"expiration"` NoExpiration bool `bson:"no_expiration" json:"no_expiration"` CreationDate time.Time `bson:"created_at" json:"created_at"` Host string `bson:"host,omitempty" json:"host"` HomeVolume bool `bson:"home_volume" json:"home_volume"` Migrating bool `bson:"migrating" json:"migrating"` }
func FindOneVolume ¶
FindOne gets one Volume for the given query.
func FindSortedVolumesByUser ¶
func FindVolumeByID ¶
FindVolumeByID finds a volume by its ID field.
func FindVolumesByUser ¶
func FindVolumesWithTerminatedHost ¶
FindVolumesWithTerminatedHost finds volumes that are attached to a host we have marked as terminated, indicating the volume is stuck in an invalid state.
func (*Volume) Remove ¶
Remove a volume from the volumes collection. Note this shouldn't be used when you want to remove from AWS itself.