Skip to content

Commit 131b801

Browse files
committed
Merge branch 'uffd-extract' into use-uffd-wp-to-only-save-dirty-pages-written-to-eng-3093
2 parents f0247a0 + 43f7daa commit 131b801

File tree

231 files changed

+2545
-1396
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

231 files changed

+2545
-1396
lines changed

.golangci.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ linters:
2727
- errchkjson
2828
- exhaustive
2929
- exhaustruct
30-
- forbidigo # enable this when we're committed to avoiding os.Getenv
3130
- funcorder
3231
- funlen
3332
- gochecknoglobals
@@ -70,11 +69,12 @@ linters:
7069
# disabled intentionally
7170

7271
settings:
73-
# enable this when we're committed to avoiding os.Getenv
74-
# forbidigo:
75-
# forbid:
76-
# - pattern: os\.Getenv
77-
# msg: Add your field to the configuration model instead.
72+
forbidigo:
73+
forbid:
74+
- pattern: "^new$"
75+
msg: "Use &Type{} instead."
76+
# - pattern: os\.Getenv
77+
# msg: "Add your field to the configuration model instead."
7878

7979
gocritic:
8080
disabled-checks:
@@ -101,25 +101,21 @@ linters:
101101
- { disabled: true, name: function-length }
102102
- { disabled: true, name: function-result-limit }
103103
- { disabled: true, name: get-return }
104-
- { disabled: true, name: if-return }
105104
- { disabled: true, name: import-alias-naming }
106105
- { disabled: true, name: import-shadowing }
107106
- { disabled: true, name: line-length-limit }
108107
- { disabled: true, name: max-control-nesting }
109108
- { disabled: true, name: max-public-structs }
110109
- { disabled: true, name: nested-structs }
111110
- { disabled: true, name: package-comments }
112-
- { disabled: true, name: redefines-builtin-id }
113111
- { disabled: true, name: unchecked-type-assertion }
114112
- { disabled: true, name: unexported-naming }
115113
- { disabled: true, name: unexported-return }
116114
- { disabled: true, name: unhandled-error } # todo: enable this
117115
- { disabled: true, name: unnecessary-format } # todo: enable this
118116
- { disabled: true, name: unnecessary-stmt } # todo: enable this
119-
- { disabled: true, name: unused-parameter } # todo: enable this
120117
- { disabled: true, name: unused-receiver }
121118
- { disabled: true, name: use-errors-new } # todo: enable this
122-
- { disabled: true, name: useless-break } # todo: enable this
123119
- { disabled: true, name: var-declaration }
124120
- { disabled: true, name: var-naming }
125121

@@ -136,3 +132,7 @@ linters:
136132

137133
run:
138134
go: 1.24.7
135+
136+
issues:
137+
max-issues-per-linter: 50
138+
max-same-issues: 50

DEV-LOCAL.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Develop the application locally
2+
3+
1. `sudo modprobe nbd nbds_max=64`
4+
2. `make local-infra`: runs clickhouse, grafana, loki, memcached, mimir, otel, postgres, redis, tempo
5+
3. `cd packages/db && make migrate-local` initialize the database
6+
4. `cd packages/local-dev && go run seed-local-database.go` generate user, team, and token for local development
7+
5. `cd packages/api && make run-local` run the api locally
8+
6. `cd packages/orchestrator && make build-debug && sudo make run-local` run the orchestrator and template-manager locally.
9+
7. `cd packages/client-proxy && make run-local` run the client-proxy locally.
10+
11+
# Services
12+
- grafana: http://localhost:53000)
13+
- postgres: postgres:postgres@127.0.0.1:5432
14+
- clickhouse: clickhouse:clickhouse@127.0.0.1:9000

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,3 +162,7 @@ generate-mocks:
162162
.PHONY: tidy
163163
tidy:
164164
scripts/golang-dependencies-integrity.sh
165+
166+
.PHONY: local-infra
167+
local-infra:
168+
docker compose --file ./packages/local-dev/docker-compose.yaml up --abort-on-container-failure

go.work

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use (
77
./packages/db
88
./packages/docker-reverse-proxy
99
./packages/envd
10+
./packages/local-dev
1011
./packages/orchestrator
1112
./packages/shared
1213

iac/provider-gcp/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ tf_vars := TF_VAR_environment=$(TERRAFORM_ENVIRONMENT) \
2020
$(call tfvar, CLIENT_CLUSTER_CACHE_DISK_SIZE_GB) \
2121
$(call tfvar, API_MACHINE_TYPE) \
2222
$(call tfvar, API_CLUSTER_SIZE) \
23+
$(call tfvar, API_USE_NAT) \
24+
$(call tfvar, API_NAT_IPS) \
2325
$(call tfvar, BUILD_MACHINE_TYPE) \
2426
$(call tfvar, BUILD_CLUSTER_SIZE) \
2527
$(call tfvar, BUILD_CLUSTER_ROOT_DISK_SIZE_GB) \

iac/provider-gcp/main.tf

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ module "cluster" {
105105
loki_node_pool = var.loki_node_pool
106106
orchestrator_node_pool = var.orchestrator_node_pool
107107

108-
logs_health_proxy_port = var.logs_health_proxy_port
109-
logs_proxy_port = var.logs_proxy_port
108+
api_use_nat = var.api_use_nat
109+
api_nat_ips = var.api_nat_ips
110110

111111
edge_api_port = var.edge_api_port
112112
edge_proxy_port = var.edge_proxy_port
@@ -203,10 +203,6 @@ module "nomad" {
203203

204204
domain_name = var.domain_name
205205

206-
# Telemetry
207-
logs_health_proxy_port = var.logs_health_proxy_port
208-
logs_proxy_port = var.logs_proxy_port
209-
210206
# Logs
211207
loki_node_pool = var.loki_node_pool
212208
loki_machine_count = var.loki_cluster_size

iac/provider-gcp/nomad-cluster/main.tf

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ module "network" {
9191
cloudflare_api_token_secret_name = var.cloudflare_api_token_secret_name
9292

9393
gcp_project_id = var.gcp_project_id
94+
gcp_region = var.gcp_region
95+
96+
api_use_nat = var.api_use_nat
97+
api_nat_ips = var.api_nat_ips
9498

9599
api_port = var.api_port
96100
docker_reverse_proxy_port = var.docker_reverse_proxy_port
@@ -106,9 +110,7 @@ module "network" {
106110
build_instance_group = google_compute_instance_group_manager.build_pool.instance_group
107111
server_instance_group = google_compute_instance_group_manager.server_pool.instance_group
108112

109-
nomad_port = var.nomad_port
110-
logs_proxy_port = var.logs_proxy_port
111-
logs_health_proxy_port = var.logs_health_proxy_port
113+
nomad_port = var.nomad_port
112114

113115
cluster_tag_name = var.cluster_tag_name
114116

iac/provider-gcp/nomad-cluster/network/main.tf

Lines changed: 34 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,6 @@ locals {
100100
health_checked_backends = { for backend_index, backend_value in local.backends : backend_index => backend_value }
101101
}
102102

103-
# ======== IP ADDRESSES ====================
104-
105-
// todo: (2025-09-22): this can be removed when all orchestrator will be rolled with internal logs collector server
106-
resource "google_compute_global_address" "orch_logs_ip" {
107-
name = "${var.prefix}logs-ip"
108-
}
109-
110-
111103
# ======== CLOUDFLARE ====================
112104

113105
data "cloudflare_zone" "domain" {
@@ -441,73 +433,6 @@ resource "google_compute_security_policy" "default" {
441433
}
442434
}
443435

444-
module "gce_lb_http_logs" {
445-
source = "GoogleCloudPlatform/lb-http/google"
446-
version = "~> 12.1"
447-
name = "${var.prefix}external-logs-endpoint"
448-
project = var.gcp_project_id
449-
address = google_compute_global_address.orch_logs_ip.address
450-
create_address = false
451-
target_tags = [var.cluster_tag_name]
452-
firewall_networks = [var.network_name]
453-
454-
labels = var.labels
455-
backends = {
456-
default = {
457-
description = null
458-
protocol = "HTTP"
459-
port = var.logs_proxy_port.port
460-
port_name = var.logs_proxy_port.name
461-
timeout_sec = 20
462-
connection_draining_timeout_sec = 1
463-
enable_cdn = false
464-
session_affinity = null
465-
affinity_cookie_ttl_sec = null
466-
custom_request_headers = null
467-
custom_response_headers = null
468-
security_policy = google_compute_security_policy.disable-bots-log-collector.self_link
469-
470-
health_check = {
471-
check_interval_sec = null
472-
timeout_sec = null
473-
healthy_threshold = null
474-
unhealthy_threshold = null
475-
request_path = var.logs_health_proxy_port.health_path
476-
port = var.logs_health_proxy_port.port
477-
host = null
478-
logging = null
479-
}
480-
481-
log_config = {
482-
enable = false
483-
sample_rate = 0.0
484-
}
485-
486-
groups = [
487-
{
488-
group = var.client_instance_group
489-
balancing_mode = null
490-
capacity_scaler = null
491-
description = null
492-
max_connections = null
493-
max_connections_per_instance = null
494-
max_connections_per_endpoint = null
495-
max_rate = null
496-
max_rate_per_instance = null
497-
max_rate_per_endpoint = null
498-
max_utilization = null
499-
},
500-
]
501-
502-
iap_config = {
503-
enable = false
504-
oauth2_client_id = ""
505-
oauth2_client_secret = ""
506-
}
507-
}
508-
}
509-
}
510-
511436
# Firewalls
512437
resource "google_compute_firewall" "default-hc" {
513438
name = "${var.prefix}load-balancer-hc"
@@ -558,26 +483,6 @@ resource "google_compute_firewall" "client_proxy_firewall_ingress" {
558483
source_ranges = ["130.211.0.0/22", "35.191.0.0/16"]
559484
}
560485

561-
resource "google_compute_firewall" "logs_collector_firewall_ingress" {
562-
name = "${var.prefix}${var.cluster_tag_name}-logs-collector-firewall-ingress"
563-
network = var.network_name
564-
565-
allow {
566-
protocol = "tcp"
567-
# Health end point is already added by load balancer module automatically, but also adding it here just to make sure we don't remove it by accident
568-
ports = [var.logs_proxy_port.port, var.logs_health_proxy_port.port]
569-
}
570-
571-
priority = 999
572-
573-
direction = "INGRESS"
574-
target_tags = [var.cluster_tag_name]
575-
# Load balancer health check IP ranges
576-
# https://cloud.google.com/load-balancing/docs/health-check-concepts
577-
source_ranges = ["130.211.0.0/22", "35.191.0.0/16"]
578-
}
579-
580-
581486
resource "google_compute_firewall" "internal_remote_connection_firewall_ingress" {
582487
name = "${var.prefix}${var.cluster_tag_name}-internal-remote-connection-firewall-ingress"
583488
network = var.network_name
@@ -792,3 +697,37 @@ resource "google_compute_security_policy" "disable-bots-log-collector" {
792697
}
793698
}
794699
}
700+
701+
# Cloud Router for NAT
702+
resource "google_compute_router" "nat_router" {
703+
count = var.api_use_nat ? 1 : 0
704+
name = "${var.prefix}nat-router"
705+
network = var.network_name
706+
region = var.gcp_region
707+
}
708+
709+
# Static IP addresses for NAT (only created if explicit IPs not provided)
710+
resource "google_compute_address" "nat_ips" {
711+
count = var.api_use_nat && length(var.api_nat_ips) == 0 ? 2 : 0
712+
name = "${var.prefix}nat-ip-${count.index + 1}"
713+
region = var.gcp_region
714+
}
715+
716+
# Cloud NAT for API nodes
717+
resource "google_compute_router_nat" "api_nat" {
718+
count = var.api_use_nat ? 1 : 0
719+
name = "${var.prefix}api-nat"
720+
router = google_compute_router.nat_router[0].name
721+
nat_ip_allocate_option = "MANUAL_ONLY"
722+
nat_ips = length(var.api_nat_ips) > 0 ? var.api_nat_ips : google_compute_address.nat_ips[*].self_link
723+
source_subnetwork_ip_ranges_to_nat = "ALL_SUBNETWORKS_ALL_IP_RANGES"
724+
725+
log_config {
726+
enable = true
727+
filter = "ERRORS_ONLY"
728+
}
729+
730+
lifecycle {
731+
create_before_destroy = true
732+
}
733+
}

iac/provider-gcp/nomad-cluster/network/outputs.tf

Lines changed: 0 additions & 3 deletions
This file was deleted.

iac/provider-gcp/nomad-cluster/network/variables.tf

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,17 @@ variable "gcp_project_id" {
2727
type = string
2828
}
2929

30+
variable "gcp_region" {
31+
type = string
32+
}
33+
34+
variable "api_use_nat" {
35+
type = bool
36+
}
37+
38+
variable "api_nat_ips" {
39+
type = list(string)
40+
}
3041

3142
variable "cloudflare_api_token_secret_name" {
3243
type = string
@@ -63,21 +74,6 @@ variable "client_proxy_port" {
6374
})
6475
}
6576

66-
variable "logs_proxy_port" {
67-
type = object({
68-
name = string
69-
port = number
70-
})
71-
}
72-
73-
variable "logs_health_proxy_port" {
74-
type = object({
75-
name = string
76-
port = number
77-
health_path = string
78-
})
79-
}
80-
8177
variable "nomad_port" {
8278
type = number
8379
}

0 commit comments

Comments
 (0)