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 ERROR: rpc error: code = Unknown desc = googleapi: Error 400: Invalid request: Invalid request since instance is not running., invalid. Closes #243 #244

Merged
merged 1 commit into from
Jun 24, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions gcp/table_gcp_sql_database.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,12 @@ func listSQLDatabases(ctx context.Context, d *plugin.QueryData, h *plugin.Hydrat

// Get the details of Cloud SQL instance
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, nil
}

// Create service connection
service, err := CloudSQLAdminService(ctx, d)
Expand Down Expand Up @@ -164,6 +170,11 @@ func getSQLDatabase(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateD
name := d.KeyColumnQuals["name"].GetStringValue()
instanceName := d.KeyColumnQuals["instance_name"].GetStringValue()

// Return nil, if no input provided
if name == "" || instanceName == "" {
return nil, nil
}

// Get the region where the specified instance is created
instanceData, err := service.Instances.Get(project, instanceName).Do()
if err != nil {
Expand Down