1
votes

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

1
The Google Cloud SDK (gcloud) includes its own version of Python. When you installed the SDK, what options did you enable and disable? The issue is that your installation of cryptography is out of date. pip install -U cryptography. Or the SDK is an old version. - John Hanley
I updated cryptography in cloud shell and manually ran gcloud components update. That gave an error and gave me a long chain of libraries to manually install with sudo apt get (which they claim is the equivalent action) I also updated crypto version in my django project to 3.3.2 and it didn't work. I really find it hard to below something that worked for so long is now broken because of outdated version (especially the timing is suspicious as I never got this error before this email.) Am I missing something/do you mean something else by updating sdk? - Prethia
I missed the part that your problem is while using Cloud Shell. Reset Cloud Shell. Are you installing anything related to Python? Do not install anything that overwrites the system's environment as those changes will be lost. Instead use virtualenv and keep installs and updates to Python local to your HOME directory. - John Hanley
I think I am failing at explaining this. My problem normally happens when Travis tries to create docker image by building my django application. But when it executes the command I stated in my question, I get this error. This is the first time ever I tried to did something from cloud shell to try to fix it. Normally I always used a normal virtual machine in Google Compute Engine.(or use gcloud from travis). I am updating my travis commands that leads to failure in the question maybe it helps - Prethia
Has updating the travis commands helped? Also, I'm assuming you were meaning to reply to @JohnHanley , so I'll tag 'em here. - fabc

1 Answers

0
votes

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