Skip to content
This repository was archived by the owner on May 30, 2025. It is now read-only.
This repository was archived by the owner on May 30, 2025. It is now read-only.

GCP Postgres CloudSQL database observation writes replicaConfiguration which is only applicable for MySQL #499

Description

@jonnylangefeld

When creating a multi-region replicated postgres CloudSQL database, where the secondary instance has a reference via spec.forProvider.masterInstanceName, then the secondary instance gets the field spec.forProvider.replicaConfiguration set with a list entry of an empty struct by the provider. Because of this the secondary resource gets an error like the following and can never become ready:

observe failed: cannot run refresh: refresh failed: Missing required argument: "replica_configuration.0.verify_server_certificate": one of `replica_configuration.0.ca_certificate,replica_configuration.0.client_certificate,replica_configuration.0.client_key,replica_configuration.0.connect_retry_interval,replica_configuration.0.dump_file_path,replica_configuration.0.failover_target,replica_configuration.0.master_heartbeat_period,replica_configuration.0.password,replica_configuration.0.ssl_cipher,replica_configuration.0.username,replica_configuration.0.verify_server_certificate` must be specified

What happened?

The spec.forProvider.replicaConfiguration is set by the provider as I can see in the managedFields

        f:spec:
          f:forProvider:
            f:maintenanceVersion: {}
            f:project: {}
            f:replicaConfiguration: {}

The field looks like this on the secondary instance (the primary doesn't have this)

      replicaConfiguration:
      - {}

The replicaConfiguration says in the docs that it's only for MySQL:

// MysqlReplicaConfiguration: MySQL specific configuration when
// replicating from a MySQL on-premises primary instance. Replication
// configuration information such as the username, password,
// certificates, and keys are not stored in the instance metadata. The
// configuration information is used only to set up the replication
// connection and is stored by MySQL in a file named **master.info** in
// the data directory.
// +optional
MysqlReplicaConfiguration *MySqlReplicaConfiguration `json:"mysqlReplicaConfiguration,omitempty"`

How can we reproduce it?

create a composition with the following resources:

- name: database-instance
  base:
    # https://doc.crds.dev/github.com/upbound/provider-gcp/sql.gcp.upbound.io/DatabaseInstance/v1beta1
    apiVersion: sql.gcp.upbound.io/v1beta1
    kind: DatabaseInstance
    metadata:
      labels:
        provisioning.getcruise.com/instance: primary
    spec:
      forProvider:
        databaseVersion: POSTGRES_13
        region: "us-west1"
        settings:
          - tier: "db-f1-micro"
            availabilityType: "REGIONAL"
        deletionProtection: false
  patches:
    - type: CombineFromComposite
      combine:
        variables:
          - fromFieldPath: metadata.name
        strategy: string
        string:
          fmt: "%s-primary"
      toFieldPath: metadata.annotations[crossplane.io/external-name]
      policy:
        fromFieldPath: Required
- name: database-instance-secondary
  base:
    # https://doc.crds.dev/github.com/upbound/provider-gcp/sql.gcp.upbound.io/DatabaseInstance/v1beta1
    apiVersion: sql.gcp.upbound.io/v1beta1
    kind: DatabaseInstance
    metadata:
      labels:
        provisioning.getcruise.com/instance: secondary
    spec:
      forProvider:
        databaseVersion: POSTGRES_13
        region: "us-west2"
        settings:
          - tier: "db-f1-micro"
            availabilityType: "ZONAL"
        deletionProtection: false
  patches:
    - type: CombineFromComposite
      combine:
        variables:
          - fromFieldPath: metadata.name
        strategy: string
        string:
          fmt: "%s-secondary"
      toFieldPath: metadata.annotations[crossplane.io/external-name]
      policy:
        fromFieldPath: Required
    - type: CombineFromComposite
      combine:
        variables:
          - fromFieldPath: metadata.name
        strategy: string
        string:
          fmt: "%s-primary"
      toFieldPath: spec.forProvider.masterInstanceName
      policy:
        fromFieldPath: Required

What environment did it happen in?

Crossplane version: v1.10.1
GCP provider version: v0.27.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions