Skip to content

Commit 909c2ec

Browse files
[CI] Add Terraform Plumbing for Postcommit CI
This patch does all the Terraform plumbing necessary for setting up the postcommit buildbots. This leaves out the actual deployments for a future patch. Reviewers: Keenuts, lnihlen, gburgessiv, cmtice, dschuff Reviewed By: cmtice Pull Request: #542
1 parent 9243d53 commit 909c2ec

File tree

4 files changed

+176
-0
lines changed

4 files changed

+176
-0
lines changed

premerge/gke_cluster/main.tf

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,40 @@ resource "google_container_node_pool" "llvm_premerge_linux" {
7878
}
7979
}
8080

81+
# Buildbot here refers specifically to the LLVM Buildbot postcommit
82+
# testing infrastructure. These machines are used specifically for testing
83+
# commits after they have landed in main.
84+
resource "google_container_node_pool" "llvm_buildbot_linux" {
85+
name = "llvm-buildbot-linux"
86+
location = var.region
87+
cluster = google_container_cluster.llvm_premerge.name
88+
initial_node_count = 0
89+
90+
autoscaling {
91+
total_min_node_count = 0
92+
total_max_node_count = 3
93+
}
94+
95+
node_config {
96+
machine_type = var.linux_machine_type
97+
taint {
98+
key = "buildbot-platform"
99+
value = "linux"
100+
effect = "NO_SCHEDULE"
101+
}
102+
labels = {
103+
"buildbot-platform" : "linux"
104+
}
105+
disk_size_gb = 200
106+
107+
# Enable workload identity federation for this pool so that we can access
108+
# GCS buckets.
109+
workload_metadata_config {
110+
mode = "GKE_METADATA"
111+
}
112+
}
113+
}
114+
81115
resource "google_container_node_pool" "llvm_premerge_libcxx" {
82116
name = "llvm-premerge-libcxx"
83117
location = var.region
@@ -118,6 +152,56 @@ resource "google_container_node_pool" "llvm_premerge_windows_2022" {
118152
# a node.kubernetes.io/os taint for windows nodes.
119153
node_config {
120154
machine_type = var.windows_machine_type
155+
labels = {
156+
"buildbot-platform" : "windows-2022"
157+
}
158+
image_type = "WINDOWS_LTSC_CONTAINERD"
159+
windows_node_config {
160+
osversion = "OS_VERSION_LTSC2022"
161+
}
162+
# Add a script that runs on the initial boot to disable Windows Defender.
163+
# Windows Defender causes an increase in test times by approximately an
164+
# order of magnitude.
165+
metadata = {
166+
"sysprep-specialize-script-ps1" = "Set-MpPreference -DisableRealtimeMonitoring $true"
167+
# Terraform wants to recreate the node pool everytime whe running
168+
# terraform apply unless we explicitly set this.
169+
# TODO(boomanaiden154): Look into why terraform is doing this so we do
170+
# not need this hack.
171+
"disable-legacy-endpoints" = "true"
172+
}
173+
disk_size_gb = 200
174+
disk_type = "pd-ssd"
175+
176+
# Enable workload identity federation for this pool so that we can access
177+
# GCS buckets.
178+
workload_metadata_config {
179+
mode = "GKE_METADATA"
180+
}
181+
}
182+
}
183+
184+
# Buildbot here refers specifically to the LLVM Buildbot postcommit
185+
# testing infrastructure. These machines are used specifically for testing
186+
# commits after they have landed in main.
187+
resource "google_container_node_pool" "llvm_buildbot_window_2022" {
188+
name = "llvm-buildbot-windows-2022"
189+
location = var.region
190+
cluster = google_container_cluster.llvm_premerge.name
191+
initial_node_count = 0
192+
193+
autoscaling {
194+
total_min_node_count = 0
195+
total_max_node_count = 3
196+
}
197+
198+
# We do not set a taint for the windows nodes as kubernetes by default sets
199+
# a node.kubernetes.io/os taint for windows nodes.
200+
node_config {
201+
# Use the Linux machine type here as we want to keep the windows machines
202+
# symmetric with the Linux machines for faster builds. Throughput is not
203+
# as much of a concern postcommit.
204+
machine_type = var.linux_machine_type
121205
labels = {
122206
"premerge-platform" : "windows-2022"
123207
}

premerge/main.tf

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,25 @@ data "google_secret_manager_secret_version" "grafana_token" {
121121
secret = "llvm-premerge-testing-grafana-token"
122122
}
123123

124+
# Buildbot here refers specifically to the LLVM Buildbot postcommit
125+
# testing infrastructure. These machines are used specifically for testing
126+
# commits after they have landed in main.
127+
data "google_secret_manager_secret_version" "us_central_linux_buildbot_password" {
128+
secret = "llvm-buildbot-linux-us-central"
129+
}
130+
131+
data "google_secret_manager_secret_version" "us_central_windows_buildbot_password" {
132+
secret = "llvm-buildbot-windows-us-central"
133+
}
134+
135+
data "google_secret_manager_secret_version" "us_west_linux_buildbot_password" {
136+
secret = "llvm-buildbot-linux-us-west"
137+
}
138+
139+
data "google_secret_manager_secret_version" "us_west_windows_buildbot_password" {
140+
secret = "llvm-buildbot-windows-us-west"
141+
}
142+
124143
provider "kubernetes" {
125144
host = "https://${module.premerge_cluster_us_central.endpoint}"
126145
token = data.google_client_config.current.access_token
@@ -152,6 +171,10 @@ module "premerge_cluster_us_central_resources" {
152171
linux_object_cache_gcp_service_account_email = module.premerge_cluster_us_central.linux_object_cache_gcp_service_account_email
153172
windows_2022_object_cache_gcp_service_account_email = module.premerge_cluster_us_central.windows_2022_object_cache_gcp_service_account_email
154173
github_arc_version = "0.12.1"
174+
linux_buildbot_name = "premerge-us-central-linux"
175+
linux_buildbot_password = data.google_secret_manager_secret_version.us_central_linux_buildbot_password.secret_data
176+
windows_buildbot_name = "premerge-us-central-windows"
177+
windows_buildbot_password = data.google_secret_manager_secret_version.us_central_windows_buildbot_password.secret_data
155178
providers = {
156179
kubernetes = kubernetes.llvm-premerge-us-central
157180
helm = helm.llvm-premerge-us-central
@@ -173,6 +196,10 @@ module "premerge_cluster_us_west_resources" {
173196
linux_object_cache_gcp_service_account_email = module.premerge_cluster_us_west.linux_object_cache_gcp_service_account_email
174197
windows_2022_object_cache_gcp_service_account_email = module.premerge_cluster_us_west.windows_2022_object_cache_gcp_service_account_email
175198
github_arc_version = "0.12.1"
199+
linux_buildbot_name = "premerge-us-west-linux"
200+
linux_buildbot_password = data.google_secret_manager_secret_version.us_west_linux_buildbot_password.secret_data
201+
windows_buildbot_name = "premerge-us-west-windows"
202+
windows_buildbot_password = data.google_secret_manager_secret_version.us_west_windows_buildbot_password.secret_data
176203
providers = {
177204
kubernetes = kubernetes.llvm-premerge-us-west
178205
helm = helm.llvm-premerge-us-west

premerge/premerge_resources/main.tf

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,51 @@ resource "kubernetes_namespace" "llvm_premerge_windows_2022_runners" {
4747
}
4848
}
4949

50+
# Buildbot here refers specifically to the LLVM Buildbot postcommit
51+
# testing infrastructure. These machines are used specifically for testing
52+
# commits after they have landed in main.
53+
resource "kubernetes_namespace" "llvm_premerge_linux_buildbot" {
54+
metadata {
55+
name = "llvm-premerge-linux-buildbot"
56+
}
57+
}
58+
59+
resource "kubernetes_namespace" "llvm_premerge_windows_2022_buildbot" {
60+
metadata {
61+
name = "llvm-premerge-windows-2022-buildbot"
62+
}
63+
}
64+
65+
resource "kubernetes_secret" "linux_buildbot_password" {
66+
metadata {
67+
name = "linux-buildbot-password"
68+
namespace = "llvm-premerge-linux-buildbot"
69+
}
70+
71+
data = {
72+
"password" = var.linux_buildbot_password
73+
}
74+
75+
type = "Opaque"
76+
77+
depends_on = [kubernetes_namespace.llvm_premerge_linux_buildbot]
78+
}
79+
80+
resource "kubernetes_secret" "windows_2022_buildbot_password" {
81+
metadata {
82+
name = "windows-buildbot-password"
83+
namespace = "llvm-premerge-windows-buildbot"
84+
}
85+
86+
data = {
87+
"password" = var.windows_buildbot_password
88+
}
89+
90+
type = "Opaque"
91+
92+
depends_on = [kubernetes_namespace.llvm_premerge_windows_2022_buildbot]
93+
}
94+
5095
resource "kubernetes_secret" "linux_github_pat" {
5196
metadata {
5297
name = "github-token"

premerge/premerge_resources/variables.tf

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,3 +104,23 @@ variable "windows_2022_object_cache_gcp_service_account_email" {
104104
description = "The email associated with the service account for accessing the object cache on Windows."
105105
type = string
106106
}
107+
108+
variable "linux_buildbot_name" {
109+
description = "The name of the linux buildbot that will run tests postcommit."
110+
type = string
111+
}
112+
113+
variable "linux_buildbot_password" {
114+
description = "The password for the linux buildbot that will run tests postcommit."
115+
type = string
116+
}
117+
118+
variable "windows_buildbot_name" {
119+
description = "The name of the windows buildbot that will run tests postcommit."
120+
type = string
121+
}
122+
123+
variable "windows_buildbot_password" {
124+
description = "The password for the windows buildbot that will run tests postcommit."
125+
type = string
126+
}

0 commit comments

Comments
 (0)