Skip to content
This repository has been archived by the owner on Mar 29, 2023. It is now read-only.

Commit

Permalink
Merge pull request #60 from gruntwork-io/yori-fix-cluster-recreate
Browse files Browse the repository at this point in the history
Fix cluster recreate on reapply
  • Loading branch information
yorinasub17 authored Sep 9, 2019
2 parents 37dbb08 + bb4c313 commit a056008
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
8 changes: 8 additions & 0 deletions modules/gke-cluster/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,14 @@ resource "google_container_cluster" "cluster" {
start_time = var.maintenance_start_time
}
}

lifecycle {
ignore_changes = [
# Since we provide `remove_default_node_pool = true`, the `node_config` is only relevant for a valid construction of
# the GKE cluster in the initial creation. As such, any changes to the `node_config` should be ignored.
"node_config",
]
}
}

# ---------------------------------------------------------------------------------------------------------------------
Expand Down
25 changes: 17 additions & 8 deletions test/gke_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,23 @@ import (
"github.com/gruntwork-io/terratest/modules/shell"
"github.com/gruntwork-io/terratest/modules/terraform"
test_structure "github.com/gruntwork-io/terratest/modules/test-structure"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func TestGKECluster(t *testing.T) {
t.Parallel()

// For convenience - uncomment these when doing local testing if you need to skip any sections.
//os.Setenv("SKIP_", "true") // Does not skip any sections, but avoids copying to a temp dir
//os.Setenv("SKIP_create_test_copy_of_examples", "true")
//os.Setenv("SKIP_create_terratest_options", "true")
//os.Setenv("SKIP_terraform_apply", "true")
//os.Setenv("SKIP_configure_kubectl", "true")
//os.Setenv("SKIP_wait_for_workers", "true")
//os.Setenv("SKIP_terraform_verify_plan_noop", "true")
//os.Setenv("SKIP_cleanup", "true")

var testcases = []struct {
testName string
exampleFolder string
Expand Down Expand Up @@ -48,14 +59,6 @@ func TestGKECluster(t *testing.T) {
t.Run(testCase.testName, func(t *testing.T) {
t.Parallel()

// Uncomment any of the following to skip that section during the test
//os.Setenv("SKIP_create_test_copy_of_examples", "true")
//os.Setenv("SKIP_create_terratest_options", "true")
//os.Setenv("SKIP_terraform_apply", "true")
//os.Setenv("SKIP_configure_kubectl", "true")
//os.Setenv("SKIP_wait_for_workers", "true")
//os.Setenv("SKIP_cleanup", "true")

// Create a directory path that won't conflict
workingDir := filepath.Join(".", "stages", testCase.testName)

Expand Down Expand Up @@ -121,6 +124,12 @@ func TestGKECluster(t *testing.T) {
kubectlOptions := test_structure.LoadKubectlOptions(t, workingDir)
verifyGkeNodesAreReady(t, kubectlOptions)
})

test_structure.RunTestStage(t, "terraform_verify_plan_noop", func() {
gkeClusterTerratestOptions := test_structure.LoadTerraformOptions(t, workingDir)
exitCode := terraform.InitAndPlan(t, gkeClusterTerratestOptions)
assert.Equal(t, exitCode, 0)
})
})
}
}

0 comments on commit a056008

Please sign in to comment.