Skip to content

Commit ffc3347

Browse files
committed
DTOSS-11646: Add a startup probe and PR fixes
Also update the terradocs on the container app module and update the README.md for how to deploy probes from root module
1 parent 1853e5b commit ffc3347

File tree

6 files changed

+91
-22
lines changed

6 files changed

+91
-22
lines changed

infrastructure/modules/container-app/README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,3 +122,26 @@ module "container-app" {
122122
replica_restart_alert_threshold = 1 (already defaults to this)
123123
}
124124
```
125+
126+
## Container Probes
127+
128+
To enable container probs:
129+
- Set `probe_path = "/healthcheck"`.
130+
- Ensure `ALLOWED_HOSTS`includes `127.0.0.1` and `localhost` so the probe running inside the container can access the health endpoint.
131+
132+
Example:
133+
```hcl
134+
module "container-app" {
135+
...
136+
probe_path = "/healthcheck"
137+
...
138+
environment_variables = merge(
139+
local.common_env,
140+
{
141+
ALLOWED_HOSTS = "${var.app_short_name}-web-${var.environment}.${var.default_domain},localhost,127.0.0.1"
142+
}
143+
...
144+
)
145+
...
146+
}
147+
```

infrastructure/modules/container-app/main.tf

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,17 +104,29 @@ resource "azurerm_container_app" "main" {
104104
}
105105
}
106106

107+
dynamic "startup_probe" {
108+
for_each = local.probe_enabled ? [1] : []
109+
110+
content {
111+
transport = "HTTP"
112+
path = var.probe_path
113+
port = var.port
114+
interval_seconds = 5
115+
timeout = 2
116+
failure_count_threshold = 30
117+
}
118+
}
119+
107120
dynamic "liveness_probe" {
108121
for_each = local.probe_enabled ? [1] : []
109122

110123
content {
111124
transport = "HTTP"
112125
path = var.probe_path
113-
port = local.effective_liveness_port
114-
initial_delay = 45
115-
interval_seconds = 10
126+
port = var.port
127+
interval_seconds = 5
116128
timeout = 2
117-
failure_count_threshold = 4
129+
failure_count_threshold = 2
118130
}
119131
}
120132
}

infrastructure/modules/container-app/tfdocs.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,14 @@ Type: `number`
210210

211211
Default: `8080`
212212

213+
### <a name="input_probe_path"></a> [probe\_path](#input\_probe\_path)
214+
215+
Description: Path for the HTTP health probe. If null, HTTP health probe is disabled. Note /healthcheck is the normal convention.
216+
217+
Type: `string`
218+
219+
Default: `null`
220+
213221
### <a name="input_replica_restart_alert_threshold"></a> [replica\_restart\_alert\_threshold](#input\_replica\_restart\_alert\_threshold)
214222

215223
Description: The replica restart alert threshold, default will be 1.

infrastructure/modules/container-app/variables.tf

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,6 @@ variable "exposed_port" {
9393
default = null
9494
}
9595

96-
variable "liveness_probe_port" {
97-
description = "Port for the liveness probe to check. Default is var.port."
98-
type = number
99-
default = null
100-
}
101-
10296
variable "memory" {
10397
description = "Memory allocated to the app (GiB). Also dictates the CPU allocation: CPU(%)=MEMORY(Gi)/2. Maximum: 4Gi"
10498
default = "0.5"
@@ -197,7 +191,7 @@ variable "replica_restart_alert_threshold" {
197191
}
198192

199193
variable "probe_path" {
200-
description = "Path for the liveness probe. If null, liveness probe is disabled."
194+
description = "Path for the HTTP health probe. If null, HTTP health probe is disabled. Note /healthcheck is the normal convention."
201195
type = string
202196
default = null
203197
}
@@ -214,7 +208,6 @@ locals {
214208
PT6H = "PT5M"
215209
PT12H = "PT5M"
216210
}
217-
alert_frequency = local.alert_frequency_map[var.alert_window_size]
218-
probe_enabled = var.probe_path != null
219-
effective_liveness_port = var.liveness_probe_port != null ? var.liveness_probe_port : var.port
211+
alert_frequency = local.alert_frequency_map[var.alert_window_size]
212+
probe_enabled = var.probe_path != null && var.is_web_app
220213
}

infrastructure/modules/sql-server/tfdocs.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,30 @@ Type: `string`
132132

133133
The following input variables are optional (have default values):
134134

135+
### <a name="input_action_group_id"></a> [action\_group\_id](#input\_action\_group\_id)
136+
137+
Description: ID of the action group to notify.
138+
139+
Type: `string`
140+
141+
Default: `null`
142+
143+
### <a name="input_alert_cpu_threshold"></a> [alert\_cpu\_threshold](#input\_alert\_cpu\_threshold)
144+
145+
Description: If alerting is enabled this will control what the cpu threshold will be, default will be 90.
146+
147+
Type: `number`
148+
149+
Default: `90`
150+
151+
### <a name="input_alert_window_size"></a> [alert\_window\_size](#input\_alert\_window\_size)
152+
153+
Description: The period of time that is used to monitor alert activity e.g. PT1M, PT5M, PT15M, PT30M, PT1H, PT6H, PT12H. The interval between checks is adjusted accordingly.
154+
155+
Type: `string`
156+
157+
Default: `"PT5M"`
158+
135159
### <a name="input_auditing_policy_retention_in_days"></a> [auditing\_policy\_retention\_in\_days](#input\_auditing\_policy\_retention\_in\_days)
136160

137161
Description: number of days for audit log policies
@@ -164,6 +188,14 @@ Type: `string`
164188

165189
Default: `"baseline"`
166190

191+
### <a name="input_enable_alerting"></a> [enable\_alerting](#input\_enable\_alerting)
192+
193+
Description: Whether monitoring and alerting is enabled for the Azure SQL Server.
194+
195+
Type: `bool`
196+
197+
Default: `false`
198+
167199
### <a name="input_firewall_rules"></a> [firewall\_rules](#input\_firewall\_rules)
168200

169201
Description: If the FW rule enabling Azure Services Passthrough should be deployed.
@@ -345,6 +377,7 @@ Description: The ID of the SQL Server.
345377

346378
The following resources are used by this module:
347379

380+
- [azurerm_monitor_metric_alert.cpu](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/monitor_metric_alert) (resource)
348381
- [azurerm_mssql_database.defaultdb](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/mssql_database) (resource)
349382
- [azurerm_mssql_database_extended_auditing_policy.database_auditing_policy](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/mssql_database_extended_auditing_policy) (resource)
350383
- [azurerm_mssql_firewall_rule.firewall_rule](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/mssql_firewall_rule) (resource)

infrastructure/modules/storage/tfdocs.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,14 @@ Type: `string`
8181

8282
The following input variables are optional (have default values):
8383

84+
### <a name="input_access_tier"></a> [access\_tier](#input\_access\_tier)
85+
86+
Description: Defines the access tier for BlobStorage, FileStorage and StorageV2 accounts. Valid options are Hot, Cool, Cold and Premium.
87+
88+
Type: `string`
89+
90+
Default: `"Hot"`
91+
8492
### <a name="input_account_replication_type"></a> [account\_replication\_type](#input\_account\_replication\_type)
8593

8694
Description: The type of replication to use for this Storage Account. Can be either LRS, GRS, RAGRS or ZRS.
@@ -97,14 +105,6 @@ Type: `string`
97105

98106
Default: `"Standard"`
99107

100-
### <a name="input_access_tier"></a> [access\_tier](#input\_access\_tier)
101-
102-
Description: Defines the access tier for BlobStorage, FileStorage and StorageV2 accounts. Valid options are Hot, Cool, Cold and Premium. Defaults to Hot.
103-
104-
Type: `string`
105-
106-
Default: `"Hot"`
107-
108108
### <a name="input_action_group_id"></a> [action\_group\_id](#input\_action\_group\_id)
109109

110110
Description: ID of the action group to notify.

0 commit comments

Comments
 (0)