diff --git a/.web-docs/components/builder/digitalocean/README.md b/.web-docs/components/builder/digitalocean/README.md index 101d9a3..17c171a 100644 --- a/.web-docs/components/builder/digitalocean/README.md +++ b/.web-docs/components/builder/digitalocean/README.md @@ -82,17 +82,17 @@ each category, the available configuration keys are alphabetized. and report errors. When false, Packer will initiate the snapshot transfers and exit successfully without waiting for completion. Defaults to true. +- `transfer_timeout` (duration string | ex: "1h5m2s") - How long to wait for a snapshot to be transferred to an additional region + before timing out. The default transfer timeout is "30m" (valid time units + include `s` for seconds, `m` for minutes, and `h` for hours). + - `state_timeout` (duration string | ex: "1h5m2s") - The time to wait, as a duration string, for a droplet to enter a desired state (such as "active") before timing out. The default state timeout is "6m". - `snapshot_timeout` (duration string | ex: "1h5m2s") - How long to wait for an image to be published to the shared image - gallery before timing out. If your Packer build is failing on the - Publishing to Shared Image Gallery step with the error `Original Error: - context deadline exceeded`, but the image is present when you check your - Azure dashboard, then you probably need to increase this timeout from - its default of "60m" (valid time units include `s` for seconds, `m` for - minutes, and `h` for hours.) + gallery before timing out. The default snapshot timeout is "60m" (valid time + units include `s` for seconds, `m` for minutes, and `h` for hours). - `droplet_name` (string) - The name assigned to the droplet. DigitalOcean sets the hostname of the machine to this value. diff --git a/builder/digitalocean/builder.go b/builder/digitalocean/builder.go index f9ae20a..e2383ed 100644 --- a/builder/digitalocean/builder.go +++ b/builder/digitalocean/builder.go @@ -137,6 +137,7 @@ func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) new(stepPowerOff), &stepSnapshot{ snapshotTimeout: b.config.SnapshotTimeout, + transferTimeout: b.config.TransferTimeout, waitForSnapshotTransfer: *b.config.WaitSnapshotTransfer, }, } diff --git a/builder/digitalocean/config.go b/builder/digitalocean/config.go index c3da58f..df52c3a 100644 --- a/builder/digitalocean/config.go +++ b/builder/digitalocean/config.go @@ -79,17 +79,17 @@ type Config struct { // and report errors. When false, Packer will initiate the snapshot transfers // and exit successfully without waiting for completion. Defaults to true. WaitSnapshotTransfer *bool `mapstructure:"wait_snapshot_transfer" required:"false"` + // How long to wait for a snapshot to be transferred to an additional region + // before timing out. The default transfer timeout is "30m" (valid time units + // include `s` for seconds, `m` for minutes, and `h` for hours). + TransferTimeout time.Duration `mapstructure:"transfer_timeout" required:"false"` // The time to wait, as a duration string, for a // droplet to enter a desired state (such as "active") before timing out. The // default state timeout is "6m". StateTimeout time.Duration `mapstructure:"state_timeout" required:"false"` // How long to wait for an image to be published to the shared image - // gallery before timing out. If your Packer build is failing on the - // Publishing to Shared Image Gallery step with the error `Original Error: - // context deadline exceeded`, but the image is present when you check your - // Azure dashboard, then you probably need to increase this timeout from - // its default of "60m" (valid time units include `s` for seconds, `m` for - // minutes, and `h` for hours.) + // gallery before timing out. The default snapshot timeout is "60m" (valid time + // units include `s` for seconds, `m` for minutes, and `h` for hours). SnapshotTimeout time.Duration `mapstructure:"snapshot_timeout" required:"false"` // The name assigned to the droplet. DigitalOcean // sets the hostname of the machine to this value. @@ -215,6 +215,10 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) { c.SnapshotTimeout = 60 * time.Minute } + if c.TransferTimeout == 0 { + c.TransferTimeout = 30 * time.Minute + } + if c.WaitSnapshotTransfer == nil { c.WaitSnapshotTransfer = godo.PtrTo(true) } diff --git a/builder/digitalocean/config.hcl2spec.go b/builder/digitalocean/config.hcl2spec.go index 41b47e5..abb1871 100644 --- a/builder/digitalocean/config.hcl2spec.go +++ b/builder/digitalocean/config.hcl2spec.go @@ -82,6 +82,7 @@ type FlatConfig struct { SnapshotName *string `mapstructure:"snapshot_name" required:"false" cty:"snapshot_name" hcl:"snapshot_name"` SnapshotRegions []string `mapstructure:"snapshot_regions" required:"false" cty:"snapshot_regions" hcl:"snapshot_regions"` WaitSnapshotTransfer *bool `mapstructure:"wait_snapshot_transfer" required:"false" cty:"wait_snapshot_transfer" hcl:"wait_snapshot_transfer"` + TransferTimeout *string `mapstructure:"transfer_timeout" required:"false" cty:"transfer_timeout" hcl:"transfer_timeout"` StateTimeout *string `mapstructure:"state_timeout" required:"false" cty:"state_timeout" hcl:"state_timeout"` SnapshotTimeout *string `mapstructure:"snapshot_timeout" required:"false" cty:"snapshot_timeout" hcl:"snapshot_timeout"` DropletName *string `mapstructure:"droplet_name" required:"false" cty:"droplet_name" hcl:"droplet_name"` @@ -177,6 +178,7 @@ func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec { "snapshot_name": &hcldec.AttrSpec{Name: "snapshot_name", Type: cty.String, Required: false}, "snapshot_regions": &hcldec.AttrSpec{Name: "snapshot_regions", Type: cty.List(cty.String), Required: false}, "wait_snapshot_transfer": &hcldec.AttrSpec{Name: "wait_snapshot_transfer", Type: cty.Bool, Required: false}, + "transfer_timeout": &hcldec.AttrSpec{Name: "transfer_timeout", Type: cty.String, Required: false}, "state_timeout": &hcldec.AttrSpec{Name: "state_timeout", Type: cty.String, Required: false}, "snapshot_timeout": &hcldec.AttrSpec{Name: "snapshot_timeout", Type: cty.String, Required: false}, "droplet_name": &hcldec.AttrSpec{Name: "droplet_name", Type: cty.String, Required: false}, diff --git a/builder/digitalocean/step_snapshot.go b/builder/digitalocean/step_snapshot.go index 87277c8..ee6259e 100644 --- a/builder/digitalocean/step_snapshot.go +++ b/builder/digitalocean/step_snapshot.go @@ -15,6 +15,7 @@ import ( type stepSnapshot struct { snapshotTimeout time.Duration + transferTimeout time.Duration waitForSnapshotTransfer bool } @@ -114,7 +115,7 @@ func (s *stepSnapshot) Run(ctx context.Context, state multistep.StateBag) multis godo.ActionCompleted, imageId, imageTransfer.ID, - client, 20*time.Minute); err != nil { + client, s.transferTimeout); err != nil { return fmt.Errorf("Error waiting for snapshot transfer: %s", err) } ui.Say(fmt.Sprintf("Transfer to %s is complete.", region)) diff --git a/docs-partials/builder/digitalocean/Config-not-required.mdx b/docs-partials/builder/digitalocean/Config-not-required.mdx index cd1f36b..f2bb929 100644 --- a/docs-partials/builder/digitalocean/Config-not-required.mdx +++ b/docs-partials/builder/digitalocean/Config-not-required.mdx @@ -36,17 +36,17 @@ and report errors. When false, Packer will initiate the snapshot transfers and exit successfully without waiting for completion. Defaults to true. +- `transfer_timeout` (duration string | ex: "1h5m2s") - How long to wait for a snapshot to be transferred to an additional region + before timing out. The default transfer timeout is "30m" (valid time units + include `s` for seconds, `m` for minutes, and `h` for hours). + - `state_timeout` (duration string | ex: "1h5m2s") - The time to wait, as a duration string, for a droplet to enter a desired state (such as "active") before timing out. The default state timeout is "6m". - `snapshot_timeout` (duration string | ex: "1h5m2s") - How long to wait for an image to be published to the shared image - gallery before timing out. If your Packer build is failing on the - Publishing to Shared Image Gallery step with the error `Original Error: - context deadline exceeded`, but the image is present when you check your - Azure dashboard, then you probably need to increase this timeout from - its default of "60m" (valid time units include `s` for seconds, `m` for - minutes, and `h` for hours.) + gallery before timing out. The default snapshot timeout is "60m" (valid time + units include `s` for seconds, `m` for minutes, and `h` for hours). - `droplet_name` (string) - The name assigned to the droplet. DigitalOcean sets the hostname of the machine to this value.