Skip to content

Commit

Permalink
Fixed Error in gcp_sql_database if instance is not running Closes #584 (
Browse files Browse the repository at this point in the history
#586)


Co-authored-by: Ved misra <47312748+misraved@users.noreply.github.com>
  • Loading branch information
ParthaI and misraved committed Jun 6, 2024
1 parent 9b3326a commit 1b1324a
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions gcp/table_gcp_sql_database.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,15 @@ func listSQLDatabases(ctx context.Context, d *plugin.QueryData, h *plugin.Hydrat
instance := h.Item.(*sqladmin.DatabaseInstance)

// ERROR: rpc error: code = Unknown desc = googleapi: Error 400: Invalid request: Invalid request since instance is not running., invalid
// Return nil, if the instance not in running state
if instance.State != "RUNNABLE" {
// Return nil, if the instance is not in Runnable state.
// ActivationPolicy specifies when the instance is activated.
// - SQL_ACTIVATION_POLICY_UNSPECIFIED Unknown activation plan.
// - ALWAYS The instance is always up and running.
// - NEVER The instance never starts.
// - ON_DEMAND The instance starts upon receiving requests.(Deprecated)
// https://cloud.google.com/sql/docs/mysql/admin-api/rest/v1/instances#SqlActivationPolicy

if instance.State != "RUNNABLE" || instance.Settings.ActivationPolicy != "ALWAYS" {
return nil, nil
}

Expand Down

0 comments on commit 1b1324a

Please sign in to comment.