Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/runtime-contracts.md
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,12 @@ a controlled reboot after the apply so cloud-init reruns filesystem preparation
and `resize2fs`, then verify the mounted ext4 capacity. Never reduce the input
after the disk exists.

The reviewed `n2d-standard-2` profile is available for workloads that need a
non-E2 capacity pool. N2D deployments must select `pd-standard` or `pd-ssd`;
the module rejects `hyperdisk-balanced` because N2D supports Persistent Disk
and Hyperdisk Throughput, not Hyperdisk Balanced. See Google's
[N2D disk compatibility](https://cloud.google.com/compute/docs/general-purpose-machines#n2d_series).

Every Compose `project_dir` must be a normalized descendant of the fixed
`/mnt/disks/data` ownership boundary. Terraform rejects paths such as `/`,
`/etc`, repeated separators, and dot-segment traversal during planning. The
Expand Down
4 changes: 2 additions & 2 deletions modules/gcp/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -986,11 +986,11 @@ resource "google_compute_instance" "cloud-compose" {
}
precondition {
condition = (
startswith(var.machine_type, "e2") ?
startswith(var.machine_type, "e2") || startswith(var.machine_type, "n2d") ?
contains(["pd-ssd", "pd-standard"], var.disk_type) :
true
)
error_message = "When using an 'e2' machine type, 'disk_type' must be 'pd-ssd' or 'pd-standard'."
error_message = "E2 and N2D machine types require disk_type pd-ssd or pd-standard."
}
precondition {
condition = !var.rollout_enabled || trimspace(var.rollout_release_url) != ""
Expand Down
36 changes: 36 additions & 0 deletions modules/gcp/runtime_contracts.tftest.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,42 @@ run "sizes_application_data_independently" {
}
}

run "accepts_n2d_with_standard_persistent_disk" {
command = plan

variables {
name = "gcp-contract"
project_id = "test-project"
docker_compose_repo = "https://github.com/libops/wp.git"
machine_type = "n2d-standard-2"
disk_type = "pd-standard"
}

assert {
condition = (
google_compute_instance.cloud-compose.machine_type == "n2d-standard-2" &&
google_compute_disk.boot.type == "pd-standard" &&
google_compute_disk.data.type == "pd-standard" &&
google_compute_disk.docker-volumes.type == "pd-standard"
)
error_message = "The GCP module must apply the reviewed N2D and Persistent Disk profile to the VM and all disks."
}
}

run "rejects_n2d_with_hyperdisk_balanced" {
command = plan

variables {
name = "gcp-contract"
project_id = "test-project"
docker_compose_repo = "https://github.com/libops/wp.git"
machine_type = "n2d-standard-2"
disk_type = "hyperdisk-balanced"
}

expect_failures = [google_compute_instance.cloud-compose]
}

run "rejects_fractional_application_data_size" {
command = plan

Expand Down
5 changes: 3 additions & 2 deletions modules/gcp/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,14 @@ variable "disk_type" {
variable "machine_type" {
type = string
default = "n4-standard-2"
description = "VM machine type (General-purpose series that support Hyperdisk Balanced"
description = "Reviewed general-purpose VM machine type."

validation {
condition = contains([
"e2-micro",
"e2-small",
"e2-medium",
"n2d-standard-2",
"n4-standard-2",
"n4-standard-4",
"n4-standard-8",
Expand All @@ -137,7 +138,7 @@ variable "machine_type" {
"c4-standard-48",
"c4-standard-96",
], var.machine_type)
error_message = "The 'machine_type' must be from a General-Purpose family that supports Hyperdisk Balanced (C4, or N4 series)"
error_message = "machine_type must be an explicitly reviewed general-purpose profile."
}
}

Expand Down
26 changes: 26 additions & 0 deletions providers/gcp/template_versions.tftest.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,32 @@ run "gcp_entrypoint_forwards_application_data_size" {
}
}

run "gcp_entrypoint_accepts_n2d_with_standard_persistent_disk" {
command = plan

variables {
name = "template-versions"
template = "wp"
gcp = {
project_id = "test-project"
instance = {
machine_type = "n2d-standard-2"
}
disks = {
type = "pd-standard"
}
}
}

assert {
condition = (
local.gcp_instance.machine_type == "n2d-standard-2" &&
local.gcp_disks.type == "pd-standard"
)
error_message = "The GCP provider entrypoint must accept the reviewed N2D and Persistent Disk profile."
}
}

run "accepts_direct_cloud_run_proxy_depth" {
command = plan

Expand Down
1 change: 1 addition & 0 deletions providers/gcp/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ variable "gcp" {
"e2-micro",
"e2-small",
"e2-medium",
"n2d-standard-2",
"n4-standard-2",
"n4-standard-4",
"n4-standard-8",
Expand Down
27 changes: 27 additions & 0 deletions runtime_contracts.tftest.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,33 @@ run "public_entrypoint_forwards_application_data_size" {
}
}

run "public_entrypoint_accepts_n2d_with_standard_persistent_disk" {
command = plan

variables {
name = "root-contract"
cloud_provider = "gcp"
template = "wp"
gcp = {
project_id = "test-project"
instance = {
machine_type = "n2d-standard-2"
}
disks = {
type = "pd-standard"
}
}
}

assert {
condition = (
local.gcp_instance.machine_type == "n2d-standard-2" &&
local.gcp_disks.type == "pd-standard"
)
error_message = "The compatibility GCP entrypoint must accept the reviewed N2D and Persistent Disk profile."
}
}

run "public_entrypoint_rejects_reserved_extra_environment" {
command = plan

Expand Down
2 changes: 1 addition & 1 deletion tests/smoke/gcp/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ variable "gcp_zone" {

variable "gcp_machine_type" {
type = string
default = "e2-medium"
default = "n2d-standard-2"
description = "Google Compute Engine machine type."
}

Expand Down
1 change: 1 addition & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ variable "gcp" {
"e2-micro",
"e2-small",
"e2-medium",
"n2d-standard-2",
"n4-standard-2",
"n4-standard-4",
"n4-standard-8",
Expand Down
Loading