google-app-engine - gcloud app deploy - 更新服务默认值失败,

创建了一个新项目,在第一次部署时我得到了这个:

    Updating service [default] (this may take several minutes)...failed.                                                                                                       
ERROR: (gcloud.app.deploy) Error Response: [13] Flex operation projects/primalexchange/regions/us-east1/operations/b5a5813a-14bf-43b6-af7f-e17b15866c4f error [INTERNAL]: An internal error occurred while processing task /appengine-flex-v1/insert_flex_deployment/flex_create_resources>2020-05-16T23:23:08.373Z4721.jc.14: Deployment Manager operation primalexchange/operation-1589671388926-5a5cc367252d6-eae4c5cb-bc5f1a6e errors: [code: "RESOURCE_ERROR"
location: "/deployments/aef-default-20200516t192110/resources/aef-default-20200516t192110"
message: "{\"ResourceType\":\"compute.beta.regionAutoscaler\",\"ResourceErrorCode\":\"403\",\"ResourceErrorMessage\":{\"code\":403,\"errors\":[{\"domain\":\"usageLimits\",\"message\":\"Exceeded limit \'QUOTA_FOR_INSTANCES\' on resource \'aef-default-20200516t192110\'. Limit: 8.0\",\"reason\":\"limitExceeded\"}],\"message\":\"Exceeded limit \'QUOTA_FOR_INSTANCES\' on resource \'aef-default-20200516t192110\'. Limit: 8.0\",\"statusMessage\":\"Forbidden\",\"requestPath\":\"https://compute.googleapis.com/compute/beta/projects/primalexchange/regions/us-east1/autoscalers\",\"httpMethod\":\"POST\"}}"

构建器中的构建显示为完全成功。

它在版本下显示我有一个版本,具有 0 个实例,100% 的流量分配,当您单击该版本时,它会将您带到我的站点并显示 404 错误。

可能是因为它说服务已停止,那可能是因为它没有“更新”。

我不认为这是“我的代码”的事情,因为我对我曾经成功部署在另一个项目下的版本进行了 git checkout,基本上相当于一个 hello world 应用程序,虽然它曾经成功,它现在失败了。此外,就在几天前,我在同一个项目下进行了另一个工作部署,但是当我使用更新的代码进行部署时,部署失败,并出现这个错误,“导致我删除整个项目并重新开始,并且现在我在这个新项目上遇到了同样的错误。我怎么知道不是我的代码首先导致了问题?由于我的代码和构建日志泄露了这一点,我的构建失败了。至此构建成功。构建中没有失败。

所以我转到了这个 url https://compute.googleapis.com/compute/beta/projects/primalexchange/regions/us-east1/autoscalers 其中指出:

{
  "error": {
    "code": 401,
    "message": "Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
    "errors": [
      {
        "message": "Login Required.",
        "domain": "global",
        "reason": "required",
        "location": "Authorization",
        "locationType": "header"
      }
    ],
    "status": "UNAUTHENTICATED"
  }
}

我不知道这是我的问题还是其他问题。我什至不知道这到底意味着什么。所以我确保我在“projectid.json”中获得了信任 并做了 export GOOGLE_APPLICATION_CREDENTIALS='projectid-2c8anumber842b4.json'

并且我断开了与我的 firebase 登录相关的代码。

我做了这些命令

gcloud services enable servicemanagement.googleapis.com
gcloud services enable servicecontrol.googleapis.com
gcloud services enable endpoints.googleapis.com

我不知道如何解决这个问题。我整个周末都在努力修复它。

我什么时候在 IAM 下使用配额,并查看了 us-east1 中自动缩放器的配额,我发现这并没有超过任何东西:

唯一限制为 8 的是 cpu,它说我在 2。

我不知道我搞砸了什么..

是的,已启用计费。

我刚遇到这个,也许这会让我有一些地方......

什么是授权 header ?为什么我第一次不需要它……或者这次我搞砸了什么。

我更改了我的代码,所以你得到的只是 hello world 的拼写错误,而且部署仍然失败:

import logging

from flask import Flask, jsonify, redirect, url_for
from flask import request, make_response
from flask import render_template
from image_upload import upload_blob

from google.cloud import storage
from google.cloud import datastore


from datetime import datetime
from cryptography.fernet import Fernet

from models.media import Media
from models.user import User


from google.cloud import ndb

import json

import random
from uuid import uuid4

from flask import Flask, make_response, request
from google.auth.transport import requests
import google.oauth2.id_token
# from google.cloud import firestore

from flask_wtf.csrf import CSRFProtect, generate_csrf
from werkzeug.utils import secure_filename
from werkzeug.exceptions import RequestEntityTooLarge

@app.route('/', methods=['GET'])
def hi():
    return "hellow world"


@app.errorhandler(500)
def server_error(e):
    logging.exception('An error occurred during a request.')
    return """
    An internal error occurred: <pre>{}</pre>
    See logs for full stacktrace.
    """.format(e), 500


if __name__ == '__main__':
    # This is used when running locally. Gunicorn is used to run the
    # application on Google App Engine. See entrypoint in app.yaml.

    app.run(host='127.0.0.1', port=8080, debug=True)

现在我更仔细地观察了这个问题,当我清楚地双重导入 flask 时,它是如何在本地运行的?

我会在删除它后尝试部署,但我怀疑这是问题所在,我很快就会回来发表另一篇关于这个问题的文章。

是的,那没关系。还是失败了。

这张图片来 self 开始的第三个项目。到目前为止,我一直在部署它。它因同样的错误而失败:

这是 App.yaml

runtime: python
api_version: '1'
env: flexible
threadsafe: true
handlers:
  - url: /static/(.*)
    application_readable: true
    static_files: __static__/static/\1
    require_matching_file: false
    upload: __static__/static/.*
  - url: /.*
    script: main.app
    secure: never
env_variables:
  SECRET_KEY: ____________
automatic_scaling:
  cool_down_period: 120s
  min_num_instances: 2
  max_num_instances: 20
  cpu_utilization:
    target_utilization: 0.5
network: {}
liveness_check:
  initial_delay_sec: 300
  check_interval_sec: 30
  timeout_sec: 4
  failure_threshold: 4
  success_threshold: 2
readiness_check:
  check_interval_sec: 5
  timeout_sec: 4
  failure_threshold: 2
  success_threshold: 2
  app_start_timeout_sec: 300

当我部署时,当我检查配额时,它看起来正在使用中的 IP 地址限制为 4,然后当我没有检查配额时,它又回到了 2。所以也许有人可以建议我如何设置我的 app.yaml 来避免这种情况?我对缩放的东西一无所知,所以我想做自动缩放,这个 app.yaml 基本上是默认设置。

没关系。我将配额增加到 6,但它仍然出错。

最佳答案

我不确定是什么原因造成的,但我能够通过将缩放设置为手动或在我的 app.yaml 中将 max_num_instances 设置为低于 8 来解决同样的问题:

automatic_scaling:
  min_num_instances: 1
  max_num_instances: 7

关于google-app-engine - gcloud app deploy - 更新服务默认值失败,代码为 13 超过实例限制的配额,以及 401 unathorized,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61845193/

相关文章:

forms - 如何判断表单字段在 vue.js 中是否无效

swiftui - 我怎样才能在 SwiftUI 中实现类似于 radiogroup 的一种可能选择

scala - 通过方法类型参数分配给类型成员的值打破了类型等价

ios - SecurityApplicationGroupIdentifier 的应用组返回 ni

swift - 在 Vapor 中使用原始 sql 返回条目总数

python - 将 Selenium 与 PyCharm CE 一起使用时的弃用问题

php - 如何解决 "The process has been signaled with sig

react-native - React 导航 5(导航到另一个堆栈屏幕)

c - 使用 for 循环初始化一个数组,并将最终数组元素的值作为条件(在 C 中)

typescript - 如何使用可选的唯一字符串定义数组 typescript 接口(interf