Skip to content
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

azurerm_container_app – support for termination_grace_period_seconds #28307

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1387,6 +1387,8 @@ resource "azurerm_container_app" "test" {
max_replicas = 3

revision_suffix = "%[3]s"

termination_grace_period_seconds = 60
}

ingress {
Expand Down
44 changes: 27 additions & 17 deletions internal/services/containerapps/helpers/container_apps.go
Original file line number Diff line number Diff line change
Expand Up @@ -813,16 +813,17 @@ func ContainerAppEnvironmentDaprMetadataSchema() *pluginsdk.Schema {
}

type ContainerTemplate struct {
Containers []Container `tfschema:"container"`
InitContainers []BaseContainer `tfschema:"init_container"`
Suffix string `tfschema:"revision_suffix"`
MinReplicas int64 `tfschema:"min_replicas"`
MaxReplicas int64 `tfschema:"max_replicas"`
AzureQueueScaleRules []AzureQueueScaleRule `tfschema:"azure_queue_scale_rule"`
CustomScaleRules []CustomScaleRule `tfschema:"custom_scale_rule"`
HTTPScaleRules []HTTPScaleRule `tfschema:"http_scale_rule"`
TCPScaleRules []TCPScaleRule `tfschema:"tcp_scale_rule"`
Volumes []ContainerVolume `tfschema:"volume"`
Containers []Container `tfschema:"container"`
InitContainers []BaseContainer `tfschema:"init_container"`
Suffix string `tfschema:"revision_suffix"`
MinReplicas int64 `tfschema:"min_replicas"`
MaxReplicas int64 `tfschema:"max_replicas"`
AzureQueueScaleRules []AzureQueueScaleRule `tfschema:"azure_queue_scale_rule"`
CustomScaleRules []CustomScaleRule `tfschema:"custom_scale_rule"`
HTTPScaleRules []HTTPScaleRule `tfschema:"http_scale_rule"`
TCPScaleRules []TCPScaleRule `tfschema:"tcp_scale_rule"`
Volumes []ContainerVolume `tfschema:"volume"`
TerminationGracePeriod int64 `tfschema:"termination_grace_period_seconds"`
}

func ContainerTemplateSchema() *pluginsdk.Schema {
Expand Down Expand Up @@ -868,6 +869,13 @@ func ContainerTemplateSchema() *pluginsdk.Schema {
Computed: true, // Note: O+C This value is always present and non-zero but if not user specified, then the service will generate a value.
Description: "The suffix for the revision. This value must be unique for the lifetime of the Resource. If omitted the service will use a hash function to create one.",
},

"termination_grace_period_seconds": {
Type: pluginsdk.TypeInt,
Optional: true,
ValidateFunc: validation.IntBetween(0, 600),
Description: "The time in seconds after the container is sent the termination signal before the process if forcibly killed.",
},
catriona-m marked this conversation as resolved.
Show resolved Hide resolved
},
},
}
Expand Down Expand Up @@ -921,9 +929,10 @@ func ExpandContainerAppTemplate(input []ContainerTemplate, metadata sdk.Resource

config := input[0]
template := &containerapps.Template{
Containers: expandContainerAppContainers(config.Containers),
InitContainers: expandInitContainerAppContainers(config.InitContainers),
Volumes: expandContainerAppVolumes(config.Volumes),
Containers: expandContainerAppContainers(config.Containers),
InitContainers: expandInitContainerAppContainers(config.InitContainers),
Volumes: expandContainerAppVolumes(config.Volumes),
TerminationGracePeriodSeconds: pointer.To(config.TerminationGracePeriod),
}

if config.MaxReplicas != 0 {
Expand Down Expand Up @@ -962,10 +971,11 @@ func FlattenContainerAppTemplate(input *containerapps.Template) []ContainerTempl
return []ContainerTemplate{}
}
result := ContainerTemplate{
Containers: flattenContainerAppContainers(input.Containers),
InitContainers: flattenInitContainerAppContainers(input.InitContainers),
Suffix: pointer.From(input.RevisionSuffix),
Volumes: flattenContainerAppVolumes(input.Volumes),
Containers: flattenContainerAppContainers(input.Containers),
InitContainers: flattenInitContainerAppContainers(input.InitContainers),
Suffix: pointer.From(input.RevisionSuffix),
TerminationGracePeriod: pointer.From(input.TerminationGracePeriodSeconds),
Volumes: flattenContainerAppVolumes(input.Volumes),
}

if scale := input.Scale; scale != nil {
Expand Down
2 changes: 2 additions & 0 deletions website/docs/d/container_app.html.markdown
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this docs file is for the the datasource, could we move this change to website/docs/r/container_app.html.markdown?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added to the resource doc. No need to remove from the data source docs as both use the same schema

Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ A `template` block supports the following:

* `revision_suffix` - The suffix for the revision. This value must be unique for the lifetime of the Resource. If omitted the service will use a hash function to create one.

* `termination_grace_period_seconds` - The time in seconds after the container is sent the termination signal before the process if forcibly killed.

* `volume` - A `volume` block as detailed below.

---
Expand Down
Loading