-
Notifications
You must be signed in to change notification settings - Fork 126
/
globals.go
1520 lines (1319 loc) · 46.3 KB
/
globals.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
package evergreen
import (
"os"
"strings"
"time"
"github.com/evergreen-ci/utility"
"github.com/mongodb/grip"
"github.com/pkg/errors"
)
const (
// User is the generic user representing the Evergreen application as a
// whole entity. If there's a more specific user performing an operation,
// prefer to use that instead.
User = "mci"
GithubPatchUser = "github_pull_request"
GithubMergeUser = "github_merge_queue"
PeriodicBuildUser = "periodic_build_user"
ParentPatchUser = "parent_patch"
HostRunning = "running"
HostTerminated = "terminated"
HostUninitialized = "initializing"
// HostBuilding is an intermediate state indicating that the intent host is
// attempting to create a real host from an intent host, but has not
// successfully done so yet.
HostBuilding = "building"
// HostBuildingFailed is a failure state indicating that an intent host was
// attempting to create a host but failed during creation. Hosts that fail
// to build will terminate shortly.
HostBuildingFailed = "building-failed"
HostStarting = "starting"
HostProvisioning = "provisioning"
// HostProvisionFailed is a failure state indicating that a host was
// successfully created (i.e. requested from the cloud provider) but failed
// while it was starting up. Hosts that fail to provisoin will terminate
// shortly.
HostProvisionFailed = "provision failed"
HostQuarantined = "quarantined"
HostDecommissioned = "decommissioned"
HostStopping = "stopping"
HostStopped = "stopped"
HostExternalUserName = "external"
// Task statuses stored in the database (i.e. (Task).Status):
// TaskUndispatched indicates either:
// 1. a task is not scheduled to run (when Task.Activated == false)
// 2. a task is scheduled to run (when Task.Activated == true)
TaskUndispatched = "undispatched"
// TaskDispatched indicates that an agent has received the task, but
// the agent has not yet told Evergreen that it's running the task
TaskDispatched = "dispatched"
// TaskStarted indicates a task is running on an agent.
TaskStarted = "started"
// The task statuses below indicate that a task has finished.
// TaskSucceeded indicates that the task has finished and is successful.
TaskSucceeded = "success"
// TaskFailed indicates that the task has finished and failed. This
// encompasses any task failure, regardless of the specific failure reason
// which can be found in the task end details.
TaskFailed = "failed"
// Task statuses used for the UI or other special-case purposes:
// TaskUnscheduled indicates that the task is undispatched and is not
// scheduled to eventually run. This is a display status, so it's only used
// in the UI.
TaskUnscheduled = "unscheduled"
// TaskInactive is a deprecated legacy status that used to mean that the
// task was not scheduled to run. This is equivalent to the TaskUnscheduled
// display status. These are not stored in the task status (although they
// used to be for very old tasks) but may be still used in some outdated
// pieces of code.
TaskInactive = "inactive"
// TaskWillRun indicates that the task is scheduled to eventually run,
// unless one of its dependencies becomes unattainable. This is a display
// status, so it's only used in the UI.
TaskWillRun = "will-run"
// All other task failure reasons other than TaskFailed are display
// statuses, so they're only used in the UI. These are not stored in the
// task status (although they used to be for very old tasks).
TaskSystemFailed = "system-failed"
TaskTestTimedOut = "test-timed-out"
TaskSetupFailed = "setup-failed"
// TaskAborted indicates that the task was aborted while it was running.
TaskAborted = "aborted"
// TaskStatusBlocked indicates that the task cannot run because it is
// blocked by an unattainable dependency. This is a display status, so it's
// only used in the UI.
TaskStatusBlocked = "blocked"
// TaskKnownIssue indicates that the task has failed and is being tracked by
// a linked issue in the task annotations. This is a display status, so it's
// only used in the UI.
TaskKnownIssue = "known-issue"
// TaskStatusPending is a special state that's used for one specific return
// value. Generally do not use this status as it is neither a meaningful
// status in the UI nor in the back end.
TaskStatusPending = "pending"
// TaskAll is not a status, but rather a UI filter indicating that it should
// select all tasks regardless of their status.
TaskAll = "all"
// Task Command Types
CommandTypeTest = "test"
CommandTypeSystem = "system"
CommandTypeSetup = "setup"
// Task descriptions
//
// TaskDescriptionHeartbeat indicates that a task failed because it did not
// send a heartbeat while it was running. Tasks are expected to send
// periodic heartbeats back to the app server indicating the task is still
// actively running, or else they are considered stale.
TaskDescriptionHeartbeat = "heartbeat"
// TaskDescriptionStranded indicates that a task failed because its
// underlying runtime environment (i.e. container or host) encountered an
// issue. For example, if a host is terminated while the task is still
// running, the task is considered stranded.
TaskDescriptionStranded = "stranded"
// TaskDescriptionNoResults indicates that a task failed because it did not
// post any test results.
TaskDescriptionNoResults = "expected test results, but none attached"
// TaskDescriptionResultsFailed indicates that a task failed because the
// test results contained a failure.
TaskDescriptionResultsFailed = "test results contained failing test"
// TaskDescriptionContainerUnallocatable indicates that the reason a
// container task failed is because it cannot be allocated a container.
TaskDescriptionContainerUnallocatable = "container task cannot be allocated"
// TaskDescriptionAborted indicates that the reason a task failed is specifically
// because it was manually aborted.
TaskDescriptionAborted = "aborted"
// Task Statuses that are only used by the UI, event log and tests
// (these may be used in old tasks as actual task statuses rather than just
// task display statuses).
TaskSystemUnresponse = "system-unresponsive"
TaskSystemTimedOut = "system-timed-out"
TaskTimedOut = "task-timed-out"
TestFailedStatus = "fail"
TestSilentlyFailedStatus = "silentfail"
TestSkippedStatus = "skip"
TestSucceededStatus = "pass"
BuildStarted = "started"
BuildCreated = "created"
BuildFailed = "failed"
BuildSucceeded = "success"
VersionStarted = "started"
VersionCreated = "created"
VersionFailed = "failed"
VersionSucceeded = "success"
// VersionAborted is a display status only and not stored in the DB
VersionAborted = "aborted"
PushLogPushing = "pushing"
PushLogSuccess = "success"
HostTypeStatic = "static"
MergeTestStarted = "started"
MergeTestSucceeded = "succeeded"
MergeTestFailed = "failed"
EnqueueFailed = "failed to enqueue"
// MaxAutomaticRestarts is the maximum number of automatic restarts allowed for a task
MaxAutomaticRestarts = 1
// MaxTaskDispatchAttempts is the maximum number of times a task can be
// dispatched before it is considered to be in a bad state.
MaxTaskDispatchAttempts = 5
// maximum task priority
MaxTaskPriority = 100
DisabledTaskPriority = int64(-1)
// if a patch has NumTasksForLargePatch number of tasks or greater, we log to splunk for investigation
NumTasksForLargePatch = 10000
DefaultEvergreenConfig = ".evergreen.yml"
// Env vars
EvergreenHome = "EVGHOME"
MongodbURL = "MONGO_URL"
SharedMongoURL = "SHARED_MONGO_URL"
MongoAWSAuthEnabled = "MONGO_AWS_AUTH"
EvergreenVersionID = "EVG_VERSION_ID"
EvergreenClientS3Bucket = "EVG_CLIENT_S3_BUCKET"
TraceEndpoint = "TRACE_ENDPOINT"
// localLoggingOverride is a special log path indicating that the app server
// should attempt to log to systemd if available, and otherwise fall back to
// logging to stdout.
localLoggingOverride = "LOCAL"
// standardOutputLoggingOverride is a special log path indicating that the
// app server should log to stdout.
standardOutputLoggingOverride = "STDOUT"
// disableLocalLoggingEnvVar is an environment variable to disable all local application logging
// besides for fallback logging to stderr.
disableLocalLoggingEnvVar = "DISABLE_LOCAL_LOGGING"
// APIServerTaskActivator represents Evergreen's internal API activator
APIServerTaskActivator = "apiserver"
// StepbackTaskActivator represents the activator for tasks activated
// due to stepback.
StepbackTaskActivator = "stepback"
// CheckBlockedTasksActivator represents the activator for task deactivated
// by the check blocked tasks job.
CheckBlockedTasksActivator = "check-blocked-tasks-job-activator"
// BuildActivator represents the activator for builds that have been
// activated.
BuildActivator = "build-activator"
// ElapsedBuildActivator represents the activator for batch time builds
// that have their batchtimes elapsed.
ElapsedBuildActivator = "elapsed-build-activator"
// ElapsedTaskActivator represents the activator for batch time tasks
// that have their batchtimes elapsed.
ElapsedTaskActivator = "elapsed-task-activator"
// GenerateTasksActivator represents the activator for tasks that have been
// generated by a task generator.
GenerateTasksActivator = "generate-tasks-activator"
// AutoRestartActivator represents the activator for tasks that have been
// automatically restarted via the retry_on_failure command flag.
AutoRestartActivator = "automatic_restart"
// StaleContainerTaskMonitor is the special name representing the unit
// responsible for monitoring container tasks that have not dispatched but
// have waiting for a long time since their activation.
StaleContainerTaskMonitor = "stale-container-task-monitor"
// UnderwaterTaskUnscheduler is the caller associated with unscheduling
// and disabling tasks older than the task.UnschedulableThreshold from
// their distro queue.
UnderwaterTaskUnscheduler = "underwater-task-unscheduler"
// Restart Types
RestartVersions = "versions"
RestartTasks = "tasks"
RestRoutePrefix = "rest"
APIRoutePrefix = "api"
APIRoutePrefixV2 = "/rest/v2"
AgentMonitorTag = "agent-monitor"
HostFetchTag = "host-fetch"
DegradedLoggingPercent = 10
SetupScriptName = "setup.sh"
TempSetupScriptName = "setup-temp.sh"
PowerShellSetupScriptName = "setup.ps1"
PowerShellTempSetupScriptName = "setup-temp.ps1"
PlannerVersionLegacy = "legacy"
PlannerVersionTunable = "tunable"
DispatcherVersionRevisedWithDependencies = "revised-with-dependencies"
// maximum turnaround we want to maintain for all hosts for a given distro
MaxDurationPerDistroHost = 30 * time.Minute
MaxDurationPerDistroHostWithContainers = 2 * time.Minute
// Spawn hosts
SpawnHostExpireDays = 30
HostExpireDays = 10
ExpireOnFormat = "2006-01-02"
DefaultMaxSpawnHostsPerUser = 3
DefaultSpawnHostExpiration = 24 * time.Hour
SpawnHostRespawns = 2
SpawnHostNoExpirationDuration = 7 * 24 * time.Hour
MaxVolumeExpirationDurationHours = 24 * time.Hour * 14
UnattachedVolumeExpiration = 24 * time.Hour * 30
DefaultMaxVolumeSizePerUser = 500
DefaultUnexpirableHostsPerUser = 1
DefaultUnexpirableVolumesPerUser = 1
DefaultSleepScheduleTimeZone = "America/New_York"
// host resource tag names
TagName = "name"
TagDistro = "distro"
TagEvergreenService = "evergreen-service"
TagUsername = "username"
TagOwner = "owner"
TagMode = "mode"
TagStartTime = "start-time"
TagExpireOn = "expire-on"
FinderVersionLegacy = "legacy"
FinderVersionParallel = "parallel"
FinderVersionPipeline = "pipeline"
FinderVersionAlternate = "alternate"
HostAllocatorUtilization = "utilization"
HostAllocatorRoundDown = "round-down"
HostAllocatorRoundUp = "round-up"
HostAllocatorRoundDefault = ""
HostAllocatorWaitsOverThreshFeedback = "waits-over-thresh-feedback"
HostAllocatorNoFeedback = "no-feedback"
HostAllocatorUseDefaultFeedback = ""
HostsOverallocatedTerminate = "terminate-hosts-when-overallocated"
HostsOverallocatedIgnore = "no-terminations-when-overallocated"
HostsOverallocatedUseDefault = ""
// CommitQueueAlias and GithubPRAlias are special aliases to specify variants and tasks for commit queue and GitHub PR patches
CommitQueueAlias = "__commit_queue"
GithubPRAlias = "__github"
GithubChecksAlias = "__github_checks"
GitTagAlias = "__git_tag"
MergeTaskVariant = "commit-queue-merge"
MergeTaskName = "merge-patch"
MergeTaskGroup = "merge-task-group"
DefaultJasperPort = 2385
// TODO (DEVPROD-778): Remove GithubAppToken
GithubAppToken = "github_app_token"
GithubAppPrivateKey = "github_app_key"
GithubKnownHosts = "github_known_hosts"
GithubCheckRun = "github_check_run"
// GitHubRetryAttempts is the github client maximum number of attempts.
GitHubRetryAttempts = 3
// GitHubRetryMinDelay is the github client's minimum amount of delay before attempting another request.
GithubRetryMinDelay = time.Second
VSCodePort = 2021
// DefaultTaskSyncAtEndTimeout is the default timeout for task sync at the
// end of a patch.
DefaultTaskSyncAtEndTimeout = time.Hour
DefaultShutdownWaitSeconds = 10
// HeartbeatTimeoutThreshold is the timeout for how long a task can run without sending
// a heartbeat
HeartbeatTimeoutThreshold = 7 * time.Minute
// MaxTeardownGroupThreshold specifies the duration after which the host should no longer continue
// to tear down a task group. This is set one minute longer than the agent's maxTeardownGroupTimeout.
MaxTeardownGroupThreshold = 4 * time.Minute
SaveGenerateTasksError = "error saving config in `generate.tasks`"
TasksAlreadyGeneratedError = "generator already ran and generated tasks"
KeyTooLargeToIndexError = "key too large to index"
InvalidDivideInputError = "$divide only supports numeric types"
// ContainerHealthDashboard is the name of the Splunk dashboard that displays
// charts relating to the health of container tasks.
ContainerHealthDashboard = "container task health dashboard"
// PRTasksRunningDescription is the description for a GitHub PR status
// indicating that there are still running tasks.
PRTasksRunningDescription = "tasks are running"
// HostServicePasswordExpansion is the expansion for the service password that is stored on the host,
// and is meant to be set as a private variable so that it will be redacted in all logs.
HostServicePasswordExpansion = "host_service_password"
// RedactedValue is the value that is shown in the REST API and UI for redacted values.
RedactedValue = "{REDACTED}"
RedactedAfterValue = "{REDACTED_AFTER}"
RedactedBeforeValue = "{REDACTED_BEFORE}"
)
var TaskStatuses = []string{
TaskStarted,
TaskSucceeded,
TaskFailed,
TaskSystemFailed,
TaskTestTimedOut,
TaskSetupFailed,
TaskAborted,
TaskStatusBlocked,
TaskStatusPending,
TaskKnownIssue,
TaskSystemUnresponse,
TaskSystemTimedOut,
TaskTimedOut,
TaskWillRun,
TaskUnscheduled,
TaskUndispatched,
TaskDispatched,
}
// TaskSystemFailureStatuses contains only system failure statuses used by the UI and event logs.
var TaskSystemFailureStatuses = []string{
TaskSystemFailed,
TaskSystemUnresponse,
TaskSystemTimedOut,
}
var InternalAliases = []string{
CommitQueueAlias,
GithubPRAlias,
GithubChecksAlias,
GitTagAlias,
}
// TaskNonGenericFailureStatuses represents some kind of specific abnormal
// failure mode. These are display statuses used in the UI.
var TaskNonGenericFailureStatuses = []string{
TaskTimedOut,
TaskSystemFailed,
TaskTestTimedOut,
TaskSetupFailed,
TaskSystemUnresponse,
TaskSystemTimedOut,
}
// TaskFailureStatuses represent all the ways that a completed task can fail,
// inclusive of display statuses such as system failures.
var TaskFailureStatuses = append([]string{TaskFailed}, TaskNonGenericFailureStatuses...)
var TaskUnstartedStatuses = []string{
TaskInactive,
TaskUndispatched,
}
func IsUnstartedTaskStatus(status string) bool {
return utility.StringSliceContains(TaskUnstartedStatuses, status)
}
func IsFinishedTaskStatus(status string) bool {
if status == TaskSucceeded ||
IsFailedTaskStatus(status) {
return true
}
return false
}
func IsFailedTaskStatus(status string) bool {
return utility.StringSliceContains(TaskFailureStatuses, status)
}
func IsValidTaskEndStatus(status string) bool {
return status == TaskSucceeded || status == TaskFailed
}
func IsFinishedBuildStatus(status string) bool {
return status == BuildFailed || status == BuildSucceeded
}
// IsFinishedVersionStatus returns true if the version or patch is true.
func IsFinishedVersionStatus(status string) bool {
return status == VersionFailed || status == VersionSucceeded
}
type ModificationAction string
// ModifySpawnHostSource determines the originating source of a spawn host
// modification.
type ModifySpawnHostSource string
const (
// ModifySpawnHostManual means the spawn host is being modified manually
// because a user requested it.
ModifySpawnHostManual ModifySpawnHostSource = "manual"
// ModifySpawnHostManual means the spawn host is being modified by the
// automatic sleep schedule.
ModifySpawnHostSleepSchedule ModifySpawnHostSource = "sleep_schedule"
)
// Common OTEL constants and attribute keys
const (
PackageName = "github.com/evergreen-ci/evergreen"
OtelAttributeMaxLength = 10000
// task otel attributes
TaskIDOtelAttribute = "evergreen.task.id"
TaskNameOtelAttribute = "evergreen.task.name"
TaskExecutionOtelAttribute = "evergreen.task.execution"
TaskStatusOtelAttribute = "evergreen.task.status"
TaskFailureTypeOtelAttribute = "evergreen.task.failure_type"
TaskTagsOtelAttribute = "evergreen.task.tags"
// version otel attributes
VersionIDOtelAttribute = "evergreen.version.id"
VersionRequesterOtelAttribute = "evergreen.version.requester"
VersionStatusOtelAttribute = "evergreen.version.status"
VersionCreateTimeOtelAttribute = "evergreen.version.create_time"
VersionStartTimeOtelAttribute = "evergreen.version.start_time"
VersionFinishTimeOtelAttribute = "evergreen.version.finish_time"
VersionAuthorOtelAttribute = "evergreen.version.author"
VersionBranchOtelAttribute = "evergreen.version.branch"
VersionMakespanSecondsOtelAttribute = "evergreen.version.makespan_seconds"
VersionTimeTakenSecondsOtelAttribute = "evergreen.version.time_taken_seconds"
VersionPRNumOtelAttribute = "evergreen.version.pr_num"
VersionDescriptionOtelAttribute = "evergreen.version.description"
// build otel attributes
BuildIDOtelAttribute = "evergreen.build.id"
BuildNameOtelAttribute = "evergreen.build.name"
ProjectIdentifierOtelAttribute = "evergreen.project.identifier"
ProjectOrgOtelAttribute = "evergreen.project.org"
ProjectRepoOtelAttribute = "evergreen.project.repo"
ProjectIDOtelAttribute = "evergreen.project.id"
DistroIDOtelAttribute = "evergreen.distro.id"
HostIDOtelAttribute = "evergreen.host.id"
HostStartedByOtelAttribute = "evergreen.host.started_by"
HostNoExpirationOtelAttribute = "evergreen.host.no_expiration"
HostInstanceTypeOtelAttribute = "evergreen.host.instance_type"
AggregationNameOtelAttribute = "db.aggregationName"
)
const (
RestartAction ModificationAction = "restart"
SetActiveAction ModificationAction = "set_active"
SetPriorityAction ModificationAction = "set_priority"
AbortAction ModificationAction = "abort"
)
// Constants for Evergreen package names (including legacy ones).
const (
UIPackage = "EVERGREEN_UI"
RESTV2Package = "EVERGREEN_REST_V2"
MonitorPackage = "EVERGREEN_MONITOR"
)
var UserTriggeredOrigins = []string{
UIPackage,
RESTV2Package,
GithubCheckRun,
}
const (
AuthTokenCookie = "mci-token"
TaskHeader = "Task-Id"
TaskSecretHeader = "Task-Secret"
HostHeader = "Host-Id"
HostSecretHeader = "Host-Secret"
PodHeader = "Pod-Id"
PodSecretHeader = "Pod-Secret"
ContentTypeHeader = "Content-Type"
ContentTypeValue = "application/json"
ContentLengthHeader = "Content-Length"
APIUserHeader = "Api-User"
APIKeyHeader = "Api-Key"
)
const (
// CredentialsCollection is the collection containing TLS credentials to
// connect to a Jasper service running on a host.
CredentialsCollection = "credentials"
// CAName is the name of the root CA for the TLS credentials.
CAName = "evergreen"
)
// Constants related to cloud providers and provider-specific settings.
const (
ProviderNameEc2OnDemand = "ec2-ondemand"
ProviderNameEc2Fleet = "ec2-fleet"
ProviderNameDocker = "docker"
ProviderNameDockerMock = "docker-mock"
ProviderNameStatic = "static"
ProviderNameMock = "mock"
// DefaultEC2Region is the default region where hosts should be spawned and
// general Evergreen operations occur in AWS if no particular region is
// specified.
DefaultEC2Region = "us-east-1"
// DefaultEBSType is Amazon's default EBS type.
DefaultEBSType = "gp3"
// DefaultEBSAvailabilityZone is the default availability zone for EBS
// volumes. This may be a temporary default.
DefaultEBSAvailabilityZone = "us-east-1a"
)
// IsEc2Provider returns true if the provider is ec2.
func IsEc2Provider(provider string) bool {
return provider == ProviderNameEc2OnDemand ||
provider == ProviderNameEc2Fleet
}
// IsDockerProvider returns true if the provider is docker.
func IsDockerProvider(provider string) bool {
return provider == ProviderNameDocker ||
provider == ProviderNameDockerMock
}
// EC2Tenancy represents the physical hardware tenancy for EC2 hosts.
type EC2Tenancy string
const (
EC2TenancyDefault EC2Tenancy = "default"
EC2TenancyDedicated EC2Tenancy = "dedicated"
)
// ValidEC2Tenancies represents valid EC2 tenancy values.
var ValidEC2Tenancies = []EC2Tenancy{EC2TenancyDefault, EC2TenancyDedicated}
// IsValidEC2Tenancy returns if the given EC2 tenancy is valid.
func IsValidEC2Tenancy(tenancy EC2Tenancy) bool {
return len(utility.FilterSlice(ValidEC2Tenancies, func(t EC2Tenancy) bool { return t == tenancy })) > 0
}
var (
// ProviderSpawnable includes all cloud provider types where hosts can be
// dynamically created and terminated according to need. This has no
// relation to spawn hosts.
ProviderSpawnable = []string{
ProviderNameEc2OnDemand,
ProviderNameEc2Fleet,
ProviderNameMock,
ProviderNameDocker,
}
// ProviderUserSpawnable includes all cloud provider types where a user can
// request a dynamically created host for purposes such as host.create and
// spawn hosts.
ProviderUserSpawnable = []string{
ProviderNameEc2OnDemand,
ProviderNameEc2Fleet,
}
ProviderContainer = []string{
ProviderNameDocker,
}
)
const (
DefaultDatabaseURL = "mongodb://localhost:27017"
DefaultDatabaseName = "mci"
DefaultDatabaseWriteMode = "majority"
DefaultDatabaseReadMode = "majority"
DefaultAmboyDatabaseURL = "mongodb://localhost:27017"
// version requester types
PatchVersionRequester = "patch_request"
GithubPRRequester = "github_pull_request"
GitTagRequester = "git_tag_request"
RepotrackerVersionRequester = "gitter_request"
TriggerRequester = "trigger_request"
MergeTestRequester = "merge_test" // Evergreen commit queue
AdHocRequester = "ad_hoc" // periodic build
GithubMergeRequester = "github_merge_request" // GitHub merge queue
)
// Constants related to requester types.
var (
// SystemVersionRequesterTypes contain non-patch requesters that are created by the Evergreen system, i.e. configs and patch files are unchanged by author.
SystemVersionRequesterTypes = []string{
RepotrackerVersionRequester,
TriggerRequester,
GitTagRequester,
AdHocRequester,
}
AllRequesterTypes = []string{
PatchVersionRequester,
GithubPRRequester,
GitTagRequester,
RepotrackerVersionRequester,
TriggerRequester,
MergeTestRequester,
AdHocRequester,
GithubMergeRequester,
}
)
// UserRequester represents the allowed user-facing requester types.
type UserRequester string
// Validate checks that the user-facing requester type is valid.
func (r UserRequester) Validate() error {
if !utility.StringSliceContains(AllRequesterTypes, UserRequesterToInternalRequester(r)) {
return errors.Errorf("invalid user requester '%s'", r)
}
return nil
}
const (
// User-facing requester types. These are equivalent in meaning to the above
// requesters, but are more user-friendly. These should only be used for
// user-facing functionality such as YAML configuration and expansions and
// should be translated into the true internal requester types so they're
// actually usable.
PatchVersionUserRequester UserRequester = "patch"
GithubPRUserRequester UserRequester = "github_pr"
GitTagUserRequester UserRequester = "github_tag"
RepotrackerVersionUserRequester UserRequester = "commit"
TriggerUserRequester UserRequester = "trigger"
MergeTestUserRequester UserRequester = "commit_queue"
AdHocUserRequester UserRequester = "ad_hoc"
GithubMergeUserRequester UserRequester = "github_merge_queue"
)
var AllUserRequesterTypes = []UserRequester{
PatchVersionUserRequester,
GithubPRUserRequester,
GitTagUserRequester,
RepotrackerVersionUserRequester,
TriggerUserRequester,
MergeTestUserRequester,
AdHocUserRequester,
GithubMergeUserRequester,
}
// InternalRequesterToUserRequester translates an internal requester type to a
// user-facing requester type.
func InternalRequesterToUserRequester(requester string) UserRequester {
switch requester {
case PatchVersionRequester:
return PatchVersionUserRequester
case GithubPRRequester:
return GithubPRUserRequester
case GitTagRequester:
return GitTagUserRequester
case RepotrackerVersionRequester:
return RepotrackerVersionUserRequester
case TriggerRequester:
return TriggerUserRequester
case MergeTestRequester:
return MergeTestUserRequester
case AdHocRequester:
return AdHocUserRequester
case GithubMergeRequester:
return GithubMergeUserRequester
default:
return ""
}
}
// UserRequesterToInternalRequester translates a user-facing requester type to
// its equivalent internal requester type.
func UserRequesterToInternalRequester(requester UserRequester) string {
switch requester {
case PatchVersionUserRequester:
return PatchVersionRequester
case GithubPRUserRequester:
return GithubPRRequester
case GitTagUserRequester:
return GitTagRequester
case RepotrackerVersionUserRequester:
return RepotrackerVersionRequester
case TriggerUserRequester:
return TriggerRequester
case MergeTestUserRequester:
return MergeTestRequester
case AdHocUserRequester:
return AdHocRequester
case GithubMergeUserRequester:
return GithubMergeRequester
default:
return ""
}
}
// Constants for project command names.
const (
GenerateTasksCommandName = "generate.tasks"
HostCreateCommandName = "host.create"
S3PushCommandName = "s3.push"
S3PullCommandName = "s3.pull"
ShellExecCommandName = "shell.exec"
AttachResultsCommandName = "attach.results"
AttachArtifactsCommandName = "attach.artifacts"
AttachXUnitResultsCommandName = "attach.xunit_results"
)
var AttachCommands = []string{
AttachResultsCommandName,
AttachArtifactsCommandName,
AttachXUnitResultsCommandName,
}
type SenderKey int
const (
// SenderGithubStatus sends messages to GitHub like PR status updates. This
// sender key logically represents all GitHub senders collectively, of which
// there is one per GitHub org.
SenderGithubStatus = SenderKey(iota)
SenderEvergreenWebhook
SenderSlack
SenderJIRAIssue
SenderJIRAComment
SenderEmail
SenderGeneric
)
func (k SenderKey) Validate() error {
switch k {
case SenderGithubStatus, SenderEvergreenWebhook, SenderSlack, SenderJIRAComment, SenderJIRAIssue,
SenderEmail, SenderGeneric:
return nil
default:
return errors.New("invalid sender defined")
}
}
func (k SenderKey) String() string {
switch k {
case SenderGithubStatus:
return "github-status"
case SenderEmail:
return "email"
case SenderEvergreenWebhook:
return "webhook"
case SenderSlack:
return "slack"
case SenderJIRAComment:
return "jira-comment"
case SenderJIRAIssue:
return "jira-issue"
case SenderGeneric:
return "generic"
default:
return "<error:unknown>"
}
}
// DevProdJiraServiceField defines a required field for DEVPROD tickets, which we sometimes auto-generate.
// Using "Other" prevents this from getting out of sync with service naming too quickly.
var DevProdJiraServiceField = map[string]string{
"id": devProdServiceId,
"value": devProdServiceValue,
}
const (
DevProdServiceFieldName = "customfield_24158"
devProdServiceId = "27020"
devProdServiceValue = "Other"
)
// Recognized Evergreen agent CPU architectures, which should be in the form
// ${GOOS}_${GOARCH}.
const (
ArchDarwinAmd64 = "darwin_amd64"
ArchDarwinArm64 = "darwin_arm64"
ArchLinuxPpc64le = "linux_ppc64le"
ArchLinuxS390x = "linux_s390x"
ArchLinuxArm64 = "linux_arm64"
ArchLinuxAmd64 = "linux_amd64"
ArchWindowsAmd64 = "windows_amd64"
)
// NameTimeFormat is the format in which to log times like instance start time.
const NameTimeFormat = "20060102150405"
var (
PatchRequesters = []string{
PatchVersionRequester,
GithubPRRequester,
MergeTestRequester,
GithubMergeRequester,
}
SystemActivators = []string{
APIServerTaskActivator,
BuildActivator,
CheckBlockedTasksActivator,
ElapsedBuildActivator,
ElapsedTaskActivator,
GenerateTasksActivator,
}
// UpHostStatus is a list of all host statuses that are considered up.
UpHostStatus = []string{
HostRunning,
HostUninitialized,
HostBuilding,
HostStarting,
HostProvisioning,
HostProvisionFailed,
HostStopping,
HostStopped,
}
// StoppableHostStatuses represent all host statuses when it is possible to
// stop a running host.
StoppableHostStatuses = []string{
// If the host is already stopped, stopping it again is a no-op but not
// an error. It will remain stopped.
HostStopped,
// If the host is stopping but somehow gets stuck stopping (e.g. a
// timeout waiting for it to stop), this is an intermediate state, so it
// is valid to try stopping it again.
HostStopping,
// If the host is running, it can be stopped.
HostRunning,
}
// StoppableHostStatuses represent all host statuses when it is possible to
// start a stopped host.
StartableHostStatuses = []string{
// If the host is stopped, it can be started back up.
HostStopped,
// If the host is stopping but somehow gets stuck stopping (e.g. a
// timeout waiting for it to stop), this is an intermediate state, so it
// is valid to start it back up.
HostStopping,
// If the host is already running, starting it again is a no-op but not
// an error. It will remain running.
HostRunning,
}
StartedHostStatus = []string{
HostBuilding,
HostStarting,
}
// ProvisioningHostStatus describes hosts that have started,
// but have not yet completed the provisioning process.
ProvisioningHostStatus = []string{
HostStarting,
HostProvisioning,
HostProvisionFailed,
HostBuilding,
}
// DownHostStatus is a list of all host statuses that are considered down.
DownHostStatus = []string{
HostTerminated,
HostQuarantined,
HostDecommissioned,
}
// NotRunningStatus is a list of host statuses from before the host starts running.
NotRunningStatus = []string{
HostUninitialized,
HostBuilding,
HostProvisioning,
HostStarting,
}
// IsRunningOrWillRunStatuses includes all statuses for active hosts (see
// ActiveStatus) where the host is either currently running or is making
// progress towards running.
IsRunningOrWillRunStatuses = []string{
HostBuilding,
HostStarting,
HostProvisioning,
HostRunning,
}
// ActiveStatuses includes all where the host is alive in the cloud provider
// or could be alive (e.g. for building hosts, the host is in the process of
// starting up). Intent hosts have not requested a real host from the cloud
// provider, so they are omitted.
ActiveStatuses = []string{
HostBuilding,
HostBuildingFailed,
HostStarting,
HostProvisioning,
HostProvisionFailed,
HostRunning,
HostStopping,
HostStopped,
HostDecommissioned,
HostQuarantined,
}
// SleepScheduleStatuses are all host statuses for which the sleep schedule
// can take effect. If it's not in one of these states, the sleep schedule
// does not apply.
SleepScheduleStatuses = []string{
HostRunning,
HostStopped,
HostStopping,
}
// Set of host status values that can be user set via the API
ValidUserSetHostStatus = []string{
HostRunning,
HostTerminated,
HostQuarantined,
HostDecommissioned,
}
// Set of valid PlannerSettings.Version strings that can be user set via the API
ValidTaskPlannerVersions = []string{
PlannerVersionLegacy,
PlannerVersionTunable,
}