Skip to content

Commit

Permalink
Merge pull request #208 from Charliekenney23/fix/watchdog-enabled-by-…
Browse files Browse the repository at this point in the history
…default

fix watchdog_enabled state drift
  • Loading branch information
0xch4z committed Jan 28, 2021
2 parents b1730e2 + 0d86359 commit 15613ee
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 1.14.3 (January 28, 2021)

BUG FIXES:

* Fixed an issue with the `watchdog_enabled` field on `linode_instance` where on creation, Watchdog is assumed disabled by default and causes resources with the field set to `false` to need to update on the next apply.

## 1.14.2 (January 27, 2021)

FEATURES:
Expand Down
4 changes: 2 additions & 2 deletions linode/resource_linode_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -783,9 +783,9 @@ func resourceLinodeInstanceCreate(d *schema.ResourceData, meta interface{}) erro
updateOpts := linodego.InstanceUpdateOptions{}
doUpdate := false

if _, watchdogEnabledOk := d.GetOk("watchdog_enabled"); watchdogEnabledOk {
watchdogEnabled := d.Get("watchdog_enabled").(bool)
if !watchdogEnabled {
doUpdate = true
watchdogEnabled := d.Get("watchdog_enabled").(bool)
updateOpts.WatchdogEnabled = &watchdogEnabled
}

Expand Down
39 changes: 39 additions & 0 deletions linode/resource_linode_instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,31 @@ func TestAccLinodeInstance_dontPoll(t *testing.T) {
})
}

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

resName := "linode_instance.foobar"
instanceName := acctest.RandomWithPrefix("tf_test")
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckLinodeInstanceDestroy,
Steps: []resource.TestStep{
{
Config: testAccCheckLinodeInstanceWithWatchdogDisabled(instanceName),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(resName, "label", instanceName),
resource.TestCheckResourceAttr(resName, "watchdog_enabled", "false"),
),
},
{
Config: testAccCheckLinodeInstanceWithWatchdogDisabled(instanceName),
PlanOnly: true,
},
},
})
}

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

Expand Down Expand Up @@ -1709,6 +1734,20 @@ resource "linode_instance" "%s" {
`, identifier, instance)
}

func testAccCheckLinodeInstanceWithWatchdogDisabled(instance string) string {
return fmt.Sprintf(`
resource "linode_instance" "foobar" {
label = "%s"
region = "ca-central"
image = "linode/alpine3.12"
type = "g6-nanode-1"
root_pass = "terraform-test"
watchdog_enabled = false
}
`, instance)
}

func testAccCheckLinodeInstanceWithType(instance string, pubkey string, typ string) string {
return fmt.Sprintf(`
resource "linode_instance" "foobar" {
Expand Down

0 comments on commit 15613ee

Please sign in to comment.