【问题标题】:Gcloud preview app can't parse my yamlGcloud 预览应用程序无法解析我的 yaml
【发布时间】:2015-10-20 06:03:49
【问题描述】:

我正在尝试让 gcloud 命令工作,以便我可以在 Jenkins 中运行它,但我遇到了麻烦。

我在跑步

gcloud --project=hv-match preview app deploy -q app.yaml --promote --verbosity debug --bucket gs://hv-match.appspot.com --version=1

这就产生了:

DEBUG: Running gcloud.preview.app.deploy with Namespace(__calliope_internal_deepest_parser=ArgumentParser(prog='
gcloud.preview.app.deploy', usage=None, description="*(BETA)* This command is used to deploy both code and confi
guration to the App Engine\nserver.  As an input it takes one or more ``DEPLOYABLES'' that should be\nuploaded. 
 A ``DEPLOYABLE'' can be a module's .yaml file or a configuration's\n.yaml file.", version=None, formatter_class
=<class 'argparse.HelpFormatter'>, conflict_handler='error', add_help=False), account=None, bucket='gs://hv-matc
h.appspot.com', cmd_func=<bound method Command.Run of <googlecloudsdk.calliope.backend.Command object at 0x1cd01
10>>, command_path=['gcloud', 'preview', 'app', 'deploy'], configuration=None, deployables=['app.yaml'], docker_
build=None, document=None, env_vars=None, force=False, format=None, h=None, help=None, http_timeout=None, log_ht
tp=None, project='hv-match', promote=True, quiet=True, server=None, set_default=None, stop_previous_version=None
, trace_email=None, trace_log=False, trace_token=None, user_output_enabled=None, verbosity='debug', version='1')
.
ERROR: Argument [app.yaml] is not a valid deployable file.
DEBUG: (gcloud.preview.app.deploy) Errors occurred while parsing the App Engine app configuration.
Traceback (most recent call last):
  File "/usr/local/bin/../share/google/google-cloud-sdk/./lib/googlecloudsdk/calliope/cli.py", line 589, in Execute
    result = args.cmd_func(cli=self, args=args)
  File "/usr/local/bin/../share/google/google-cloud-sdk/./lib/googlecloudsdk/calliope/backend.py", line 1221, in Run
    resources = command_instance.Run(args)
  File "/usr/local/bin/../share/google/google-cloud-sdk/./lib/googlecloudsdk/appengine/app_commands/deploy.py", line 184, in Run
    args.deployables, project, args.version or util.GenerateVersionId())
  File "/usr/local/bin/../share/google/google-cloud-sdk/./lib/googlecloudsdk/appengine/lib/yaml_parsing.py", line 351, in __init__
    raise AppConfigSetLoadError()
AppConfigSetLoadError: Errors occurred while parsing the App Engine app configuration.
ERROR: (gcloud.preview.app.deploy) Errors occurred while parsing the App Engine app configuration.

这是我的 app.yaml:

runtime: php55
api_version: 1
threadsafe: yes

handlers:
- url: /favicon\.ico
  static_files: favicon.ico
  upload: favicon\.ico
- url: /phpinfo.php
  script: phpinfo.php  
- url: /tabell.php
  script: tabell.php
- url: /lineup.php
  script: lineup.php
- url: /nextgame.php
  script: nextgame.php
- url: /pregame.php
  script: pregame.php
- url: /forumtext.php
  script: forumtext.php
- url: /livetabell.php
  script: livetabell.php
- url: /abbreviation.php
  script: abbreviation.php
- url: /SaveData.php
  script: SaveData.php
  login: admin
- url: /test.html
  script: test.html
- url: .*
  script: main.php
env_variables:
  apfykey: '*string-with-api-key*'

从谷歌搜索到它可能与欧洲/美国问题有关,我不确定我的项目在哪里被 lozalized,但我的虚拟机至少在美国。还是可以是别的?

提前感谢您的帮助!

使用 JENKINS 输出进行编辑

当我通过 Jenkins Execute Shell 运行上面的命令时,我得到了这个输出:

DEBUG: Running gcloud.preview.app.deploy with Namespace(__calliope_internal_deepest_parser=ArgumentParser(prog='gcloud.preview.app.deploy', usage=None, description="*(BETA)* This command is used to deploy both code and configuration to the App Engine\nserver.
As an input it takes one or more ``DEPLOYABLES'' that should be\nuploaded.  A ``DEPLOYABLE'' can be a module's .yaml file or a configuration's\n.yaml file.", version=None, formatter_class=<class 'argparse.HelpFormatter'>, conflict_handler='error',
add_help=False), account=None, bucket='gs://hv-match.appspot.com', cmd_func=<bound method Command.Run of <googlecloudsdk.calliope.backend.Command object at 0x320c210>>, command_path=['gcloud', 'preview', 'app', 'deploy'], configuration=None,
deployables=['app.yaml'], docker_build=None, document=None, env_vars=None, force=False, format=None, h=None, help=None, http_timeout=None, log_http=None, project='hv-match', promote=True, quiet=True, server=None, set_default=None, stop_previous_version=None,
trace_email=None, trace_log=False, trace_token=None, user_output_enabled=None, verbosity='debug', version='1').
DEBUG: API endpoint: [https://appengine.googleapis.com/], API version: [v1beta4]
You are about to deploy the following modules:
 - hv-match/default (from [/opt/bitnami/apps/jenkins/jenkins_home/jobs/Deploy/workspace/app.yaml])
     Deployed URL: [https://hv-match.appspot.com]

Beginning deployment...
DEBUG: Using bucket [gs://hv-match.appspot.com].
INFO: Ignoring directory [.git]: Directory matches ignore regex.
INFO: Ignoring file [.gitignore]: File matches ignore regex.
DEBUG: Generated deployment manifest: "{
    *** removed for readability ***
}"
Copying files to Google Cloud Storage...
Synchronizing files to [gs://hv-match.appspot.com].
DEBUG: Running command: [/bin/bash /usr/local/share/google/google-cloud-sdk/bin/gsutil -m rsync -R -c /tmp/tmpPvL87s gs://hv-match.appspot.com], Env: [None]
Updating module [default]...DEBUG: Converted YAML to JSON: "{
    *** removed for readability ***
}"

Updating module [default]...failed.
DEBUG: (gcloud.preview.app.deploy) Error Response: [403] Request had insufficient authentication scopes.
Traceback (most recent call last):
  File "/usr/local/bin/../share/google/google-cloud-sdk/./lib/googlecloudsdk/calliope/cli.py", line 589, in Execute
    result = args.cmd_func(cli=self, args=args)
  File "/usr/local/bin/../share/google/google-cloud-sdk/./lib/googlecloudsdk/calliope/backend.py", line 1221, in Run
    resources = command_instance.Run(args)
  File "/usr/local/bin/../share/google/google-cloud-sdk/./lib/googlecloudsdk/appengine/app_commands/deploy.py", line 250, in Run
    images.get(module))
  File "/usr/local/bin/../share/google/google-cloud-sdk/./lib/googlecloudsdk/appengine/lib/appengine_api_client.py", line 73, in DeployModule
    self.client.apps_modules_versions.Create, create_request)
  File "/usr/local/bin/../share/google/google-cloud-sdk/./lib/googlecloudsdk/appengine/lib/api/requests.py", line 41, in MakeRequest
    raise exceptions.HttpException(ExtractErrorMessage(error_json))
HttpException: Error Response: [403] Request had insufficient authentication scopes.
ERROR: (gcloud.preview.app.deploy) Error Response: [403] Request had insufficient authentication scopes.
Build step 'Execute shell' marked build as failure
Finished: FAILURE

所以完全不同的东西,我在这里不知所措......

gcloud version 的输出

Google Cloud SDK 0.9.82
app 2015.10.08
bq 2.0.18
bq-nix 2.0.18
core 2015.10.08
core-nix 2015.09.03
gcloud 2015.10.08
gsutil 4.15
gsutil-nix 4.14

【问题讨论】:

  • app.yaml 看起来不错,但是您运行的是哪个版本的 gcloud,您在运行它时是否看到此消息? WARNING: The 'app run' command is deprecated and will soon be removed. Please use dev_appserver.py (in the same directory as the 'gcloud' command) instead.
  • 我不记得看到那个警告了。如果我运行gcloud version 我得到gcloud 2015.10.08,我会将其余的输出放在我原来的帖子中。
  • 您确定您在正确的目录中吗? Argument [app.yaml] is not a valid deployable file. 是与 gcloud 无法找到 app.yaml 一致的错误消息。您可以尝试在同一脚本中运行cat app.yaml,还是在gcloud 调用中指定完整路径?
  • 是的,我在部署之前运行了lscat app.yaml,我可以在那里看到我的应用程序的所有文件以及yaml 文件的正确内容。跨度>

标签: google-app-engine deployment jenkins gcloud


【解决方案1】:

Request had insufficient scopes 是一条消息,表明您使用的身份验证方法无权执行您需要执行的所有任务。

如果您使用托管在 Google Compute Engine 虚拟机上的 Jenkins 实例,您应该 (1) 创建一个新虚拟机并为其提供 more permissive scopes,或者 (2) 使用 service account 对 Jenkins 实例进行身份验证有权访问 App Engine 和 Compute Engine API。

我们会考虑让这些错误消息更有帮助。

【讨论】:

  • 我添加了一个带有 JSON 文件的服务帐户,并将该服务帐户的电子邮件地址的所有变体添加到我的应用程序的权限中,但仍然出现该错误。然后我会尝试创建另一个 VM...
  • curl "http://metadata/computeMetadata/v1/instance/service-accounts/" -H "Metadata-Flavor: Google" 返回############@project.gserviceaccount.com/default/
  • Running gcloud compute instances describe INSTANCE --format json 返回 Could not fetch resource: - Insufficient PermissionUnable to fetch a list of zones. Specifying [--zone] may fix this issue: - Insufficient Permission 取决于我是否在提示 Did you mean zone [us-central1-a] for instances: [['[INSTANCE]']]? 时选择 yn
  • previos question最终编辑 有我用来创建我的 Jenkins VM 的命令,我怀疑这需要更改以获得正确的范围?我没有正确检查命令,只是运行它,我猜这不是很聪明,但我认为它已更新......
【解决方案2】:

好的,我终于解决了我的问题! :)

我在 Google Cloud Shell 中运行:

PASSWORD=###%%%&&&                                                # 12 or more chars, with letters and numbers
PROJECT_ID=**PROJECT**
BITNAMI_IMAGE=bitnami-jenkins-1-634-0-linux-debian-7-x86-64       # e.g. bitnami-jenkins-1-606-0-linux-debian-7-x86-64

gcloud compute \
instances create bitnami-jenkins2 \
--project ${PROJECT_ID} \
--image-project bitnami-launchpad \
--image ${BITNAMI_IMAGE} \
--zone us-central1-b \
--machine-type g1-small \
--metadata "bitnami-base-password=${PASSWORD},bitnami-default-user=CHANGEUSERNAMEHERE,bitnami-key=jenkins,bitnami-name=Jenkins,bitnami-url=//bitnami.com/stack/jenkins,bitnami-description=Jenkins,startup-script-url=https://dl.google.com/dl/jenkins/p2dsetup/setup-script.sh" \
--scopes "https://www.googleapis.com/auth/cloud-platform,https://www.googleapis.com/auth/userinfo.email,https://www.googleapis.com/auth/compute,https://www,googleapis.com/auth/cloud.useraccounts,https://www.googleapis.com/auth/logging.write,https://www.googleapis.com/auth/devstorage.full_control,https://www.googleapis.com/auth/projecthosting,https://www.googleapis.com/auth/appengine.admin" \
--tags "bitnami-launchpad"

这创建了我的虚拟机,但使用了错误的用户,因为我使用上面的命令更改了我的用户名(它是用“用户”创建的)。所以我必须找到我的 config.xml 和 change the username to the correct one for all permissionsupdate the password,并将默认用户名文件夹“user”的文件夹重命名为我选择的用户名。

在那之后,我几乎就在那里,我缺少一个我必须启用的 API。我在 Cloud Console 中访问了 APIs and auth > APIs,但找不到 App Engine Admin API 我收到了 Zachary 的 here 提示(再次感谢老兄! ),但我错过了你可以搜索 100 多个 API,而显示的并不是唯一可用的,所以最终我找到了。

我还必须为 gcloud 命令安装一些组件,这可以通过 SSH 连接到 VM 来完成。我安装了 [preview] 和 [app] 组件,并更新了所有其他默认 gcloud 组件。

我的部署刚刚通过并更新了我的应用,非常感谢大家的帮助!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-30
    • 1970-01-01
    • 2016-12-21
    • 1970-01-01
    • 2011-08-16
    相关资源
    最近更新 更多