pkg/platform/packet: allow sequential terraform smart apply
@@ -203,7 +203,7 @@ func (c *config) Apply(ex *terraform.Executor) error {
return err
}
- return c.terraformSmartApply(ex, c.DNS)
+ return c.terraformSmartApply(ex, c.DNS, nil)
}
// ApplyWithoutParallel applies Terraform configuration without parallel execution.
@@ -212,7 +212,7 @@ func (c *config) ApplyWithoutParallel(ex *terraform.Executor) error {
return fmt.Errorf("initializing Terraform configuration: %w", err)
}
- return c.terraformSmartApply(ex, c.DNS)
+ return c.terraformSmartApply(ex, c.DNS, []string{"-parallelism=1"})
}
func (c *config) Destroy(ex *terraform.Executor) error {
@@ -355,25 +355,25 @@ func (c *config) resolveNodePrivateCIDRs() ([]string, hcl.Diagnostics) {
}
// terraformSmartApply applies cluster configuration.
-func (c *config) terraformSmartApply(ex *terraform.Executor, dc dns.Config) error {
+func (c *config) terraformSmartApply(ex *terraform.Executor, dc dns.Config, extraArgs []string) error {
// If the provider isn't manual, apply everything in a single step.
if dc.Provider != dns.Manual {
- return ex.Apply(nil)
+ return ex.Apply(extraArgs)
}
steps := []terraform.ExecutionStep{
// We need the controllers' IP addresses before we can apply the 'dns' module.
{
Description: "create controllers",
- Args: []string{
+ Args: append([]string{
"apply",
"-auto-approve",
fmt.Sprintf("-target=module.packet-%s.packet_device.controllers", c.ClusterName),
- },
+ }, extraArgs...),
},
{
Description: "construct DNS records",
- Args: []string{"apply", "-auto-approve", "-target=module.dns"},
+ Args: append([]string{"apply", "-auto-approve", "-target=module.dns"}, extraArgs...),
},
// Run `terraform refresh`. This is required in order to make the outputs from the previous
// apply operations available.
@@ -384,7 +384,7 @@ func (c *config) terraformSmartApply(ex *terraform.Executor, dc dns.Config) erro
},
{
Description: "complete infrastructure creation",
- Args: []string{"apply", "-auto-approve"},
+ Args: append([]string{"apply", "-auto-approve"}, extraArgs...),
PreExecutionHook: c.DNS.ManualConfigPrompt(),
},
}
