Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ignore disk_size when disk_autoresize is true #36

Merged
merged 2 commits into from
Nov 28, 2023

Conversation

HeshamMeneisi
Copy link
Contributor

@HeshamMeneisi HeshamMeneisi commented Nov 27, 2023

Pull Request Submission Checklist

Please confirm that you have done the following before requesting reviews:

  • I have confirmed that the PR type is appropriate for the change I am making according to the Honest Pull Request and Commit Message Naming Conventions.
  • I have typed an adequate description that explains why I am making this change.
  • I have installed and run standard pre-commit hooks that lints and validates my code.

Description

  • Ignore settings_disk_size when settings_disk_autoresize is set to true to avoid failing to create a read-replica after the master instance has been auto-scaled up.

This change is Reviewable

@honestbank-bot
Copy link
Contributor

Terraform Format and Style 🖌success

Terraform Initialization ⚙️success

Terraform Validation 🤖Success! The configuration is valid.

Pusher: @HeshamMeneisi, Action: pull_request, Working Directory: ``, Workflow: terraform

@@ -69,7 +69,7 @@ resource "google_sql_database_instance" "instance" {
disk_autoresize = var.settings_disk_autoresize
disk_autoresize_limit = var.settings_disk_autoresize_limit
disk_type = var.settings_disk_type
disk_size = var.settings_disk_size
disk_size = var.settings_disk_autoresize ? null : var.settings_disk_size
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What should be starting value of disk? You should have the default value of disk as 10GB and ignore the changes to the attribute disk_size in the life_cycle hooks.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would we ignore the disk size @sunilhonest ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

life_cycle already ignores updates to disk_size. We don't need an initial value, it's optional and will default to the minimum size (10GB).

disk_size - (Optional) The size of data disk, in GB. Size of a running instance cannot be reduced but can be increased. The minimum value is 10GB.

If you think there's use-case where we need a manual initial size bigger than 10GB, we can only ignore it for read-replicas.

Copy link
Contributor Author

@HeshamMeneisi HeshamMeneisi Nov 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to ignoresettings_disk_size only for the read replica to allow a custom initial size for the master instance.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jai We have disk_autoresize enabled and hence GCP increases the disk size. TF apply will try to reset it to value passed(ex: 10 GB in our case) and hence we should ignore it in the life_cycle.

Copy link
Contributor

@jai jai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to update tests/check for this case?

@honestbank-bot
Copy link
Contributor

Terraform Format and Style 🖌success

Terraform Initialization ⚙️success

Terraform Validation 🤖Success! The configuration is valid.

Pusher: @HeshamMeneisi, Action: pull_request, Working Directory: ``, Workflow: terraform

@HeshamMeneisi
Copy link
Contributor Author

Do we need to update tests/check for this case?

@jai

The only test for this case is a scenario:

  • Create a DB instance with no read-replica
  • Scale it up over 10GB
  • Enable read-replica

Quite complicated and not really worth it just for this case IMO.

@HeshamMeneisi HeshamMeneisi merged commit 7a6f57e into main Nov 28, 2023
5 checks passed
@HeshamMeneisi HeshamMeneisi deleted the hesham/devop-3686-fix-the-submodule branch November 28, 2023 03:42
Copy link

🎉 This PR is included in version 1.10.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants