mirror of
https://github.com/bpg/terraform-provider-proxmox.git
synced 2025-07-01 02:52: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
|
difference on the resource. You may use the `ignore_changes` lifecycle
|
||||||
meta-argument to ignore changes to this attribute.
|
meta-argument to ignore changes to this attribute.
|
||||||
- `template` - (Optional) Whether to create a template (defaults to `false`).
|
- `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
|
- `unprivileged` - (Optional) Whether the container runs as unprivileged on
|
||||||
the host (defaults to `false`).
|
the host (defaults to `false`).
|
||||||
- `vm_id` - (Optional) The container identifier
|
- `vm_id` - (Optional) The container identifier
|
||||||
|
@ -75,6 +75,7 @@ const (
|
|||||||
dvStartupDownDelay = -1
|
dvStartupDownDelay = -1
|
||||||
dvStartOnBoot = true
|
dvStartOnBoot = true
|
||||||
dvTemplate = false
|
dvTemplate = false
|
||||||
|
dvTimeoutCreate = 1800
|
||||||
dvUnprivileged = false
|
dvUnprivileged = false
|
||||||
dvVMID = -1
|
dvVMID = -1
|
||||||
|
|
||||||
@ -154,6 +155,7 @@ const (
|
|||||||
mkStartOnBoot = "start_on_boot"
|
mkStartOnBoot = "start_on_boot"
|
||||||
mkTags = "tags"
|
mkTags = "tags"
|
||||||
mkTemplate = "template"
|
mkTemplate = "template"
|
||||||
|
mkTimeoutCreate = "timeout_create"
|
||||||
mkUnprivileged = "unprivileged"
|
mkUnprivileged = "unprivileged"
|
||||||
mkVMID = "vm_id"
|
mkVMID = "vm_id"
|
||||||
)
|
)
|
||||||
@ -834,6 +836,12 @@ func Container() *schema.Resource {
|
|||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
Default: dvTemplate,
|
Default: dvTemplate,
|
||||||
},
|
},
|
||||||
|
mkTimeoutCreate: {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Description: "Create container timeout",
|
||||||
|
Optional: true,
|
||||||
|
Default: dvTimeoutCreate,
|
||||||
|
},
|
||||||
mkUnprivileged: {
|
mkUnprivileged: {
|
||||||
Type: schema.TypeBool,
|
Type: schema.TypeBool,
|
||||||
Description: "Whether the container runs as unprivileged on the host",
|
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)
|
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.
|
// 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 {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user