Skip to content

Commit

Permalink
Fix failure when container no longer exists
Browse files Browse the repository at this point in the history
If you create a container with terraform and then delete it by hand,
terraform plan fails because client.ContainerState returns an error.

This bug is subtle because go allows partial variable shadowing when
using := to assign to multiple variables. (err is already declared as a
named return parameter.)
  • Loading branch information
Joel Jensen authored and sl1pm4t committed Mar 24, 2017
1 parent 5f5020b commit a4e398b
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lxd/resource_lxd_container.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,9 @@ func resourceLxdContainerExists(d *schema.ResourceData, meta interface{}) (exist
exists = false

ct, err := client.ContainerState(name)
if err != nil && err.Error() == "not found" {
err = nil
}
if err == nil && ct != nil {
exists = true
}
Expand Down

0 comments on commit a4e398b

Please sign in to comment.