Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CTX-601] chore: always retry terraform-destroy #1664

Merged
merged 1 commit into from
Jun 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions pkg/resource/aws/aws_eip_association_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package aws_test

import (
"testing"
"time"

"github.com/snyk/driftctl/test"
"github.com/snyk/driftctl/test/acceptance"
Expand All @@ -13,10 +12,6 @@ func TestAcc_Aws_EipAssociation(t *testing.T) {
TerraformVersion: "0.15.5",
Paths: []string{"./testdata/acc/aws_eip_association"},
Args: []string{"scan", "--deep"},
RetryDestroy: acceptance.RetryConfig{
Attempts: 3,
Delay: 5 * time.Second,
},
Checks: []acceptance.AccCheck{
{
Env: map[string]string{
Expand Down
4 changes: 0 additions & 4 deletions pkg/resource/aws/aws_eip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ func TestAcc_Aws_Eip(t *testing.T) {
TerraformVersion: "0.15.5",
Paths: []string{"./testdata/acc/aws_eip"},
Args: []string{"scan", "--deep"},
RetryDestroy: acceptance.RetryConfig{
Attempts: 3,
Delay: 5 * time.Second,
},
Checks: []acceptance.AccCheck{
{
Env: map[string]string{
Expand Down
4 changes: 0 additions & 4 deletions pkg/resource/aws/aws_internet_gateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ func TestAcc_Aws_InternetGateway(t *testing.T) {
TerraformVersion: "0.15.5",
Paths: []string{"./testdata/acc/aws_internet_gateway"},
Args: []string{"scan", "--deep"},
RetryDestroy: acceptance.RetryConfig{
Attempts: 3,
Delay: 5 * time.Second,
},
Checks: []acceptance.AccCheck{
{
Env: map[string]string{
Expand Down
5 changes: 0 additions & 5 deletions pkg/resource/aws/aws_route_table_association_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package aws_test

import (
"testing"
"time"

"github.com/snyk/driftctl/test"
"github.com/snyk/driftctl/test/acceptance"
Expand All @@ -13,10 +12,6 @@ func TestAcc_Aws_RouteTableAssociation(t *testing.T) {
TerraformVersion: "0.15.5",
Paths: []string{"./testdata/acc/aws_route_table_association"},
Args: []string{"scan", "--deep"},
RetryDestroy: acceptance.RetryConfig{
Attempts: 3,
Delay: 5 * time.Second,
},
Checks: []acceptance.AccCheck{
{
Env: map[string]string{
Expand Down
8 changes: 0 additions & 8 deletions pkg/resource/aws/aws_route_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ func TestAcc_Aws_Route(t *testing.T) {
TerraformVersion: "0.15.5",
Paths: []string{"./testdata/acc/aws_route"},
Args: []string{"scan", "--deep"},
RetryDestroy: acceptance.RetryConfig{
Attempts: 3,
Delay: 5 * time.Second,
},
Checks: []acceptance.AccCheck{
{
Env: map[string]string{
Expand All @@ -41,10 +37,6 @@ func TestAcc_Aws_Route_With_PrefixListId(t *testing.T) {
TerraformVersion: "0.15.5",
Paths: []string{"./testdata/acc/aws_route_with_prefix_list_id"},
Args: []string{"scan", "--deep"},
RetryDestroy: acceptance.RetryConfig{
Attempts: 3,
Delay: 5 * time.Second,
},
Checks: []acceptance.AccCheck{
{
Env: map[string]string{
Expand Down
12 changes: 1 addition & 11 deletions test/acceptance/testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@ type AccCheck struct {
Check func(result *test.ScanResult, stdout string, err error)
}

type RetryConfig struct {
Attempts uint8
Delay time.Duration
}

type AccTestCase struct {
DoNotRunTerraform bool
TerraformVersion string
Expand All @@ -60,7 +55,6 @@ type AccTestCase struct {
originalEnv []string
tf map[string]*tfexec.Terraform
ShouldRefreshBeforeDestroy bool
RetryDestroy RetryConfig
}

func (c *AccTestCase) initTerraformExecutor() error {
Expand Down Expand Up @@ -214,11 +208,7 @@ func (c *AccTestCase) terraformApply() error {
}

func (c *AccTestCase) terraformDestroy() error {
if c.RetryDestroy.Attempts == 0 {
return c.doDestroy()
}
r := retrier.New(retrier.ConstantBackoff(int(c.RetryDestroy.Attempts), c.RetryDestroy.Delay), nil)

r := retrier.New(retrier.ExponentialBackoff(10, time.Second*5), nil)
return r.Run(c.doDestroy)

}
Expand Down