mirror of
https://github.com/bpg/terraform-provider-proxmox.git
synced 2025-06-30 18:42:58 +00:00
feat(lxc): add configurable timeout for container creation (#1146)
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
This commit is contained in:
parent
b366b2c9d5
commit
84440d8329
@ -214,6 +214,7 @@ output "ubuntu_container_public_key" {
|
||||
difference on the resource. You may use the `ignore_changes` lifecycle
|
||||
meta-argument to ignore changes to this attribute.
|
||||
- `template` - (Optional) Whether to create a template (defaults to `false`).
|
||||
- `timeout_create` - (Optional) Timeout for creating a container in seconds (defaults to 1800).
|
||||
- `unprivileged` - (Optional) Whether the container runs as unprivileged on
|
||||
the host (defaults to `false`).
|
||||
- `vm_id` - (Optional) The container identifier
|
||||
|
@ -75,6 +75,7 @@ const (
|
||||
dvStartupDownDelay = -1
|
||||
dvStartOnBoot = true
|
||||
dvTemplate = false
|
||||
dvTimeoutCreate = 1800
|
||||
dvUnprivileged = false
|
||||
dvVMID = -1
|
||||
|
||||
@ -154,6 +155,7 @@ const (
|
||||
mkStartOnBoot = "start_on_boot"
|
||||
mkTags = "tags"
|
||||
mkTemplate = "template"
|
||||
mkTimeoutCreate = "timeout_create"
|
||||
mkUnprivileged = "unprivileged"
|
||||
mkVMID = "vm_id"
|
||||
)
|
||||
@ -834,6 +836,12 @@ func Container() *schema.Resource {
|
||||
ForceNew: true,
|
||||
Default: dvTemplate,
|
||||
},
|
||||
mkTimeoutCreate: {
|
||||
Type: schema.TypeInt,
|
||||
Description: "Create container timeout",
|
||||
Optional: true,
|
||||
Default: dvTimeoutCreate,
|
||||
},
|
||||
mkUnprivileged: {
|
||||
Type: schema.TypeBool,
|
||||
Description: "Whether the container runs as unprivileged on the host",
|
||||
@ -1721,8 +1729,10 @@ func containerCreateStart(ctx context.Context, d *schema.ResourceData, m interfa
|
||||
|
||||
containerAPI := api.Node(nodeName).Container(vmID)
|
||||
|
||||
createTimeout := d.Get(mkTimeoutCreate).(int)
|
||||
|
||||
// Start the container and wait for it to reach a running state before continuing.
|
||||
err = containerAPI.StartContainer(ctx, 60)
|
||||
err = containerAPI.StartContainer(ctx, createTimeout)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user