hashicorp / terraform-provider-mysql

Terraform MySQL provider – This Terraform provider is archived per our provider archiving process: https://terraform.io/docs/internals/archiving.html
https://www.terraform.io/docs/providers/mysql/
Mozilla Public License 2.0
61 stars 190 forks source link

Mysql provider: Malformed version: 10.1.21-MariaDB-1~xenial #6

Closed hashibot closed 6 years ago

hashibot commented 7 years ago

This issue was originally opened by @michalmedvecky as hashicorp/terraform#11935. It was migrated here as part of the provider split. The original body of the issue is below.


Terraform Version

Terraform v0.8.6

Affected Resource(s)

Terraform Configuration Files

provider "mysql" {
    endpoint = "somewhere.example.com:3306"
    username = "root"
    password = "password"
}

# Create a Database
resource "mysql_database" "test" {
    name = "test-deleteme"
}

Debug Output

terraform plan -state new.tfstate -target mysql_database.test
Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but
will not be persisted to local or remote state storage.

Error refreshing state: 1 error(s) occurred:

* Malformed version: 10.1.21-MariaDB-1~xenial

Expected Behavior

mysql_database.test: Creating...
  default_character_set: "" => "utf8"
  default_collation:     "" => "utf8_general_ci"
  name:                  "" => "test-deleteme"
mysql_database.test: Creation complete

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.

Actual Behavior

Weird error message appeared instead of creating the database

Steps to Reproduce

Important Factoids

The actual problem is in builtin/providers/mysql/provider.go around line 115:

return version.NewVersion(rows[0].Str(0))

and the function itself:

http://github.com/hashicorp/go-version/version.go:

// The raw regular expression string used for testing the validity
// of a version.
const VersionRegexpRaw string = `v?([0-9]+(\.[0-9]+)*?)` +
        `(-?([0-9A-Za-z\-]+(\.[0-9A-Za-z\-]+)*))?` +
        `(\+([0-9A-Za-z\-]+(\.[0-9A-Za-z\-]+)*))?` +
        `?`

I have no idea why only version numbers that match this regex are invalid.

bjcone commented 7 years ago

I'm seeing the same issue. Error output is:

captn3m0 commented 7 years ago

Seeing the same: 10.3.2-MariaDB-10.3.2+maria~jessie

astraios commented 7 years ago

Hi guys,

I have the same issue here:

Error: Error running plan: 1 error(s) occurred:

* provider.mysql: Malformed version: 10.2.10-MariaDB-10.2.10+maria~jessie-log
terraform version                                                                                                                                                          
Terraform v0.11.1
+ provider.mysql v1.0.0
captn3m0 commented 6 years ago

Just to update, this is broken yet again for me, because MariaDB decided to add : to their version string :angry:

Earlier: 10.3.2-MariaDB-10.3.2+maria~jessie Now: 10.3.6-MariaDB-1:10.3.6+maria~jessie

I'm planning to work around this by force setting the VERSION() response using the --version= flag.

Edit: Was fairly easy to do with Terraform/Docker

Update2: The --version fag requires atleast mariadb 10.2

Mayeu commented 6 years ago

I am also getting this issue with the very last container from MariaDB:

Error: Error refreshing state: 1 error(s) occurred:

* provider.mysql: Malformed version: 10.3.10-MariaDB-1:10.3.10+maria~bionic

Using the container: mariadb:10.3.10.