-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: reduce warm up time #72
Changes from all commits
5d4a0e1
db0281d
9ae06e2
7dbc872
0a52ffc
fea66d0
2023883
839eb88
b73b98b
f412d9f
98e0e35
5716440
5efb4c5
013411e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -217,6 +217,9 @@ resource "google_compute_region_network_endpoint_group" "default" { | |
resource "google_compute_global_address" "default" { | ||
project = var.project_id | ||
name = "${var.deployment_name}-reserved-ip" | ||
depends_on = [ | ||
time_sleep.project_services | ||
] | ||
} | ||
|
||
resource "google_compute_url_map" "default" { | ||
|
@@ -290,12 +293,26 @@ resource "google_compute_global_forwarding_rule" "http" { | |
labels = var.labels | ||
} | ||
|
||
resource "time_sleep" "load_balancer_warm_up_time" { | ||
# It may take more than 2 minutes for the newly provisioned load balancer | ||
# to forward requests to the Cloud Run service. The following data source | ||
# allows for terraform apply to finish running when the end-point resolves | ||
|
||
data "http" "load_balancer_warm_up" { | ||
url = "http://${google_compute_global_address.default.address}/" | ||
# Attempt retry every 20 seconds 17 times, totaling to a 6 minute timeout. | ||
retry { | ||
attempts = 17 | ||
max_delay_ms = 20000 | ||
min_delay_ms = 20000 | ||
} | ||
Comment on lines
+303
to
+307
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. discussion: Was curious if there were any surprises here, I think these parameters are likely being used with https://github.com/hashicorp/go-retryablehttp/blob/v0.7.4/client.go#L520C23-L520C23. Based on my reading, min_delay_ms would not normally be linear, but setting the max to the same value caps the exponential computation. No op here, just thought that may be interesting if others haven't delved that far. |
||
# Begin trying after load balancer resources are created. | ||
depends_on = [ | ||
google_compute_global_address.default, | ||
google_compute_url_map.default, | ||
google_compute_backend_service.default, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. note: Alright, I've talked myself out of this being a suggestion and made it a "note". |
||
google_compute_target_http_proxy.default, | ||
google_compute_global_forwarding_rule.http | ||
] | ||
|
||
create_duration = "370s" | ||
} | ||
|
||
### Firestore ### | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,7 @@ | |
|
||
output "frontend_url" { | ||
description = "IP address to site. Load balancer expected to take ~5 minutes for it to warm up." | ||
value = "http://${google_compute_global_address.default.address}/" | ||
value = data.http.load_balancer_warm_up.url | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. praise: Nice simplification of the output configuration based on the http data. |
||
} | ||
|
||
output "neos_toc_url" { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: why 6 minutes? Depending on the answer, that may be good to add to the inline comment because it would help future maintainers understand how to repeat the reasoning if the number should be changed in the future.