Skip to content

Commit 76ed672

Browse files
fix: GCP dynamic zone discovery; guaranteed CI cleanup on failure
GCP: replace hardcoded zone with dynamic discovery at plan time using data "google_compute_zones" so the cluster is never deployed into an exhausted or unavailable zone. CI workflows: add Taskfile defer to all four workflows so terraform destroy is guaranteed to run on exit regardless of which step fails, preventing resource accumulation on cancellation or mid-run failures. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 44452d1 commit 76ed672

3 files changed

Lines changed: 34 additions & 7 deletions

File tree

.tasks/ci.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ tasks:
1515
aws:rp:
1616
desc: CI workflow - AWS basic Redpanda
1717
cmds:
18+
- defer:
19+
task: :infra:aws:destroy
1820
- task: :tools:keygen
1921
- task: :infra:aws:build
2022
- task: :cluster:provision
@@ -30,6 +32,10 @@ tasks:
3032
ENABLE_CONNECT: "true"
3133
DISTRO: "43"
3234
cmds:
35+
- defer:
36+
task: :infra:aws:destroy
37+
- defer:
38+
task: :infra:extra:aws:destroy
3339
- task: :tools:keygen
3440
- task: :infra:aws:build
3541
vars: {ENABLE_CONNECT: "true", DISTRO: "43"}
@@ -51,6 +57,8 @@ tasks:
5157
vars:
5258
TIERED_STORAGE_ENABLED: "true"
5359
cmds:
60+
- defer:
61+
task: :infra:aws:destroy
5462
- task: :tools:keygen
5563
- task: :infra:aws:build
5664
vars: {TIERED_STORAGE_ENABLED: "true"}
@@ -69,6 +77,10 @@ tasks:
6977
TIERED_STORAGE_ENABLED: "true"
7078
DISTRO: "43"
7179
cmds:
80+
- defer:
81+
task: :infra:aws:destroy
82+
- defer:
83+
task: :infra:extra:aws:destroy
7284
- task: :tools:keygen
7385
- task: :infra:aws:build
7486
vars: {ENABLE_CONNECT: "true", TIERED_STORAGE_ENABLED: "true", DISTRO: "43"}
@@ -92,6 +104,8 @@ tasks:
92104
gcp:rp:
93105
desc: CI workflow - GCP basic Redpanda
94106
cmds:
107+
- defer:
108+
task: :infra:gcp:destroy
95109
- task: :tools:keygen
96110
- task: :infra:gcp:build
97111
- task: :cluster:provision
@@ -106,6 +120,8 @@ tasks:
106120
vars:
107121
TIERED_STORAGE_ENABLED: "true"
108122
cmds:
123+
- defer:
124+
task: :infra:gcp:destroy
109125
- task: :tools:keygen
110126
- task: :infra:gcp:build
111127
vars: {TIERED_STORAGE_ENABLED: "true"}

aws/main.tf

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
## we assume a default vpc. if you have one you want to use you will need to provide a vpc and subnet ID
22

3-
43
module "redpanda-cluster" {
54
source = "redpanda-data/redpanda-cluster/aws"
65
public_key_path = var.public_key_path
@@ -21,9 +20,9 @@ module "redpanda-cluster" {
2120
client_instance_type = var.client_instance_type
2221
prometheus_instance_type = var.prometheus_instance_type
2322
machine_architecture = var.machine_architecture
24-
connect_count = var.connect_count
25-
connect_instance_type = var.broker_instance_type
26-
enable_connect = var.enable_connect
23+
connect_count = var.connect_count
24+
connect_instance_type = var.broker_instance_type
25+
enable_connect = var.enable_connect
2726
}
2827

2928
variable "broker_instance_type" {

gcp/main.tf

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ module "redpanda-cluster" {
3535
ssh_user = var.ssh_user
3636
subnet = coalesce(var.subnet, google_compute_subnetwork.test-subnet.id)
3737
image = var.image
38-
availability_zone = var.availability_zone
38+
availability_zone = local.availability_zones
3939
broker_count = var.broker_count
4040
client_count = var.client_count
4141
disks = var.disks
@@ -58,6 +58,18 @@ provider "google" {
5858
credentials = base64decode(var.gcp_creds)
5959
}
6060

61+
data "google_compute_zones" "available" {
62+
region = var.region
63+
status = "UP"
64+
}
65+
66+
locals {
67+
availability_zones = length(var.availability_zone) > 0 ? var.availability_zone : [
68+
for z in data.google_compute_zones.available.names :
69+
trimprefix(z, "${var.region}-")
70+
]
71+
}
72+
6173
variable "gcp_creds" {
6274
default = ""
6375
type = string
@@ -69,8 +81,8 @@ variable "region" {
6981
}
7082

7183
variable "availability_zone" {
72-
description = "The zone where the cluster will be deployed [a,b,...]"
73-
default = ["a"]
84+
description = "The zone where the cluster will be deployed [a,b,...]. Leave empty to auto-discover available zones."
85+
default = []
7486
type = list(string)
7587
}
7688

0 commit comments

Comments
 (0)