google-compute-engine - gcloud auth 抛出 PyOpenSSL 不可用

标签 google-compute-engine travis-ci gcloud

我一直试图让 gcloud 在 Travis 上处于可用状态,但我似乎无法通过 gcloud auth activate-service-account观点。

当它运行时,我只会收到以下错误:

ERROR: (gcloud.auth.activate-service-account) PyOpenSSL is not available. 
See https://developers.google.com/cloud/sdk/crypto for details.

我已经尝试使用 export CLOUDSDK_PYTHON_SITEPACKAGES=1 安装 apt-get 和 pip设置,似乎没有任何效果。

有没有人有任何想法或替代方案?

这是 Travis 版本 Ubuntu 14.04。

更新

如果我从 travis 上的文档运行命令,我会收到以下错误:
usage: gcloud auth activate-service-account  ACCOUNT --key-file KEY_FILE [optional flags]
ERROR: (gcloud.auth.activate-service-account) too few arguments

这让我觉得我必须有一个 ACCOUNT参数,但是在使用未加密的服务帐户 key 在本地运行命令后,我知道不需要它(除非发生了变化)。

我唯一能想到的另一件事是文件没有被正确解密或者命令本身在 Travis 中不满意:
- gcloud auth activate-service-account --key-file client-secret.json

更新 2

只是倾倒了大量日志来弄清楚发生了什么。 (向@Vilas 大喊大叫寻求他的帮助)

它看起来像 gcloud已安装在节点的 VM 上,但它是一个超旧版本。
$ which gcloud
/usr/bin/gcloud

$ gcloud --version
Google Cloud SDK 0.9.37
bq 2.0.18
bq-nix 2.0.18
compute 2014.11.25
core 2014.11.25
core-nix 2014.11.25
dns 2014.11.25
gcutil 1.16.5
gcutil-nix 1.16.5
gsutil 4.6
gsutil-nix 4.6
sql 2014.11.25

下一个问题是如何获得找到正确 gcloud 的路径?

我已经通过运行此命令确认下载的 SDK 安装到 ${HOME}/google-cloud-sdk/bin。
$ ls -l ${HOME}/google-cloud-sdk/bin
total 24
drwxr-xr-x 2 travis travis 4096 Apr 27 21:44 bootstrapping
-rwxr-xr-x 1 travis travis 3107 Mar 28 14:53 bq
-rwxr-xr-x 1 travis travis  912 Apr 21 18:56 dev_appserver.py
-rwxr-xr-x 1 travis travis 3097 Mar 28 14:53 gcloud
-rwxr-xr-x 1 travis travis 3144 Mar 28 14:53 git-credential-gcloud.sh
-rwxr-xr-x 1 travis travis 3143 Mar 28 14:53 gsutil

最佳答案

我终于找到了解决方案。本质上,Travis 安装了一个超旧版本的 gcloud SDK,它接管了下载的 SDK。

帮助诊断的步骤

  • 在您的 .travis.yml文件添加:
    env:
      global:
        # Ensure the downloaded SDK is first on the PATH
        - PATH=${HOME}/google-cloud-sdk/bin:$PATH
        # Ensure the install happens without prompts
        - CLOUDSDK_CORE_DISABLE_PROMPTS=1
    
  • 然后在您的安装步骤中添加以下内容:
    install:
    # Make sure SDK is downloaded - cache once it's working
    # NOTE: Note sure how to update the SDK if it's cached
    - curl https://sdk.cloud.google.com | bash;
    # List the SDK contents to ensure it's downloaded
    - ls -l ${HOME}/google-cloud-sdk/bin
    # Ensure the correct gcloud is being used
    - which gcloud
    # Print the gcloud version and make sure it's something
    # Reasonably up to date compared with: 
    # https://cloud.google.com/sdk/downloads#versioned
    - gcloud --version
    
  • 关于google-compute-engine - gcloud auth 抛出 PyOpenSSL 不可用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36765665/

    相关文章:

    google-compute-engine - 在Google Compute Engine中创建VM实例时出错

    java - 使用GCE的API插入新实例

    android - TravisCI 中的 NDK、CMake 和 Android

    使用 sys-img-armeabi-v7a-google_apis-22 时 Android 检测测试构建失败

    java - 使用外部 IP 访问 Google Cloud VM 实例 Tomcat

    google-compute-engine - 是否可以获得 Kubernetes GKE 节点池的 GCP 的 ANY 发行版?

    heroku - Travis CI 无法识别重命名的存储库

    docker - Kubernetes Jenkins 交换空间问题

    bash - gcloud:是否可以根据当前文件夹更改默认项目?

    python - 如何在 google ml api python 客户端中设置请求超时?