dotfiles's People
dotfiles's Issues
test
Community Note
- Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request.
- Please do not leave +1 or me too comments, they generate extra noise for issue followers and do not help prioritize the request.
- If you are interested in working on this issue or have submitted a pull request, please leave a comment.
- If an issue is assigned to the
modular-magician
user, it is either in the process of being autogenerated, or is planned to be autogenerated soon. If an issue is assigned to a user, that user is claiming responsibility for the issue. If an issue is assigned tohashibot
, a community member has claimed the issue already.
Terraform Version
Terraform v1.1.7
Affected Resource(s)
- google_sql_database_instance
Terraform Configuration Files
data "google_project" "project" {}
resource "google_sql_database_instance" "master" {
project = data.google_project.project.project_id
region = "asia-northeast1"
name = "mts-issue-test-master-001"
database_version = "MYSQL_5_7"
settings {
availability_type = "ZONAL"
disk_autoresize = true
disk_size = 10
disk_type = "PD_SSD"
tier = "db-f1-micro"
activation_policy = "ALWAYS"
pricing_plan = "PER_USE"
backup_configuration {
binary_log_enabled = true
enabled = true
location = "asia"
start_time = "18:00"
}
database_flags {
name = "character_set_server"
value = "utf8mb4"
}
}
}
resource "google_sql_database_instance" "replica" {
depends_on = [google_sql_database_instance.master]
name = "mts-issue-test-replica-001"
project = data.google_project.project.project_id
master_instance_name = "mts-issue-test-master-001"
region = "asia-northeast1"
database_version = "MYSQL_5_7"
replica_configuration {
failover_target = false
}
settings {
tier = "db-f1-micro"
availability_type = "ZONAL"
pricing_plan = "PER_USE"
disk_autoresize = true
disk_size = 10
backup_configuration {
binary_log_enabled = true
}
database_flags {
name = "slave_parallel_workers"
value = "3"
}
database_flags {
name = "slave_parallel_type"
value = "LOGICAL_CLOCK"
}
database_flags {
name = "slave_pending_jobs_size_max"
value = "536870912" # 512MB
}
}
}
Debug Output
when create new replica with binary logging (success)
https://gist.github.com/Climber22/09449433d0433104dfa7f8b74b04df42
when update replica (failed)
https://gist.github.com/Climber22/bc2abc80e52bb1bcb9e18f261180d6f7
Panic Output
Expected Behavior
When you run terraform apply
, updating Cloud SQL completes without error.
A read replica instance with binary logging enabled is created.
Actual Behavior
When you run terraform apply
again, updating Cloud SQL was failed with error message below.
│ Error: Error, failed to update instance settings for : googleapi: Error 400: Invalid request: Binary log must be disabled when backup is disabled or the instance must be a replica instance with a MySQL 5.7 or above version., invalid
│
│ with google_sql_database_instance.replica,
│ on cloudsql.tf line 35, in resource "google_sql_database_instance" "replica":
│ 35: resource "google_sql_database_instance" "replica" {
Terraform tries to update read replica (mysql 5.7), so error message above looks wrong.
I wrote information about the reason for this confusing error message (Reason of this issue
section)
Steps to Reproduce
When you firstly run terraform apply
, Cloud SQL instance will be successfully created without error.
(Thanks for This PR, when create new one, PATCH method is explicitly called to enable binary_logging for replica instance )
Then, if you add some diff, and run terraform apply
again, updating will be failed.
terraform apply
Important Factoids
Reason of this issue
I ask this issue for GCP support, and they said that “This is because the difference between PATCH and PUT method”.
In detail, PATCH method will evaluate diff between current status and request body, and apply only diff.
On the other hand, PUT method will try to overwrite all parameter with request body.
ref: https://cloud.google.com/sql/docs/mysql/admin-api/rest/v1beta4/instances/patch?hl=ja
Updates settings of a Cloud SQL instance. This method supports patch semantics.
In this case, when terraform try to update Cloud SQL by PUT method, there is no information to show “this is replica instance”.
To add this information, terraform should add instanceType
params and specify it as “READ_REPLICA_INSTANCE“
ref: https://cloud.google.com/sql/docs/mysql/admin-api/rest/v1beta4/instances?hl=ja#SqlInstanceType
How to resolve this issue
In my opinion, adding instanceType
field to google_sql_database_instance resource will solve this issue.
Additionally, If google_sql_database_instance has instanceType
field, creation of read replica with binary logging enabled can be done without PATCH method ( I’ve not tried it, just my hypothesis )
References
- #0000
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.