简体   繁体   中英

Error deploying a function from vscode cloud run extension

I am new to cloud computing and I'm trying to use google cloud to run some python codes. I use the vscode extension Cloud Run to deploy one function and run it on the cloud but I am getting the following error:

Could not create or update Cloud Run service scraping, Container Healthcheck failed. Revision 'scraping-00002-puv' is not ready and cannot serve traffic. The user-provided container failed to start and listen on the port defined provided by the PORT=8080 environment variable. Logs for this revision might contain more information.

Here are the steps I followed:

  • I created an application folder with my.py codes (scraping_functions.py) and the automatic launch.json that contains the following configurations:
{
  "configurations": [
    {
      "name": "Deploy Cloud Function",
      "type": "cloudcode.cloudfunctions",
      "request": "launch",
      "functionName": "scraping",
      "gen": "GEN_2",
      "revision": "scraping-00001-biy",
      "entryPoint": "hello_get",
      "testInput": "",
      "region": "europe-west1",
      "runtime": "python310"
    },
    {
      "name": "Cloud Run: Run/Debug Locally",
      "type": "cloudcode.cloudrun",
      "request": "launch",
      "build": {
        "docker": {
          "path": "Dockerfile"
        }
      },
      "image": "scraping",
      "service": {
        "name": "scraping",
        "containerPort": 8080,
        "resources": {
          "limits": {
            "memory": "256Mi"
          }
        }
      },
      "target": {
        "minikube": {}
      },
      "watch": true,
      "internalConsoleOptions": "neverOpen"
    },
    {
      "name": "Python: Current File",
      "type": "python",
      "request": "launch",
      "program": "${file}",
      "console": "integratedTerminal",
      "justMyCode": true
    },
    {
      "name": "Deploy Cloud Function",
      "type": "cloudcode.cloudfunctions",
      "request": "launch",
      "functionName": "function-scrape",
      "gen": "GEN_2",
      "entryPoint": "hello_get",
      "revision": "function-scrape-00003-vuh",
      "testInput": "",
      "region": "europe-west1",
      "runtime": "python310"
    },
    {
      "name": "Docker: Python - General",
      "type": "docker",
      "request": "launch",
      "preLaunchTask": "docker-run: debug",
      "python": {
        "pathMappings": [
          {
            "localRoot": "${workspaceFolder}",
            "remoteRoot": "/app"
          }
        ],
        "projectType": "general"
      }
    }
  ]
}

-I also have a dockerfile that was generated automatically from the vscode extension. -On the cloud run extension, I go to Cloud Functions and click deploy function. I also tried to run and debug but the same error appears...

  • The log file indicated in the error message does not seem to contain much more interesting information so I am not sure what can be causing the error.

The most common cause of this error is the container not listening for incoming HTTP requests on the port that is defined by Cloud Run and provided in the $PORT environment variable. This is a requirement for Cloud Run.

You can refer to this Documentation , which lists a series of steps to follow when encountering this error to fix the issue.

I have found this issue tracker raised for a similar issue which is still open. you can report there.

You can also check with these thread1 and thread2 which may help you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM