Skip to content

Commit 9d1088f

Browse files
Drop regional scope, randomize global bucket name. (#1103)
This eliminates the ability to specify a regional scope for workqueue, regional-go-reconciler, and the associated dashboards. This also shifts the (now) solve GCS bucket to use a randomized suffix to reduce the possibility of collisions given the global namespace of GCS buckets. This change is technically lossy as it deletes the live GCS bucket backing the workqueue and replaces it. However, the nature of workqueues is that you can "resync" (e.g. backstop) and recover from any lost data (the K8s equivalent is a controller restart, this is why controllers resync at startup). I applied this to multiple reconcilers in my dev environment without any TF issues. --------- Signed-off-by: Matt Moore <[email protected]> Co-authored-by: octo-sts[bot] <157150467+octo-sts[bot]@users.noreply.github.com>
1 parent 696008b commit 9d1088f

File tree

14 files changed

+20
-129
lines changed

14 files changed

+20
-129
lines changed

modules/dashboard/reconciler/README.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ module "my-reconciler-dashboard" {
1818
# Workqueue configuration
1919
max_retry = 100
2020
concurrent_work = 20
21-
scope = "global"
2221
2322
# Optional sections
2423
sections = {
@@ -55,7 +54,6 @@ The dashboard includes:
5554
| `workqueue_name` | Workqueue name | `${name}-wq` |
5655
| `max_retry` | Maximum retry attempts for tasks | `100` |
5756
| `concurrent_work` | Concurrent work items | `20` |
58-
| `scope` | Workqueue scope (regional/global) | `global` |
5957
| `sections` | Optional dashboard sections | See variables.tf |
6058
| `notification_channels` | Alert notification channels | `[]` |
6159

@@ -82,7 +80,6 @@ module "my-reconciler-dashboard" {
8280
name = "my-reconciler" # Same base name as the reconciler
8381
max_retry = module.my-reconciler.max-retry
8482
concurrent_work = module.my-reconciler.concurrent-work
85-
scope = "global"
8683
}
8784
<!-- BEGIN_TF_DOCS -->
8885
## Requirements
@@ -123,7 +120,6 @@ No resources.
123120
| <a name="input_name"></a> [name](#input\_name) | The name of the reconciler (base name without suffixes) | `string` | n/a | yes |
124121
| <a name="input_notification_channels"></a> [notification\_channels](#input\_notification\_channels) | List of notification channels for alerts | `list(string)` | `[]` | no |
125122
| <a name="input_project_id"></a> [project\_id](#input\_project\_id) | The GCP project ID | `string` | n/a | yes |
126-
| <a name="input_scope"></a> [scope](#input\_scope) | The scope of the workqueue (regional or global) | `string` | `"global"` | no |
127123
| <a name="input_sections"></a> [sections](#input\_sections) | Configure visibility of optional dashboard sections | <pre>object({<br/> github = optional(bool, false)<br/> })</pre> | `{}` | no |
128124
| <a name="input_service_name"></a> [service\_name](#input\_service\_name) | The name of the reconciler service (defaults to name-rec) | `string` | `""` | no |
129125
| <a name="input_workqueue_name"></a> [workqueue\_name](#input\_workqueue\_name) | The name of the workqueue (defaults to name-wq) | `string` | `""` | no |

modules/dashboard/reconciler/dashboard.tf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ module "workqueue-state" {
1616
service_name = local.workqueue_name
1717
max_retry = var.max_retry
1818
concurrent_work = var.concurrent_work
19-
scope = var.scope
2019
filter = []
2120
collapsed = false
2221
}

modules/dashboard/reconciler/variables.tf

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,6 @@ variable "concurrent_work" {
3838
default = 20
3939
}
4040

41-
variable "scope" {
42-
description = "The scope of the workqueue (regional or global)"
43-
type = string
44-
default = "global"
45-
}
46-
4741
// Section visibility
4842
variable "sections" {
4943
description = "Configure visibility of optional dashboard sections"

modules/dashboard/sections/workqueue/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ No resources.
8181
| <a name="input_filter"></a> [filter](#input\_filter) | n/a | `list(string)` | `[]` | no |
8282
| <a name="input_max_retry"></a> [max\_retry](#input\_max\_retry) | n/a | `number` | `0` | no |
8383
| <a name="input_receiver_name"></a> [receiver\_name](#input\_receiver\_name) | n/a | `string` | `""` | no |
84-
| <a name="input_scope"></a> [scope](#input\_scope) | n/a | `string` | `"regional"` | no |
8584
| <a name="input_service_name"></a> [service\_name](#input\_service\_name) | n/a | `string` | n/a | yes |
8685
| <a name="input_title"></a> [title](#input\_title) | n/a | `string` | `"Workqueue State"` | no |
8786

modules/dashboard/sections/workqueue/main.tf

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,6 @@ variable "max_retry" {
2828
variable "concurrent_work" {
2929
type = number
3030
}
31-
variable "scope" {
32-
type = string
33-
default = "regional"
34-
}
3531

3632
locals {
3733
// Use provided names or derive from service_name
@@ -52,7 +48,7 @@ module "work-in-progress" {
5248
"metric.type=\"prometheus.googleapis.com/workqueue_in_progress_keys/gauge\"",
5349
"metric.label.\"service_name\"=\"${local.dsp_name}\"",
5450
])
55-
group_by_fields = var.scope == "regional" ? ["resource.label.\"location\""] : null
51+
group_by_fields = null
5652
primary_align = "ALIGN_MAX"
5753
primary_reduce = "REDUCE_MAX"
5854
thresholds = [var.concurrent_work]
@@ -66,7 +62,7 @@ module "work-queued" {
6662
"metric.type=\"prometheus.googleapis.com/workqueue_queued_keys/gauge\"",
6763
"metric.label.\"service_name\"=\"${local.dsp_name}\"",
6864
])
69-
group_by_fields = var.scope == "regional" ? ["resource.label.\"location\""] : null
65+
group_by_fields = null
7066
plot_type = "STACKED_AREA"
7167
primary_align = "ALIGN_MAX"
7268
primary_reduce = "REDUCE_MAX"
@@ -105,7 +101,7 @@ module "wait-latency" {
105101
"metric.type=\"prometheus.googleapis.com/workqueue_wait_latency_seconds/histogram\"",
106102
"metric.label.\"service_name\"=\"${local.dsp_name}\"",
107103
])
108-
group_by_fields = var.scope == "regional" ? ["resource.label.\"location\""] : null
104+
group_by_fields = null
109105
}
110106

111107
module "percent-deduped" {
@@ -128,10 +124,10 @@ module "percent-deduped" {
128124
alignment_period = "60s"
129125
thresholds = []
130126
numerator_align = "ALIGN_RATE"
131-
numerator_group_by_fields = var.scope == "regional" ? ["resource.label.\"location\""] : null
127+
numerator_group_by_fields = null
132128
numerator_reduce = "REDUCE_SUM"
133129
denominator_align = "ALIGN_RATE"
134-
denominator_group_by_fields = var.scope == "regional" ? ["resource.label.\"location\""] : null
130+
denominator_group_by_fields = null
135131
denominator_reduce = "REDUCE_SUM"
136132
}
137133

@@ -150,7 +146,7 @@ module "max-attempts" {
150146
"metric.type=\"prometheus.googleapis.com/workqueue_max_attempts/gauge\"",
151147
"metric.label.\"service_name\"=\"${local.dsp_name}\"",
152148
])
153-
group_by_fields = var.scope == "regional" ? ["resource.label.\"location\""] : null
149+
group_by_fields = null
154150
primary_align = "ALIGN_MAX"
155151
primary_reduce = "REDUCE_MAX"
156152
thresholds = var.max_retry > 0 ? [var.max_retry] : []
@@ -171,7 +167,7 @@ module "dead-letter-queue" {
171167
"metric.type=\"prometheus.googleapis.com/workqueue_dead_lettered_keys/gauge\"",
172168
"metric.label.\"service_name\"=\"${local.dsp_name}\"",
173169
])
174-
group_by_fields = var.scope == "regional" ? ["resource.label.\"location\""] : null
170+
group_by_fields = null
175171
plot_type = "STACKED_AREA"
176172
primary_align = "ALIGN_MAX"
177173
primary_reduce = "REDUCE_MAX"

modules/dashboard/workqueue/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ No resources.
7575
| <a name="input_labels"></a> [labels](#input\_labels) | Additional labels to apply to the dashboard | `map(string)` | `{}` | no |
7676
| <a name="input_max_retry"></a> [max\_retry](#input\_max\_retry) | The maximum number of retry attempts before a task is moved to the dead letter queue | `number` | `100` | no |
7777
| <a name="input_name"></a> [name](#input\_name) | Name of the workqueue | `string` | n/a | yes |
78-
| <a name="input_scope"></a> [scope](#input\_scope) | The scope of the workqueue: 'regional' or 'global' | `string` | `"regional"` | no |
7978

8079
## Outputs
8180

modules/dashboard/workqueue/dashboard.tf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ module "workqueue-state" {
55
service_name = var.name
66
max_retry = var.max_retry
77
concurrent_work = var.concurrent_work
8-
scope = var.scope
98
filter = []
109
collapsed = false
1110
}

modules/dashboard/workqueue/variables.tf

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,6 @@ variable "concurrent_work" {
1414
type = number
1515
}
1616

17-
variable "scope" {
18-
description = "The scope of the workqueue: 'regional' or 'global'"
19-
type = string
20-
default = "regional"
21-
}
22-
2317
variable "labels" {
2418
description = "Additional labels to apply to the dashboard"
2519
type = map(string)

modules/regional-go-reconciler/main.tf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ module "workqueue" {
3131
notification_channels = var.notification_channels
3232
labels = var.labels
3333

34-
scope = "global"
3534
multi_regional_location = var.multi_regional_location
3635

3736
depends_on = [module.reconciler]

modules/workqueue/README.md

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -171,22 +171,17 @@ No requirements.
171171
| [google-beta_google_project_service_identity.pubsub](https://registry.terraform.io/providers/hashicorp/google-beta/latest/docs/resources/google_project_service_identity) | resource |
172172
| [google_cloud_scheduler_job.cron](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/cloud_scheduler_job) | resource |
173173
| [google_pubsub_subscription.global-this](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/pubsub_subscription) | resource |
174-
| [google_pubsub_subscription.this](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/pubsub_subscription) | resource |
175174
| [google_pubsub_topic.global-object-change-notifications](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/pubsub_topic) | resource |
176-
| [google_pubsub_topic.object-change-notifications](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/pubsub_topic) | resource |
177-
| [google_pubsub_topic_iam_binding.gcs-publishes-to-topic](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/pubsub_topic_iam_binding) | resource |
178175
| [google_pubsub_topic_iam_binding.global-gcs-publishes-to-topic](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/pubsub_topic_iam_binding) | resource |
179176
| [google_service_account.change-trigger](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/service_account) | resource |
180177
| [google_service_account.cron-trigger](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/service_account) | resource |
181178
| [google_service_account.dispatcher](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/service_account) | resource |
182179
| [google_service_account.receiver](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/service_account) | resource |
183180
| [google_service_account_iam_binding.allow-pubsub-to-mint-tokens](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/service_account_iam_binding) | resource |
184181
| [google_storage_bucket.global-workqueue](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/storage_bucket) | resource |
185-
| [google_storage_bucket.workqueue](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/storage_bucket) | resource |
186-
| [google_storage_bucket_iam_binding.authorize-access](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/storage_bucket_iam_binding) | resource |
187182
| [google_storage_bucket_iam_binding.global-authorize-access](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/storage_bucket_iam_binding) | resource |
188183
| [google_storage_notification.global-object-change-notifications](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/storage_notification) | resource |
189-
| [google_storage_notification.object-change-notifications](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/storage_notification) | resource |
184+
| [random_string.bucket_suffix](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/string) | resource |
190185
| [random_string.change-trigger](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/string) | resource |
191186
| [random_string.cron-trigger](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/string) | resource |
192187
| [random_string.dispatcher](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/string) | resource |
@@ -208,7 +203,7 @@ No requirements.
208203
| <a name="input_project_id"></a> [project\_id](#input\_project\_id) | n/a | `string` | n/a | yes |
209204
| <a name="input_reconciler-service"></a> [reconciler-service](#input\_reconciler-service) | The name of the reconciler service that the workqueue will dispatch work to. | <pre>object({<br/> name = string<br/> })</pre> | n/a | yes |
210205
| <a name="input_regions"></a> [regions](#input\_regions) | A map from region names to a network and subnetwork. A service will be created in each region configured to egress the specified traffic via the specified subnetwork. | <pre>map(object({<br/> network = string<br/> subnet = string<br/> }))</pre> | n/a | yes |
211-
| <a name="input_scope"></a> [scope](#input\_scope) | The scope of the workqueue: 'regional' for region-specific workqueues or 'global' for a single multi-regional workqueue. | `string` | `"global"` | no |
206+
| <a name="input_scope"></a> [scope](#input\_scope) | The scope of the workqueue. Must be 'global' for a single multi-regional workqueue. | `string` | `"global"` | no |
212207
| <a name="input_squad"></a> [squad](#input\_squad) | squad label to apply to the service. | `string` | n/a | yes |
213208

214209
## Outputs

0 commit comments

Comments
 (0)