Skip to content

Conversation

@zliang-akamai
Copy link
Member

📝 Description

Resolve #2085

✔️ How to Test

First Step

Apply this TF config:

provider "linode" {}

resource "linode_database_postgresql_v2" "this" {
  label = "mydatabase"
  engine_id = "postgresql/16"
  region = "us-mia"
  type = "g6-standard-1"
  allow_list = ["0.0.0.0/0"]
}

provider "postgresql" {
  host        = linode_database_postgresql_v2.this.host_primary
  port        = linode_database_postgresql_v2.this.port
  database    = "defaultdb"
  superuser   = false
  username    = linode_database_postgresql_v2.this.root_username
  password    = linode_database_postgresql_v2.this.root_password
  sslrootcert = linode_database_postgresql_v2.this.ca_cert
  sslmode     = "require"
}

resource "postgresql_role" "this" {
  name     = "test_role"
  password = "test_password"
}

Second Step

Change the allow_list, then apply again.

provider "linode" {}

resource "linode_database_postgresql_v2" "this" {
  label = "mydatabase"
  engine_id = "postgresql/16"
  region = "us-mia"
  type = "g6-standard-1"
  allow_list = ["YOUR_IP_ADDRESS"] // change this to your IP
}

provider "postgresql" {
  host        = linode_database_postgresql_v2.this.host_primary
  port        = linode_database_postgresql_v2.this.port
  database    = "defaultdb"
  superuser   = false
  username    = linode_database_postgresql_v2.this.root_username
  password    = linode_database_postgresql_v2.this.root_password
  sslrootcert = linode_database_postgresql_v2.this.ca_cert
  sslmode     = "require"
}

resource "postgresql_role" "this" {
  name     = "test_role"
  password = "test_password"
}

@zliang-akamai zliang-akamai requested a review from a team as a code owner November 16, 2025 18:15
@zliang-akamai zliang-akamai requested review from ezilber-akamai and vshanthe and removed request for a team November 16, 2025 18:15
@vshanthe vshanthe requested a review from Copilot November 18, 2025 07:28
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR resolves issue #2085 by applying the UseStateForUnknown() plan modifier to the host_primary and host_secondary computed attributes in database resources. This prevents unnecessary updates to dependent resources when the database configuration changes but the host values remain the same.

Key changes:

  • Added UseStateForUnknown() plan modifier to host attributes in PostgreSQL v2 database schema
  • Added UseStateForUnknown() plan modifier to host attributes in MySQL v2 database schema

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
linode/databasepostgresqlv2/framework_resource_schema.go Added plan modifiers to preserve host values during updates
linode/databasemysqlv2/framework_resource_schema.go Added plan modifiers to preserve host values during updates

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

@vshanthe vshanthe left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@ezilber-akamai ezilber-akamai left a comment

Choose a reason for hiding this comment

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

Thanks for fixing this!

@zliang-akamai
Copy link
Member Author

Blocked by #2176
We can't always use state for unknown because there are cases some attribute updates (e.g., changes of cluster_size may change the standby host (formerly secondary host)) will change host names. Also, secondary host has been renamed to standby host in the API response, so we may have to fix that before this PR.

@zliang-akamai zliang-akamai marked this pull request as draft November 19, 2025 18:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: linode_database_postgresql_v2 - host_primary unknown

3 participants