question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

cloudsql - postgres

See original GitHub issue

I’ve been trying to extend the cloudsql mysql example to include POSTGRES options. So what is the deal? For me what fails is the failover section of code. I’ve tried (as you can see) to set the locationPreference because I read that needs to be different from the original. I’ve also set the availabilityType: REGIONAL for the master.

{% if properties['failover']['enabled'] %}
- name: {{ ID }}-failover
  type: sqladmin.v1beta4.instance
  properties:
    backendType: SECOND_GEN
    instanceType: READ_REPLICA_INSTANCE
    databaseVersion: {{ properties['cloudsql']['databaseVersion'] }}
    region: {{ properties['cloudsql']['region'] }}
    masterInstanceName: $(ref.{{ ID }}-master.name)
    replicaConfiguration:
      failoverTarget: true
    settings:
      tier: {{ properties['cloudsql']['tier'] }}
      locationPreference:
        zone: {{ properties['failover']['zone'] }}
{% endif %}

Any idea what might be the problem? the error isn’t very descriptive.

{"ResourceType":"sqladmin.v1beta4.instance","ResourceErrorCode":"400","ResourceErrorMessage":{"code":400,"errors":[{"domain":"global","message":"Invalid instance property.","reason":"invalidInstanceProperty"}],"message":"Invalid instance property.","statusMessage":"Bad Request","requestPath":"https://www.googleapis.com/sql/v1beta4/projects/wrkerz-test-3/instances","httpMethod":"POST"}}
screen shot 2018-10-10 at 9 43 41 pm

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
MrAliascommented, Nov 20, 2018

@jonbcampos I just (frustratingly) ran into this same error, but think I found a solution.

From looking at the project audit logs I was trying to deploy to it looked like this was a 500 response from Google rather than what the error leads you to believe would be a 400. This led me to manually enable High availability directly on the master in the console.

Unlike what I have seen with MySQL CloudSQL failover replicas, the failover was reported in the console as Enabled rather than a separate instance listing. I was able to describe the master and notice that it was described with the following attributes:

failoverReplica:
  available: true

Upon removing the failover instance from the template and adding the above properties the deployment worked. E.g.

resources:
- name: {{ ID }}-master
  type: sqladmin.v1beta4.instance
  properties:
    backendType: SECOND_GEN
    instanceType: CLOUD_SQL_INSTANCE
    databaseVersion: {{ properties['cloudsql']['databaseVersion'] }}
    region: {{ properties['cloudsql']['region'] }}
    settings:
      tier: {{ properties['cloudsql']['tier'] }}
      dataDiskSizeGb: {{ properties['cloudsql']['dataDiskSizeGb'] }}
      dataDiskType: {{ properties['cloudsql']['dataDiskType'] }}
      storageAutoResize: true
      replicationType: SYNCHRONOUS
      {% if properties['failover'] %}
      failoverReplica:
        available: true
      {% endif %}
      locationPreference:
        zone: {{ properties['cloudsql']['zone'] }}
      {% if properties['databaseFlags'] %}
      databaseFlags: {{ properties['databaseFlags'] }}
      {% endif %}
      activationPolicy: ALWAYS
      backupConfiguration:
        enabled: true
        binaryLogEnabled: true
        startTime: {{ properties['cloudsql']['backupStartTime'] }}
      ipConfiguration:
        authorizedNetworks: {{ properties['cloudsql']['authorizedNetworks'] }}

{% for i in range(properties['readReplicas']) %}
- name: {{ ID }}-rr-{{ i }}
  type: sqladmin.v1beta4.instance
  properties:
...

Ideally the example could be updated to work, but until then hopefully this helps.

0reactions
ryu1kncommented, Sep 6, 2019

Cool, thanks for the pointer @ocsig !

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cloud SQL for PostgreSQL documentation - Google Cloud
Cloud SQL for PostgreSQL is a fully-managed database service that helps you set up, maintain, manage, and administer your PostgreSQL relational databases on ......
Read more >
Setting Up Database Monitoring for Google Cloud SQL ...
Database Monitoring provides deep visibility into your Postgres databases by exposing query metrics, query samples, explain plans, database states, ...
Read more >
Database Access with PostgreSQL on GCP Cloud SQL
Database Access with PostgreSQL on GCP Cloud SQL · Step 1/7. Enable Cloud SQL IAM authentication · Step 2/7. Create a service account...
Read more >
Getting Started with Cloud SQL for PostgreSQL - YouTube
See how easy it is to get started with Google Cloud SQL for MySQL and PostgreSQL.
Read more >
Connecting a Google CloudSQL PostgreSQL Destination to ...
In this tutorial, we'll walk you through how to connect a Google CloudSQL PostgreSQL instance to Stitch as a destination. For more info...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found