3

My previous deployments with same github workflow file were successful. Suddenly today, I get this error in Github Actions while trying to deploy.

May I know how to fix this?

Run google-github-actions/setup-gcloud@v0
24
/usr/bin/tar xz --warning=no-unknown-keyword --overwrite -C /home/runner/work/_temp/fa0cd935-fe7e-4593-8662-69259b4b00a0 -f /home/runner/work/_temp/52901a76-e32d-4cdf-92e4-83836f8c5362
25
Warning: "service_account_key" has been deprecated. Please switch to using google-github-actions/auth which supports both Workload Identity Federation and Service Account Key JSON authentication. For more details, see https://github.com/google-github-actions/setup-gcloud#authorization
26
Error: google-github-actions/setup-gcloud failed with: failed to execute command `gcloud --quiet auth activate-service-account *** --key-file -`: /opt/hostedtoolcache/gcloud/270.0.0/x64/lib/googlecloudsdk/core/console/console_io.py:544: SyntaxWarning: "is" with a literal. Did you mean "=="?
27
  if answer is None or (answer is '' and default is not None):
28
/opt/hostedtoolcache/gcloud/270.0.0/x64/lib/third_party/ipaddress/__init__.py:1106: SyntaxWarning: 'str' object is not callable; perhaps you missed a comma?
29
  raise TypeError("%s and %s are not of the same version" (a, b))
30
ERROR: gcloud failed to load: module 'collections' has no attribute 'MutableMapping'
31
    gcloud_main = _import_gcloud_main()
32
    import googlecloudsdk.gcloud_main
33
    from googlecloudsdk.calliope import base
34
    from googlecloudsdk.calliope import display
35
    from googlecloudsdk.calliope import display_taps
36
    from googlecloudsdk.core.resource import resource_printer_base
37
    from googlecloudsdk.core.resource import resource_projector
38
    from google.protobuf import json_format as protobuf_encoding
39
    from google.protobuf import symbol_database
40
    from google.protobuf import message_factory
41
    from google.protobuf import reflection
42
    from google.protobuf.internal import python_message as message_impl
43
    from google.protobuf.internal import containers
44
    MutableMapping = collections.MutableMapping
45

46
This usually indicates corruption in your gcloud installation or problems with your Python interpreter.
47

48
Please verify that the following is the path to a working Python 2.7 executable:
49
    /usr/bin/python
50

51
If it is not, please set the CLOUDSDK_PYTHON environment variable to point to a working Python 2.7 executable.
52

53
If you are still experiencing problems, please reinstall the Cloud SDK using the instructions here:
54
    https://cloud.google.com/sdk/
user3665224
  • 1,349
  • 3
  • 16
  • 34

5 Answers5

3

I fixed it by using below lines in workflow yml before uses: google-github-actions/setup-gcloud@v0

- run: |
    sudo apt-get install python2.7
    export CLOUDSDK_PYTHON="/usr/bin/python2"
user3665224
  • 1,349
  • 3
  • 16
  • 34
  • It worked for me. I also added the shell param as it is apparently mandatory – Fran Jiménez Nov 22 '22 at 16:44
  • @FranJiménez we tried with the following snippet which is still throwing an error on the python. Could you share if any other changes required. https://share.anysnap.app/f7KB30GMrPg1 – siva Nov 25 '22 at 05:36
2

Answer above did not work for us, however, we're able to identify and fix the the problem by doing followings.

Problem: The python version used in our action was somehow 3.10.3 which is not compliant with gcloud cli.

Official gcloud docs says:

The gcloud CLI runs under Python. Note that gcloud requires Python version 3.5-3.9

Solution: We've updated github workflow definition to setup a supported version of the python by the gcloud cli.

- name: Setup python
    uses: actions/setup-python@v4
    with:
      python-version: '3.9'

- name: Export gcloud related env variable
    run: export CLOUDSDK_PYTHON="/usr/bin/python3"
mit4dev
  • 31
  • 4
1

In my case setting the version to 318.0.0 also fixed the issue.

name: Set up gcloud
        uses: google-github-actions/setup-gcloud@v0
        with:
          version: '318.0.0'
          service_account_email: ${{ secrets.GCP_SA_EMAIL }}
          service_account_key: ${{ secrets.GCP_SA_KEY }}

Based on the info at: AttributeError: module 'importlib' has no attribute 'util'

strada
  • 942
  • 9
  • 18
1

I ran into the same issue. Seems it's a gcloud and Python versioning issue.

Here is what solved it for me:

my workflow yml before the fix:

- uses: google-github-actions/setup-gcloud@v0
      with:
        version: '270.0.0'
        service_account_email: ${{ secrets.SECRET_NAME }}
        service_account_key: ${{ secrets.SECRET_NAME }}

after the fix:

- name: Set up Python
      uses: actions/setup-python@v4
      with:
        python-version: '3.9'
- uses: google-github-actions/setup-gcloud@v0
      with:
        version: '318.0.0'
        service_account_email: ${{ secrets.SECRET_NAME }}
        service_account_key: ${{ secrets.SECRET_NAME }}
0

GCloud setup works again out of the box using the latest action:

  - uses: google-github-actions/setup-gcloud@v1
thisismydesign
  • 21,553
  • 9
  • 123
  • 126