Skip to content

Commit 6959cbd

Browse files
authored
azurerm_container_app_job add InitialDelaySeconds for readiness and startup probes (hashicorp#31796)
[BUG] * `azurerm_container_app_job` add InitialDelaySeconds for readiness and startup probes (hashicorp#31796)
1 parent 6481733 commit 6959cbd

2 files changed

Lines changed: 107 additions & 9 deletions

File tree

internal/services/containerapps/container_app_job_resource_test.go

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,21 @@ func TestAccContainerAppJob_withIdentityUpdate(t *testing.T) {
139139
})
140140
}
141141

142+
func TestAccContainerAppJob_allProbes(t *testing.T) {
143+
data := acceptance.BuildTestData(t, "azurerm_container_app_job", "test")
144+
r := ContainerAppJobResource{}
145+
146+
data.ResourceTest(t, r, []acceptance.TestStep{
147+
{
148+
Config: r.allProbes(data),
149+
Check: acceptance.ComposeTestCheckFunc(
150+
check.That(data.ResourceName).ExistsInAzure(r),
151+
),
152+
},
153+
data.ImportStep(),
154+
})
155+
}
156+
142157
func TestAccContainerAppJob_eventTrigger(t *testing.T) {
143158
data := acceptance.BuildTestData(t, "azurerm_container_app_job", "test")
144159
r := ContainerAppJobResource{}
@@ -287,6 +302,85 @@ func TestAccContainerAppJob_withKeyVaultSecretIdentityUpdate(t *testing.T) {
287302
})
288303
}
289304

305+
func (r ContainerAppJobResource) allProbes(data acceptance.TestData) string {
306+
template := r.template(data)
307+
return fmt.Sprintf(`
308+
provider "azurerm" {
309+
features {}
310+
}
311+
312+
%[1]s
313+
314+
resource "azurerm_container_app_job" "test" {
315+
name = "acctest-cajob%[2]d"
316+
resource_group_name = azurerm_resource_group.test.name
317+
location = azurerm_resource_group.test.location
318+
container_app_environment_id = azurerm_container_app_environment.test.id
319+
320+
replica_timeout_in_seconds = 10
321+
replica_retry_limit = 10
322+
manual_trigger_config {
323+
parallelism = 4
324+
replica_completion_count = 1
325+
}
326+
327+
template {
328+
container {
329+
image = "jackofallops/azure-containerapps-python-acctest:v0.0.1"
330+
name = "testcontainerappsjob0"
331+
liveness_probe {
332+
transport = "HTTP"
333+
port = 5000
334+
path = "/health"
335+
336+
header {
337+
name = "Cache-Control"
338+
value = "no-cache"
339+
}
340+
341+
initial_delay = 5
342+
interval_seconds = 20
343+
timeout = 2
344+
failure_count_threshold = 1
345+
}
346+
startup_probe {
347+
transport = "HTTP"
348+
port = 5000
349+
path = "/health"
350+
351+
header {
352+
name = "Cache-Control"
353+
value = "no-cache"
354+
}
355+
356+
initial_delay = 5
357+
interval_seconds = 20
358+
timeout = 2
359+
failure_count_threshold = 1
360+
}
361+
readiness_probe {
362+
transport = "HTTP"
363+
port = 5000
364+
path = "/health"
365+
366+
header {
367+
name = "Cache-Control"
368+
value = "no-cache"
369+
}
370+
371+
initial_delay = 5
372+
interval_seconds = 20
373+
timeout = 2
374+
failure_count_threshold = 1
375+
}
376+
cpu = 0.5
377+
memory = "1Gi"
378+
}
379+
}
380+
}
381+
`, template, data.RandomInteger)
382+
}
383+
290384
func (r ContainerAppJobResource) eventTrigger(data acceptance.TestData) string {
291385
template := r.template(data)
292386
return fmt.Sprintf(`

internal/services/containerapps/helpers/container_app_job.go

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -586,11 +586,12 @@ func expandContainerAppJobLivenessProbe(input ContainerAppLivenessProbe) jobs.Co
586586
func expandContainerAppJobReadinessProbe(input ContainerAppReadinessProbe) jobs.ContainerAppProbe {
587587
probeType := jobs.TypeReadiness
588588
result := jobs.ContainerAppProbe{
589-
Type: &probeType,
590-
PeriodSeconds: pointer.To(input.Interval),
591-
TimeoutSeconds: pointer.To(input.Timeout),
592-
FailureThreshold: pointer.To(input.FailureThreshold),
593-
SuccessThreshold: pointer.To(input.SuccessThreshold),
589+
Type: &probeType,
590+
InitialDelaySeconds: pointer.To(input.InitialDelay),
591+
PeriodSeconds: pointer.To(input.Interval),
592+
TimeoutSeconds: pointer.To(input.Timeout),
593+
FailureThreshold: pointer.To(input.FailureThreshold),
594+
SuccessThreshold: pointer.To(input.SuccessThreshold),
594595
}
595596

596597
switch p := strings.ToUpper(input.Transport); p {
@@ -627,10 +628,11 @@ func expandContainerAppJobReadinessProbe(input ContainerAppReadinessProbe) jobs.
627628
func expandContainerAppJobStartupProbe(input ContainerAppStartupProbe) jobs.ContainerAppProbe {
628629
probeType := jobs.TypeStartup
629630
result := jobs.ContainerAppProbe{
630-
Type: &probeType,
631-
PeriodSeconds: pointer.To(input.Interval),
632-
TimeoutSeconds: pointer.To(input.Timeout),
633-
FailureThreshold: pointer.To(input.FailureThreshold),
631+
Type: &probeType,
632+
InitialDelaySeconds: pointer.To(input.InitialDelay),
633+
PeriodSeconds: pointer.To(input.Interval),
634+
TimeoutSeconds: pointer.To(input.Timeout),
635+
FailureThreshold: pointer.To(input.FailureThreshold),
634636
}
635637

636638
switch p := strings.ToUpper(input.Transport); p {
@@ -753,6 +755,7 @@ func flattenContainerAppJobLivenessProbe(input jobs.ContainerAppProbe) []Contain
753755
func flattenContainerAppJobReadinessProbe(input jobs.ContainerAppProbe) []ContainerAppReadinessProbe {
754756
result := make([]ContainerAppReadinessProbe, 0)
755757
probe := ContainerAppReadinessProbe{
758+
InitialDelay: pointer.From(input.InitialDelaySeconds),
756759
Interval: pointer.From(input.PeriodSeconds),
757760
Timeout: pointer.From(input.TimeoutSeconds),
758761
FailureThreshold: pointer.From(input.FailureThreshold),
@@ -793,6 +796,7 @@ func flattenContainerAppJobReadinessProbe(input jobs.ContainerAppProbe) []Contai
793796
func flattenContainerAppJobStartupProbe(input jobs.ContainerAppProbe) []ContainerAppStartupProbe {
794797
result := make([]ContainerAppStartupProbe, 0)
795798
probe := ContainerAppStartupProbe{
799+
InitialDelay: pointer.From(input.InitialDelaySeconds),
796800
Interval: pointer.From(input.PeriodSeconds),
797801
Timeout: pointer.From(input.TimeoutSeconds),
798802
FailureThreshold: pointer.From(input.FailureThreshold),

0 commit comments

Comments
 (0)