binxio/azure-devops-extensions

Versions

Opened this issue · 2 comments

We had this working on SDK v306 and vscode-windows-2016 for while.

After changing to SDK v375 it caused a path error. i.e. it thinks the path is still //306//

Moving Agent specification to windows-2022 failed with a python exception

2022-03-04T05:50:41.0414720Z ==============================================================================
2022-03-04T05:50:41.0415128Z Task : Run a custom gcloud command
2022-03-04T05:50:41.0415447Z Description : Execute gcloud commands to manage resources on Google Cloud Platform (GCP)
2022-03-04T05:50:41.0415725Z Version : 0.4.0
2022-03-04T05:50:41.0416290Z Author : laurensknoll@binx.io
2022-03-04T05:50:41.0416971Z Help :
2022-03-04T05:50:41.0417221Z ==============================================================================
2022-03-04T05:50:42.2026284Z [command]C:\Windows\system32\cmd.exe /D /S /C "C:\hostedtoolcache\windows\google-cloud-sdk\306.0.0\x64\bin\gcloud.cmd auth activate-service-account --key-file D:\a_temp/ul-gs-u-903249-04-prj-bf2609f5f2d4.json --quiet"
2022-03-04T05:50:44.3080528Z C:/ProgramData/Chocolatey/lib/mingw/tools/install/mingw64/opt/bin/python.exe: can't find 'main' module in ''
2022-03-04T05:50:44.7988941Z C:/ProgramData/Chocolatey/lib/mingw/tools/install/mingw64/opt/bin/python.exe: can't find 'main' module in ''
2022-03-04T05:50:45.1119793Z Traceback (most recent call last):
2022-03-04T05:50:45.1120867Z File "C:\hostedtoolcache\windows\google-cloud-sdk\306.0.0\x64\lib\gcloud.py", line 104, in
2022-03-04T05:50:45.1263524Z main()
2022-03-04T05:50:45.1264769Z File "C:\hostedtoolcache\windows\google-cloud-sdk\306.0.0\x64\lib\gcloud.py", line 62, in main
2022-03-04T05:50:45.1266412Z from googlecloudsdk.core.util import encoding
2022-03-04T05:50:45.1267578Z File "C:\hostedtoolcache\windows\google-cloud-sdk\306.0.0\x64\lib\googlecloudsdk_init_.py", line 23, in
2022-03-04T05:50:45.1270361Z from googlecloudsdk.core.util import importing
2022-03-04T05:50:45.1271695Z File "C:\hostedtoolcache\windows\google-cloud-sdk\306.0.0\x64\lib\googlecloudsdk\core\util\importing.py", line 23, in
2022-03-04T05:50:45.1273035Z import imp
2022-03-04T05:50:45.1275013Z File "C:\hostedtoolcache\windows\Python\3.9.10\x64\lib\imp.py", line 23, in
2022-03-04T05:50:45.1276378Z from importlib import util
2022-03-04T05:50:45.1277159Z File "C:\hostedtoolcache\windows\Python\3.9.10\x64\lib\importlib\util.py", line 2, in
2022-03-04T05:50:45.1360446Z from . import abc
2022-03-04T05:50:45.1361748Z File "C:\hostedtoolcache\windows\Python\3.9.10\x64\lib\importlib\abc.py", line 17, in
2022-03-04T05:50:45.1433195Z from typing import Protocol, runtime_checkable
2022-03-04T05:50:45.1435189Z File "C:\hostedtoolcache\windows\Python\3.9.10\x64\lib\typing.py", line 26, in
2022-03-04T05:50:45.1511769Z import re as stdlib_re # Avoid confusion with the re we export.
2022-03-04T05:50:45.1512574Z File "C:\hostedtoolcache\windows\Python\3.9.10\x64\lib\re.py", line 124, in
2022-03-04T05:50:45.1618399Z import enum
2022-03-04T05:50:45.1619841Z File "C:\hostedtoolcache\windows\google-cloud-sdk\306.0.0\x64\lib\third_party\enum_init_.py", line 26, in
2022-03-04T05:50:45.1621171Z spec = importlib.util.find_spec('enum')
2022-03-04T05:50:45.1622274Z AttributeError: module 'importlib' has no attribute 'util'
2022-03-04T05:50:45.2066205Z ##[error]Error: The process 'C:\hostedtoolcache\windows\google-cloud-sdk\306.0.0\x64\bin\gcloud.cmd' failed with exit code 1

Changing Agent Specification to ubuntu-20.04 works great with GCP SDK 375.

We don't need those older versions to work, but a release note specifying which agents are supported would be useful.

Thanks for posting the issue @intotecho . The issue is caused by using an unsupported python version (3.9) for GCP SDK v306. Python 3.9 is supported from GCP SDK v318 onwards. See support ticket.

Switching to GCP SDK v375, therefore, should have worked on win-2022. Could you share your pipeline so I'm able to understand why it resolved to the wrong GCP SDK version?

Created an example pipeline that installs GCP SDK v306 on Windows 2022. Note the UsePythonVersion task to downgrade the python version to 3.8. Also note the Set CLOUDSDK_PYTHON command to instrument GCP SDK to use the downgraded python. The latter is required, because the installation script doesn't rely on the Path-environment variable, but relies on the where python output to select (the latest) v3 python.

pool:
  name: windows-2022

steps:
- task: UsePythonVersion@0
  name: usePython
  displayName: Use Python 3.8
  inputs:
    versionSpec: 3.8
- task: CmdLine@2
  displayName: Set CLOUDSDK_PYTHON
  inputs:
    script: 'echo ##vso[task.setvariable variable=CLOUDSDK_PYTHON]$(usePython.pythonLocation)\python.exe'
- task: GoogleCloudSdkInstaller@0
  displayName: Install Google Cloud SDK 306.0.0
  inputs:
    version: 306.0.0
- task: GcloudRunner@0
  displayName: gcloud components list
  inputs:
    command: components list