Cloud-sql-proxy go binary returns 404 - google-cloud-platform

I am trying to run cloud_sql_proxy installed as a binary from go get, but I always get a 404 Error.
I have followed the instructions at https://github.com/GoogleCloudPlatform/cloudsql-proxy, but with no luck.
$GOPATH/go/bin/cloud_sql_proxy -instances=project_name:region:instance_name=tcp:3306 -credential_file=/path/to/cloud-sql-proxy.json
The error I get:
2020/01/18 13:20:03 Rlimits for file descriptors set to {&{8500 9223372036854775807}}
2020/01/18 13:20:03 using credential file for authentication; email=<EMAIL>
2020/01/18 13:20:03 errors parsing config:
googleapi: got HTTP response code 404 with body: <!DOCTYPE html>
<html lang=en>
<meta charset=utf-8>
<meta name=viewport content="initial-scale=1, minimum-scale=1, width=device-width">
<title>Error 404 (Not Found)!!1</title>
<style>
*{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* > body{background:url(//www.google.com/images/errors/robot.png) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0}#media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}#logo{background:url(//www.google.com/images/branding/googlelogo/1x/googlelogo_color_150x54dp.png) no-repeat;margin-left:-5px}#media only screen and (min-resolution:192dpi){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat 0% 0%/100% 100%;-moz-border-image:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) 0}}#media only screen and (-webkit-min-device-pixel-ratio:2){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat;-webkit-background-size:100% 100%}}#logo{display:inline-block;height:54px;width:150px}
</style>
<a href=//www.google.com/><span id=logo aria-label=Google></span></a>
<p><b>404.</b> <ins>That’s an error.</ins>
<p>The requested URL <code>/sql/v1beta4/sql/v1beta4/projects/project_name/instances/instance_name?alt=json&prettyPrint=false</code> was not found on this server. <ins>That’s all we know.</ins>
However, if I get the binary from https://cloud.google.com/sql/docs/mysql/sql-proxy, then the connection if fine, proving that the instance address and the credential file work just fine. The service account has also the Cloud SQL Admin role, so that should be just fine as well.
I have cloned the repo, and tried to debug the code to see where exactly if fails, and of course, it fails at:
cmd/cloud_sql_proxy/proxy.go:268
sql.BasePath = *host
inst, err := sql.Instances.Get(proj, name).Do()
if err != nil {
return instanceConfig{}, err
}
The reason I am insisting on using the go-binary is that I want to re-use cloud_sql_proxy on Raspberry PI 3b+, and this seems to be the only option of getting cloud_sql_proxy working on ARM architecture.

Related

GCP Vertex AI Training Custom Job with BigQuery: The requested URL was not found on this server

I am following this Google CoLab tutorial and error on Step 5, custom model training job using a scikit-learn prebuilt container.
The training code works locally with the same environment as the container. But when I submit a training job, I get the following error:
The replica workerpool0-0 exited with a non-zero status of 1.
Traceback (most recent call last):
[...]
google.api_core.exceptions.NotFound: 404 POST https://bigquery.googleapis.com/bigquery/v2/projects//my-project/jobs?prettyPrint=false: <!DOCTYPE html>
<html lang=en>
<meta charset=utf-8>
<meta name=viewport content="initial-scale=1, minimum-scale=1, width=device-width">
<title>Error 404 (Not Found)!!1</title>
<style>
*{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* > body{background:url(//www.google.com/images/errors/robot.png) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0}#media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}#logo{background:url(//www.google.com/images/branding/googlelogo/1x/googlelogo_color_150x54dp.png) no-repeat;margin-left:-5px}#media only screen and (min-resolution:192dpi){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat 0% 0%/100% 100%;-moz-border-image:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) 0}}#media only screen and (-webkit-min-device-pixel-ratio:2){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat;-webkit-background-size:100% 100%}}#logo{display:inline-block;height:54px;width:150px}
</style>
<a href=//www.google.com/><span id=logo aria-label=Google></span></a>
<p><b>404.</b> <ins>That’s an error.</ins>
<p>The requested URL <code>/bigquery/v2/projects//my-project/jobs?prettyPrint=false</code> was not found on this server. <ins>That’s all we know.</ins>
(job ID: my-job-id)
-----Query Job SQL Follows-----
| . | . | . |
1:
2: SELECT * from titanic.survivors"
3:
| . | . | . |
It seems like a problem with google-api-core but I am confused as to why this fails in the cloud when it runs locally with the same dependencies.
The error https://bigquery.googleapis.com/bigquery/v2/projects//my-project/jobs?prettyPrint=false also does not look right because of the projects//my-project but the training job submits that request.

Cannot Deploy New ML Model Version to Google AI-Platform with custom prediction routine in Scikit-learn

I am trying to create a custom prediction routine on GCP AI-Platform using scikit-learn by following along the AI Platform tutorial.
When I get to the end Deploy your custom prediction routine, I create the model on the global endpoint as stated
gcloud ai-platform models create $MODEL_NAME \
--regions us-central1
However, I cannot use gcloud beta ai-platform versions create to create a model version. When I follow the next step:
gcloud components install beta
gcloud beta ai-platform versions create $VERSION_NAME \
--model $MODEL_NAME \
--runtime-version 2.1 \
--python-version 3.7 \
--origin gs://$BUCKET_NAME/custom_prediction_routine_tutorial/model/ \
--package-uris gs://$BUCKET_NAME/custom_prediction_routine_tutorial/my_custom_code-0.1.tar.gz \
--prediction-class predictor.MyPredictor
I get the following cryptic error (presumably meaning it cant find the model resource):
Using endpoint [https://us-central-ml.googleapis.com/]
ERROR: (gcloud.beta.ai-platform.versions.create) HTTPError 404: <!DOCTYPE html>
<html lang=en>
<meta charset=utf-8>
<meta name=viewport content="initial-scale=1, minimum-scale=1, width=device-width">
<title>Error 404 (Not Found)!!1</title>
<style>
*{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* > body{background:url(//www.google.com/images/errors/robot.png) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0}#media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}#logo{background:url(//www.google.com/images/branding/googlelogo/1x/googlelogo_color_150x54dp.png) no-repeat;margin-left:-5px}#media only screen and (min-resolution:192dpi){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat 0% 0%/100% 100%;-moz-border-image:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) 0}}#media only screen and (-webkit-min-device-pixel-ratio:2){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat;-webkit-background-size:100% 100%}}#logo{display:inline-block;height:54px;width:150px}
</style>
<a href=//www.google.com/><span id=logo aria-label=Google></span></a>
<p><b>404.</b> <ins>That’s an error.</ins>
<p>The requested URL <code>/v1/projects/test-project/models/IrisPredictor/versions</code> was not found on this server. <ins>That’s all we know.</ins>
Note that I have changed the python version from 3.5 -> 3.7 and runtime version from 1.13 -> 2.1 from the tutorial since that does work when I go to the gcp console in the browser and create a new version manually and using python 3.5 is not an option for me.
You should add the --region global flag to the command.
Also keep in mind that you can only deploy a custom prediction routine when you use a legacy (MLS1) machine type for your model version.
To specify the machine-type, you can pick between mls1-c1-m2 and mls1-c4-m2. For more information about the machine types read this doc

google_cloud_run_service return HTTP response 404 with body during creation

google_cloud_run_service.skills-online: Creating...
Error: Error creating Service: googleapi: got HTTP response code 404 with body:
<title>Error 404 (Not Found)!!1</title> <style> *{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* > body{background:url(//www.google.com/images/errors/robot.png) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0}#media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}#logo{background:url(//www.google.com/images/branding/googlelogo/1x/googlelogo_color_150x54dp.png) no-repeat;margin-left:-5px}#media only screen and (min-resolution:192dpi){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat 0% 0%/100% 100%;-moz-border-image:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) 0}}#media only screen and (-webkit-min-device-pixel-ratio:2){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat;-webkit-background-size:100% 100%}}#logo{display:inline-block;height:54px;width:150px} </style>
404. That’s an error.
The requested URL /apis/serving.knative.dev/v1/namespaces/skills-online/services was not found on this server. That’s all we know.
on main.tf line 11, in resource "google_cloud_run_service" "skills-online":
11: resource "google_cloud_run_service" "skills-online" {
creating google cloud run using infrastructure as code terraform
after $ terraform apply return HTTP response 404 with body, during the creation
Terraform Version
terraform version: v0.12.24
Google provider: v3.19.0
Terraform Configuration Files
provider "google" {
credentials = file("skills-online.json")
project = "skills-online"
region = "asia-south1"
}
resource "google_project_service" "run" {
service = "run.googleapis.com"
}
resource "google_cloud_run_service" "skills-online" {
name = "skills-online"
location = "asia-south1"
template {
spec {
containers {
image = "gcr.io/skills-online/imagename"
}
}
}
traffic {
percent = 100
latest_revision = true
}
}
terraform.tf file Affected Resource(s) google_cloud_run_service
Debug Output file
https://gist.github.com/Ameen-Alam/7765d293028a9fd7b29630edfb8e45a3
Expected Behavior
Cloud run service created
Important Factoids
image = "gcr.io/skills-online/imagename"
image = "gcr.io/skills-online/---------------"
due to security reason, I wrote the name of the image as a dummy
opened this issue by Ameen Alam
https://github.com/terraform-providers/terraform-provider-google/issues/6258
The google cloud run service is not available in asia-south1 region
which is why
"Error creating Service: googleapi: got HTTP response code 404 with body:"
is occurring, during creation google_cloud_run_service
I changed the region in my code, according to this list
https://cloud.google.com/run/docs/locations.
I have selected asia-east1 (Taiwan) region.
The error has been resolved.
closed this issue
https://github.com/terraform-providers/terraform-provider-google/issues/6258

Deploy a Dataflow with Terraform

I'm trying to deploy a Dataflow template with Terraform in GCloud.
There are several tutorial which include some terraform code. There are 2 options:Use module like the following link or use resource like the following link
With both options I have the following error:
Error: googleapi: got HTTP response code 502 with body: <!DOCTYPE html>
<html lang=en>
<meta charset=utf-8>
<meta name=viewport content="initial-scale=1, minimum-scale=1, width=device-width">
<title>Error 502 (Server Error)!!1</title>
<style>
*{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* > body{background:url(//www.google.com/images/errors/robot.png) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0}#media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}#logo{background:url(//www.google.com/images/branding/googlelogo/1x/googlelogo_color_150x54dp.png) no-repeat;margin-left:-5px}#media only screen and (min-resolution:192dpi){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat 0% 0%/100% 100%;-moz-border-image:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) 0}}#media only screen and (-webkit-min-device-pixel-ratio:2){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat;-webkit-background-size:100% 100%}}#logo{display:inline-block;height:54px;width:150px}
</style>
<a href=//www.google.com/><span id=logo aria-label=Google></span></a>
<p><b>502.</b> <ins>That’s an error.</ins>
<p>The server encountered a temporary error and could not complete your request.<p>Please try again in 30 seconds. <ins>That’s all we know.</ins>
on .terraform\modules\dataflow-job\terraform-google-modules-terraform-google-dataflow-722fc1d\main.tf line 17, in resource "google_dataflow_job" "dataflow_job":
17: resource "google_dataflow_job" "dataflow_job" {
I have tried running from my local computer and also from the cloud shell inside GCP.
The problem should be in the dataflow module, because I also tried to create other resource like a bucket and compute engine and it works without any problem.
The dataflow template is storaged in a bucket before I run the terraform script.
Terraform version: 0.12.19
The code:
main.tf
variable "project_id" {}
<...>
provider "google" {
version = "~> 2.8.0"
region = var.region
}
resource "google_dataflow_job" "dataflow_job" {
project = var.project_id
region = var.region
zone = "${var.region}-a"
name = var.project_name
on_delete = "cancel"
max_workers = var.max_workers
template_gcs_path = var.template_location
temp_gcs_location = "gs://${var.gcs_location}/tmp_dir"
service_account_email = var.controller_service_account_email
parameters = {
inputPubSub = var.input_PubSub_subscription
outputPubSub = var.output_PubSub_subscription
}
machine_type = var.machine_type
}
terraform.tfvars
<...>
template_location = "gs://www/zzz/template"
gcs_location= "gs://www/yyy"
<...>
To test if my code is wrong, I also tried directly from the code of link and also the same error.
Am I missing any dependence to add to the code?
Note that you have declared temp_gcs_location as "gs://${var.gcs_location}/tmp_dir" but then, in terraform.tvars you set gcs_location as "gs://www/yyy" (so the gs:// prefix appears twice). In any case, the job should be launched but then fail to create.
I made a minimal example with the following versions:
$ terraform --version
Terraform v0.12.20
+ provider.google v3.5.0
and using the Google-provided word count template. My main.tf file is:
variable "project_id" {
type = string
description = "GCP Project ID."
}
variable "gcs_location" {
type = string
description = "GCS bucket name (no gs:// prefix)."
}
provider "google" {
project = var.project_id
region = "us-central1"
zone = "us-central1-c"
}
resource "google_dataflow_job" "wordcount" {
name = "wordcount"
template_gcs_path = "gs://dataflow-templates/latest/Word_Count"
temp_gcs_location = "gs://${var.gcs_location}/temp"
parameters = {
inputFile = "gs://dataflow-samples/shakespeare/kinglear.txt"
output = "gs://${var.gcs_location}/wordcount/output"
}
}
and df.tfvars (change with the appropriate values):
project_id = "PROJECT_ID"
gcs_location = "BUCKET_NAME"
I run it with:
terraform apply -var-file="df.tvars"
and the job is successfully created:
google_dataflow_job.wordcount: Creating...
google_dataflow_job.wordcount: Creation complete after 3s [id=2020-01-27_...]
Let me know if this helps.

When loading a table to bigquery, google.auth.exceptions.RefreshError is raised everytime

I was loading a json lines file to bigquery. However, it failed because of this error :
File "/home/togayyazar/.local/lib/python3.7/site-packages/google/auth/compute_engine/credentials.py", line 102, in refresh
six.raise_from(new_exc, caught_exc)
File "<string>", line 3, in raise_from
google.auth.exceptions.RefreshError: ('Failed to retrieve http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/?recursive=true from the Google Compute Enginemetadata service. Status: 404 Response:\nb\'<!DOCTYPE html>\\n<html lang=en>\\n <meta charset=utf-8>\\n <meta name=viewport content="initial-scale=1, minimum-scale=1, width=device-width">\\n <title>Error 404 (Not Found)!!1</title>\\n <style>\\n *{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* > body{background:url(//www.google.com/images/errors/robot.png) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0}#media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}#logo{background:url(//www.google.com/images/branding/googlelogo/1x/googlelogo_color_150x54dp.png) no-repeat;margin-left:-5px}#media only screen and (min-resolution:192dpi){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat 0% 0%/100% 100%;-moz-border-image:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) 0}}#media only screen and (-webkit-min-device-pixel-ratio:2){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat;-webkit-background-size:100% 100%}}#logo{display:inline-block;height:54px;width:150px}\\n </style>\\n <a href=//www.google.com/><span id=logo aria-label=Google></span></a>\\n <p><b>404.</b> <ins>That\\xe2\\x80\\x99s an error.</ins>\\n <p>The requested URL <code>/computeMetadata/v1/instance/service-accounts/default/?recursive=true</code> was not found on this server. <ins>That\\xe2\\x80\\x99s all we know.</ins
I've changed credential json file with a new one but it did not work.
There is an issue with your credentials. It could be related to the authentication method you are using (service-account, user credentials), and how you are using it (from a BigQuery client library, command line tool).
It seems to me that you are using the bq command line tool (part of the google-cloud-sdk) from a Google Compute Engine VM. By default, you have access to a service-account within the instance, if you want to authenticate with another method, here are the instructions.
Looks like you might have a typo in your filename/path.
HTTP Error 404 is a NotFound error, meaning it couldn't find something.
Judging by the error in the html it couldn't find "/computeMetadata/v1/instance/service-accounts/default/?recursive=true" at the location where you are executing your command, rather than the credentials not having permissions.