petoju / terraform-provider-mysql

Terraform MySQL provider – unofficial fork
https://registry.terraform.io/providers/petoju/mysql
Mozilla Public License 2.0
63 stars 40 forks source link

DNS Resolution Failures on MacOS #66

Closed cablespaghetti closed 1 year ago

cablespaghetti commented 1 year ago

Terraform Version

Terraform v1.3.9
on darwin_arm64

Affected Resource(s)

All resources.

Terraform Configuration Files

resource "mysql_grant" "user_owner" {
  for_each   = mysql_user.user_owner
  user       = mysql_user.user_owner[each.key].user
  database   = mysql_database.db.name
  privileges = ["ALL PRIVILEGES"]
  host       = "%"
}

Expected Behavior

DNS resolved on MacOS with more complex configurations such as split DNS on a VPN.

Actual Behavior

I am seeing DNS resolution failures when connected to a VPN using split DNS on the latest version of MacOS. This seems to be a oddity in the way Go does DNS resolution when MacOS releases are cross-compiled from Linux or another OS.

After hanging for a really long time the error looks something like this:

╷
│ Error: failed to connect to MySQL: could not connect to server: dial tcp: lookup growth-blog.cloopht3pgme.eu-west-1.rds.amazonaws.com on [2a00:23c6:d098:4200:62be:b4ff:fe06:1372]:53: no such host

Steps to Reproduce

Run terraform apply using this module when a hostname is not resolvable using the primary DNS server on a MacOS machine, but is using split DNS configuration.

Important Factoids

Doing DNS resolution the "proper way" on MacOS gets an IP address:

❯ dscacheutil -q host -a name growth-blog.cloopht3pgme.eu-west-1.rds.amazonaws.com
name: growth-blog.cloopht3pgme.eu-west-1.rds.amazonaws.com
ip_address: 172.27.68.209

Other software such as the MySQL CLI and DBeaver also succeeds in connecting.

References

This issue is essentially the same problem https://github.com/Telmate/terraform-provider-proxmox/issues/665

This should be fixed if this provider can upgrade to Go 1.20: https://danp.net/posts/macos-dns-change-in-go-1-20/

petoju commented 1 year ago

@cablespaghetti could you please test it again? Just released version 3.0.31 should be handling that well.

thibautlemesle-fox commented 1 year ago

Hi @petoju,

FYI, it seems the darwin_arm64 has not been released.

I therefore think something was unexpected as it was the platform from which originated this ticket.

petoju commented 1 year ago

@thibautlemesle-fox this should be fixed.

Something probably went wrong with go update. I update also my local goreleaser and it finished fine now.

cablespaghetti commented 1 year ago

@petoju Apologies for the really slow response. I can confirm that the Go update has fixed this for me. Thank you! 🎉