azure-cli: aks-preview extension breaks most az aks commands
Describe the bug aks-preview extension broke az aks get-credentials. This was working perfectly prior to Nov 13 2019.
To Reproduce
bash-4.2# az --version
azure-cli 2.0.75
command-modules-nspkg 2.0.3
core 2.0.75
nspkg 3.0.4
telemetry 1.0.4
Python location '/usr/bin/python'
Extensions directory '/home/jenkins/.azure/cliextensions'
Python (Linux) 2.7.5 (default, Jun 11 2019, 14:33:56)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)]
Legal docs and information: aka.ms/AzureCliLegal
bash-4.2# ls -l /home/jenkins/.azure/cliextensions/aks-preview/azext_aks_preview/custom.py
ls: cannot access /home/jenkins/.azure/cliextensions/aks-preview/azext_aks_preview/custom.py: No such file or directory
bash-4.2# az aks get-credentials -n aks-testing -g rsg-testing -a -f admin.kubeconfig
Merged "aks-testing" as current context in admin.kubeconfig
bash-4.2# az extension add --name aks-preview
bash-4.2# ls -l /home/jenkins/.azure/cliextensions/aks-preview/azext_aks_preview/custom.py
-rw-r--r--. 1 root root 107080 Nov 13 07:17 /home/jenkins/.azure/cliextensions/aks-preview/azext_aks_preview/custom.py
bash-4.2# az aks get-credentials -n aks-testing -g rsg-testing -a -f admin.kubeconfig
The command failed with an unexpected error. Here is the traceback:
invalid syntax (custom.py, line 1155)
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/knack/cli.py", line 206, in invoke
cmd_result = self.invocation.execute(args)
File "/usr/lib/python2.7/site-packages/azure/cli/core/commands/__init__.py", line 523, in execute
self.commands_loader.load_arguments(command)
File "/usr/lib/python2.7/site-packages/azure/cli/core/__init__.py", line 291, in load_arguments
self.command_table[command].load_arguments() # this loads the arguments via reflection
File "/usr/lib/python2.7/site-packages/azure/cli/core/commands/__init__.py", line 291, in load_arguments
super(AzCliCommand, self).load_arguments()
File "/usr/lib/python2.7/site-packages/knack/commands.py", line 97, in load_arguments
cmd_args = self.arguments_loader()
File "/usr/lib/python2.7/site-packages/azure/cli/core/__init__.py", line 488, in default_arguments_loader
op = handler or self.get_op_handler(operation, operation_group=kwargs.get('operation_group'))
File "/usr/lib/python2.7/site-packages/azure/cli/core/__init__.py", line 528, in get_op_handler
op = import_module(mod_to_import)
File "/usr/lib64/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/home/jenkins/.azure/cliextensions/aks-preview/azext_aks_preview/custom.py", line 1155
f'save them to the storage account {colorama.Style.BRIGHT}{colorama.Fore.GREEN}{storage_account_name}{colorama.Style.RESET_ALL} as '
^
SyntaxError: invalid syntax
To open an issue, please run: 'az feedback'
Expected behavior az aks get-credentials will not fail
Environment summary install method is via pip: pip install --no-cache-dir --upgrade azure-cli running on a docker image with base openshift3/jenkins-slave-base-rhel7 tested in bash shell
Additional context This was working perfectly prior to Nov 13 2019.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 3
- Comments: 25 (13 by maintainers)
dirty workaround: install an older version with something like:
az extension remove --name aks-preview
az extension add --source https://azurecliaks.blob.core.windows.net/azure-cli-extension/aks_preview-0.4.21-py2.py3-none-any.whl
This line:
f'save them to the storage account {colorama.Style.BRIGHT}{colorama.Fore.GREEN}{storage_account_name}{colorama.Style.RESET_ALL} as '",
is using an f-string which is valid syntax only in Python 3.6 and higher.
On Centos, if you install the azure cli via yum using this package:
azure-cli-2.0.76-1.el7.x86_64
az
will use Python 2.7