All Questions
Tagged with google-cloud-run python
262 questions
30
votes
5
answers
37k
views
"[CRITICAL] WORKER TIMEOUT" in logs when running "Hello Cloud Run with Python" from GCP Setup Docs
Following the tutorial here I have the following 2 files:
app.py
from flask import Flask, request
app = Flask(__name__)
@app.route('/', methods=['GET'])
def hello():
"""Return a ...
27
votes
7
answers
13k
views
How to generate a Blob signed url in Google Cloud Run?
Under Google Cloud Run, you can select which service account your container is running. Using the default compute service account fails to generate a signed url.
The work around listed here works on ...
15
votes
5
answers
20k
views
Simplest way to perform logging from Google Cloud Run
I followed this guide https://firebase.google.com/docs/hosting/cloud-run to setup cloud run docker.
Then I tried to follow this guide https://cloud.google.com/run/docs/logging to perform a simple log. ...
14
votes
1
answer
7k
views
Gunicorn (with Flask) parameters for Google Cloud Run (GCR) - what to put in Dockerfile? [closed]
Looking for some guidance from people with practical GCR experience. How do you get on with this?
I run a Docker container (approx. 670mb in size) in Google Cloud Run, inside is my Python server based ...
8
votes
1
answer
6k
views
How to increase the memory limits in Google Cloud Run?
I'm building a simple Flask based app using Cloud Run + Cloud Firestore. There is one method that brings a lot of data, and the logs are showing this error:
`Memory limit of 244M exceeded with 248M ...
8
votes
1
answer
4k
views
Google Cloud Run does not load .env file
I spend the last couple of days trying to find what I have done wrong but I am still not able to figure out because I am able to run the app locally using flask run and also using Docker using docker-...
7
votes
1
answer
16k
views
Google cloud run and web scraping with selenium
I am currently trying to get a web scraping script to be used on Google Cloud to import data to the Google Sheets API. I had a quick look around and Google Cloud Run seems that it may be able to do ...
7
votes
2
answers
2k
views
Docker image deploys locally but fails on Google Cloud Run
Here is my Dockerfile:
# Use lightweight Python image
FROM python:3.9-slim
ARG DOCKER_ENV
# PYTHONFAULTHANDLER=1 - Display trace if a sefault occurs.
# PYTHONUNBUFFERED=1 - Allow statements and log ...
7
votes
0
answers
2k
views
Google Cloud Run with gunicorn/flask - getting intermittent 504s
I run a Flask application on Cloud Run with gunicorn and worker type gthread. On low level, this API just writes/retrieves entries from Datastore and Pubsub so all operations are light. The traffic is ...
6
votes
2
answers
1k
views
Cloud Run Flask API container running shutit enters a sleep loop
The issue has appeared recently and the previously healthy container now enters a sleep loop when a shutit session is being created. The issue occurs only on Cloud Run and not locally.
Minimum ...
5
votes
4
answers
4k
views
How can I get the user's IP-Address in my Cloud-Run Flask app?
I have a Flask app running via Google Cloud Run and I need to know the user's IP-Address.
I am using gunicorn as my Server.
I have tried the following code:
request.remote_addr
request.environ['...
5
votes
1
answer
1k
views
Dash app cannot find pages folder when deploying on GCP using gunicorn
I am trying to deploy my dash app which uses dash_extensions, Dash_proxy and has multiple pages in the pages folder on GCP cloud run using gunicorn but the app cannot find the pages folder. It works ...
4
votes
2
answers
14k
views
Docker Error - CommandError: "0.0.0.0:" is not a valid port number or address:port pair
So I have a docker file, that I intend to build and push to Google Cloud Run and it looks like this:
# pull official base image
FROM python:3.7-slim
# set work directory
WORKDIR /usr/src/app
# set ...
4
votes
2
answers
4k
views
Google Cloud Run: Calling from outside GCP
I'm trying to access a secure cloud run service. If I try from my machine with the SDK it works fine:
curl --header "Authorization: Bearer $(gcloud auth print-identity-token)"
However, I can not get ...
4
votes
1
answer
4k
views
Where can I find python print statements in Cloud Run docker instances?
If I am running a container within Cloud Run and do a print statement in my python code. Where can I view it? Cloud logs seem to show logs for the contain itself(build, etc)?
to debug my code often I ...
4
votes
2
answers
6k
views
How to run a "hello world" python script with Google Cloud Run
Forgive my ignorance..
I'm trying to learn how to schedule python scripts with Google Cloud. After a bit of research, I've seen many people suggest Docker + Google Cloud Run + Cloud Scheduler. I've ...
4
votes
1
answer
819
views
Which production server to use for Python applications in Cloud Run?
I want to use GCP cloud run as a technology to run my python flask app, so I have to dockerize it. Most of examples I've seen are either using built in flask server or gunicorn server as an ENTRYPOINT,...
4
votes
1
answer
2k
views
Discord Bot + Google Cloud Run: "Container failed to start."
I'm attempting to deploy a simple Discord bot written in python and containerized via Docker to Google Cloud Run.
The Dockerfile is very simple:
FROM python:3.9
WORKDIR /app
COPY requirements.txt ...
4
votes
1
answer
2k
views
Google Cloud Run Jobs logging splits Exception MESSAGES with multiple lines into multiple log entries
Several days ago, a Python RuntimeError was raised in one of my company's Cloud Run jobs which stopped it.
Cloud Run's logging, unfortunately, handled that RuntimeError in a bad way.
It correctly put ...
4
votes
2
answers
2k
views
How can I trigger same Cloud Run job/service using different arguments?
I'm trying to make a scrapy scraper work using cloud run. The main idea is that every 20 minutes a cloud scheduler cron should trigger the web scraper and get data from different sites. All sites have ...
4
votes
1
answer
5k
views
Google Cloud Run - how to set 'Access-Control-Allow-Origin' header?
I'm setting up my first application on Google Cloud Run and now want to connect the server with my website. However I've run into CORS issues.
I tried fixing it in my code by using flask_cors. I can ...
4
votes
1
answer
977
views
GCF function testing in python: failed to fetch builder image
I regularly use Google Cloud Run to write functions using Python. When testing I am usually able to click "Test Function" at the top of the page which opens a console window at the bottom of ...
4
votes
0
answers
1k
views
Cloud Run suddenly starts timing out when processing any request
We've been running a backend application on Cloud Run for about a year and a half now, and a month ago it suddenly stopped properly handling all requests at seemingly random times (about every couple ...
4
votes
1
answer
3k
views
Getting AttributeError: module 'proto' has no attribute 'module'
I'm trying to deploy a gRPC server to Cloud Run using Docker to create associated image. I am getting the following error when called:
[] Traceback (most recent call last):
> [] File "...
3
votes
4
answers
6k
views
What is the current maximum timeout for a GCP Cloud Run app invoked by Cloud Scheduler
I am looking at using Cloud Scheduler to trigger daily execution of a python app on Cloud Run. The app pulls data from a third party API and inserts it into BigQuery. The only issue is, that ...
3
votes
2
answers
2k
views
Specify Python version on Cloud Run Buildpack
I am deploying a web app on Cloud Run using the automated Cloud Build "Buildpack" option (as explained here); hence not having to create a Docker File.
I would like to deploy the app using ...
3
votes
2
answers
4k
views
How to download large file from Cloud Run in Django
I have Django project on Cloud Run. When I download small file from page which has below code.
def download_view(request,pk):
file_path = f'media/{pk}.mp3'
name = f'{pk}.mp3'
with open(...
3
votes
2
answers
15k
views
Cloud Endpoints returning 401 Jwt issuer is not configured
I am trying to set up service to service authentication so an external application can make requests to a Cloud Run application (behind a Cloud Endpoints API gateway).
I have followed the Cloud ...
3
votes
1
answer
2k
views
Execute very long-running tasks using Google Cloud
I have been using Google CLoud for a few weeks now and I am facing a big problem for my limited GCP knowledge.
I have a python project whos goal is to "scrape" datas from a website using it'...
3
votes
1
answer
1k
views
Initialise fastapi web service fully before listening on port
I have a fastapi web app which is running inside of a docker container. The web app hosts multiple machine learning models which on startup it needs to read into memory. This process can take around ...
3
votes
2
answers
1k
views
After adding nltk.download('words') Google Cloud Run
I have a Google Cloud Run app run on GCP. After adding the following modification, the app crashed:
nltk.download('stopwords')
nltk.download('averaged_perceptron_tagger')
nltk.download('...
3
votes
2
answers
531
views
Testing Cloud Run for a Non HTTP use usecase
I'm just getting started with GCP and starting to explore cloud run a bit.
I'm using cloud run for NON HTTP purpose, i.e that I do not want to build a web application.I'm simply trying to take a ...
3
votes
2
answers
597
views
Google Cloud Run for Anthos (Knative) not setting X-Forwarded-Proto header correctly on https requests
I have a django application running in Google cloud run (in a Kube cluster), via Docker served by uwsgi (but I've tried manage.py runserver and it's the same). By default cloud run accepts connections ...
3
votes
1
answer
1k
views
Create a cloud run job which shares code with a cloud run service
I see google cloud run now has jobs which is amazing!
What I would like to achieve is to have a main container serving web traffic and also a job container which can be activated based on some ...
3
votes
3
answers
3k
views
How can I grant a Cloud Run service access to service account's credentials without the key file?
I'm developing a Cloud Run Service that accesses different Google APIs using a service account's secrets file with the following python 3 code:
from google.oauth2 import service_account
credentials = ...
3
votes
1
answer
864
views
Why does sqlite (read-only) work running in Docker locally but not in Google Cloud Run?
I have a substantial sqlite database file (~2 million rows) which I query in a Rust application using rusqlite on Google Cloud Run, using a bundled version of sqlite.
I do not add or write data, and ...
3
votes
1
answer
678
views
gRPC API server via Python can't worked
I have developed the gRPC API server via Python, Then build it to container and deploy on Cloud Run,
Which my gRPC server are integrating with TensorFlow application. Actually the tensorflow for image ...
3
votes
0
answers
1k
views
Docker on Google Cloud Run - Python Multiprocessing: OSError: [Errno 38] Function not implemented
I'm running a simple python web scraping script within a docker container on Cloud Run, it is invoked from the Cloud Scheduler and gives an error:
File "/usr/local/lib/python3.8/multiprocessing/...
3
votes
0
answers
3k
views
unable to run selenium chrome-driver on google-cloud-run
I have a docker container that runs a working selenium chrome driver script, however when the same image is deployed to Google Cloud Run I encounter the following error.
webdriver.Chrome('/home/...
2
votes
1
answer
4k
views
Execute GCP Cloud Run job with environment variable override using Python client
I am trying to trigger a GCP Cloud Run job from a python script following the run_job documentation (https://cloud.google.com/python/docs/reference/run/latest/google.cloud.run_v2.services.jobs....
2
votes
2
answers
2k
views
Do I need to clean/remove the images created on deployments of my Cloud Run instance?
I have a Cloud Run instance up and running on my Google Cloud Platform project.
Whenever I do any changes to my main.py file, I perform the following steps:
gcloud builds submit --tag ${CONTAINER}
...
2
votes
2
answers
2k
views
Tracing a Python gRPC server deployed on Cloud Run with OpenTelemetry
I'm running a Python gRPC server on Cloud Run and attempting to add instrumentation to capture trace information. I have a basic setup currently, however I'm having trouble making use of propagation ...
2
votes
2
answers
789
views
Cloud Run / Docker loading large files for ML prediction
I am trying to serve a fairly large model (1GB) from a Flask powered docker container on Google Cloud Run.
I am trying to figure out the best way load the pickle / joblib model files - so as to reduce ...
2
votes
2
answers
3k
views
Accessing and using csv file from Cloud Storage in Cloud Run instance
I know how to download the file from cloud storage within the cloud run instance. But, I can't find the syntax for reading the file in python. I'm looking to immediately convert the csv file into a ...
2
votes
1
answer
2k
views
Cloud Run Client Request IP address gets overridden by proxy Python Fast API
There is an issue of getting real user request IP address inside web application that is running on Cloud Run service. By some reason the web application obtains the same IP address for all users ...
2
votes
1
answer
2k
views
How do I run my Cloud Run service locally?
I have the following simple Cloud Run service from the Python quickstart:
app.py:
import os
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello_world():
return 'Hello ...
2
votes
1
answer
195
views
Cloud Run in Google Cloud doesn't recognize time.sleep() in my Python script
I have a Cloud Run service running a Python script in a Docker container.
Running the script on a VM in GCP or locally works fine. It recognizes the time.sleep() in my script.
But Cloud Run does not. ...
2
votes
1
answer
389
views
Django app on Cloud Run infinite redirects (301)
I am trying to deploy a Django app in a container to Cloud Run. I have it running well locally using Docker. However, when I deploy it to Cloud Run, I get infinite 301 redirects. The Cloud Run logs do ...
2
votes
2
answers
881
views
Python script scheduling on google cloud
I'm facing this issue where i have a python script that needs to be run every day at 00:00am on google cloud, possibly using Google Cloud Run, what I'd like to know is something quite specific to ...
2
votes
1
answer
3k
views
Failed to install jsonnet on google cloud run
I am trying to build a image for deploying a code on google cloud run with the jsonnet python package, it fails to install jsonnet with following error. Any ideas what can I do to resolve this?
...