Skip to content

Commit c4f9126

Browse files
authored
Allow user to specify task_timeout (#27)
* Adding task_timeout option Fixes #20 * Updated hcl2 config * Updating docs for task_timeout
1 parent 48cc7dc commit c4f9126

File tree

7 files changed

+17
-5
lines changed

7 files changed

+17
-5
lines changed

builder/proxmox/clone/config.hcl2spec.go

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

builder/proxmox/common/client.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,16 @@ package proxmox
33
import (
44
"crypto/tls"
55
"log"
6-
"time"
76

87
"github.com/Telmate/proxmox-api-go/proxmox"
98
)
109

11-
const defaultTaskTimeout = 30 * time.Second
12-
1310
func newProxmoxClient(config Config) (*proxmox.Client, error) {
1411
tlsConfig := &tls.Config{
1512
InsecureSkipVerify: config.SkipCertValidation,
1613
}
1714

18-
client, err := proxmox.NewClient(config.proxmoxURL.String(), nil, tlsConfig, int(defaultTaskTimeout.Seconds()))
15+
client, err := proxmox.NewClient(config.proxmoxURL.String(), nil, tlsConfig, int(config.TaskTimeout.Seconds()))
1916
if err != nil {
2017
return nil, err
2118
}

builder/proxmox/common/config.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ type Config struct {
4040
Token string `mapstructure:"token"`
4141
Node string `mapstructure:"node"`
4242
Pool string `mapstructure:"pool"`
43+
TaskTimeout time.Duration `mapstructure:"task_timeout"`
4344

4445
VMName string `mapstructure:"vm_name"`
4546
VMID int `mapstructure:"vm_id"`
@@ -143,6 +144,9 @@ func (c *Config) Prepare(upper interface{}, raws ...interface{}) ([]string, []st
143144
if c.Token == "" {
144145
c.Token = os.Getenv("PROXMOX_TOKEN")
145146
}
147+
if c.TaskTimeout == 0 {
148+
c.TaskTimeout = 60 * time.Second
149+
}
146150
if c.BootKeyInterval == 0 && os.Getenv(bootcommand.PackerKeyEnv) != "" {
147151
var err error
148152
c.BootKeyInterval, err = time.ParseDuration(os.Getenv(bootcommand.PackerKeyEnv))

builder/proxmox/common/config.hcl2spec.go

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

builder/proxmox/iso/config.hcl2spec.go

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs-partials/builder/proxmox/common/Config-not-required.mdx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
- `pool` (string) - Pool
1818

19+
- `task_timeout` (duration string | ex: "1h5m2s") - Task Timeout
20+
1921
- `vm_name` (string) - VM Name
2022

2123
- `vm_id` (int) - VMID
@@ -38,7 +40,7 @@
3840

3941
- `disks` ([]diskConfig) - Disks
4042

41-
- `qemu_agent` (bool) - Agent
43+
- `qemu_agent` (boolean) - Agent
4244

4345
- `scsi_controller` (string) - SCSI Controller
4446

docs/builders/clone.mdx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ in the image's Cloud-Init settings for provisioning.
6868

6969
- `insecure_skip_tls_verify` (bool) - Skip validating the certificate.
7070

71+
- `task_timeout` (duration string | ex: "10m") - The timeout for
72+
Promox API operations, e.g. clones. Defaults to 1 minute.
73+
7174
- `pool` (string) - Name of resource pool to create virtual machine in.
7275

7376
- `vm_name` (string) - Name of the virtual machine during creation. If not

0 commit comments

Comments
 (0)