Search code examples
google-cloud-platformcryptographytravis-cigcloudgoogle-cloud-shell

Travis -Gcloud crashed (AttributeError): '_RSAPrivateKey' object has no attribute 'sign'


UPDATE


Here is part of travis file

 before_install:
      #openssl stuff regarding credentials.tar.gz
       
      - if [ ! -d "${GAE_PYTHONPATH}" ]; then python scripts/fetch_gae_sdk.py $(dirname
        "${GAE_PYTHONPATH}"); fi
      - if [ ! -d $HOME/google-cloud-sdk/bin ]; then rm -rf $HOME/google-cloud-sdk; curl
        https://sdk.cloud.google.com | bash; fi
      - tar -xzf credentials.tar.gz
 - "$HOME/google-cloud-sdk/bin/gcloud  components update"
  -  "pip install -U cryptography"
      - "$HOME/google-cloud-sdk/bin/gcloud auth activate-service-account --key-file travis-credentials.json" # ERROR HAPPENS HERE
#ERROR IS =  Gcloud crashed (AttributeError): '_RSAPrivateKey' object has no attribute 'sign'
      - "$HOME/google-cloud-sdk/bin/gcloud auth configure-docker"

And this is what I can't understand. I would assume if it was something related to a sudden version upgrade from gcloud and it is incompatible with crpyotgraphy then lots of applications would have failed and my fix attempts would fix it. But this used to work until I get the aforementioned email so I am thinking something is messed up after that email but it is just a wild guess.

All of the Travis file

language: python
python: 2.7
branches:
  only:
    - master
services:
  - docker
cache:
  directories:
    - "$HOME/google-cloud-sdk/"
env:
  - GAE_PYTHONPATH=${HOME}/.cache/google_appengine PATH=$PATH:${HOME}/google-cloud-sdk/bin
    PYTHONPATH=${PYTHONPATH}:${GAE_PYTHONPATH} CLOUDSDK_CORE_DISABLE_PROMPTS=1
before_install:
  #unrelated stuff
  - if [ ! -d "${GAE_PYTHONPATH}" ]; then python scripts/fetch_gae_sdk.py $(dirname
    "${GAE_PYTHONPATH}"); fi
  - if [ ! -d $HOME/google-cloud-sdk/bin ]; then rm -rf $HOME/google-cloud-sdk; curl
    https://sdk.cloud.google.com | bash; fi
  - tar -xzf credentials.tar.gz
 - "$HOME/google-cloud-sdk/bin/gcloud  components update"
  -  "pip install -U cryptography"
  - "$HOME/google-cloud-sdk/bin/gcloud auth activate-service-account --key-file travis-credentials.json"
  - "$HOME/google-cloud-sdk/bin/gcloud auth configure-docker"
install:
  #push image to gcr
script:
  - echo "done"

The same question is asked here question but updating cryptography module didn't resolve the issue(I tried 3 different versions from the latest to one listed in the answer -> 2.6.1). 3 days ago I received an email from google which said the following.

Hello Cloud Shell user,

It's been over 120 days since you opened Cloud Shell from the Google Cloud Platform console. In 7 days, your Cloud Shell home directory will be automatically scheduled for deletion.

To keep your Cloud Shell home directory and its data, just log in and open Cloud Shell.

I opened the shell to keep it activated but when I try to deploy my django application with travis I got the following error when I tried to execute a gcloud command.

 $HOME/google-cloud-sdk/bin/gcloud auth activate-service-account --key-file travis-credentials.json
ERROR: gcloud crashed (AttributeError): '_RSAPrivateKey' object has no attribute 'sign'

I tried 2.6.1, 2.8 (my previous version), 3.4.1(most updated version), but none of them worked. Any idea on how to fix this? My last build was a month ago and it worked successfully without changing anything in configuration


Solution

  • Apparently, this issue is related to the gcloud version I was using.I always fetch the latest version (which is currently 331.0.0). Although it is not desirable, downgrading gcloud SDK to 330.0.0 resolved the issue.

    gcloud  components update --version 330.0.0