azure-cli icon indicating copy to clipboard operation
azure-cli copied to clipboard

"az container logs" does not work in 2.28.0

Open NakagawaMakoto opened this issue 5 years ago • 32 comments

Describe the bug

Command Name az container logs does not work in 2.28.0. I works fine in 2.27.2

Errors:

The command failed with an unexpected error. Here is the traceback:
'ContainerInstanceManagementClient' object has no attribute 'container'
Traceback (most recent call last):
  File "/opt/az/lib/python3.6/site-packages/knack/cli.py", line 231, in invoke
    cmd_result = self.invocation.execute(args)
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 657, in execute
    raise ex
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 720, in _run_jobs_serially
    results.append(self._run_job(expanded_arg, cmd_copy))
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 691, in _run_job
    result = cmd_copy(params)
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 328, in __call__
    return self.handler(*args, **kwargs)
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/command_operation.py", line 112, in handler
    client = self.client_factory(self.cli_ctx, command_args) if self.client_factory else None
  File "/opt/az/lib/python3.6/site-packages/azure/cli/command_modules/container/_client_factory.py", line 18, in cf_container
    return _container_instance_client_factory(cli_ctx).container
AttributeError: 'ContainerInstanceManagementClient' object has no attribute 'container'

To Reproduce:

Steps to reproduce the behavior. Note that argument values have been redacted, as they may contain sensitive information.

  • Put any pre-requisite steps here...
  • az container logs -g xxxx -n xxxx

Expected Behavior

Logs from the container should be shown.

Environment Summary

Linux-5.13.12-x86_64-with-debian-11.0, Debian GNU/Linux 11 (bullseye)
Python 3.6.10
Installer: DEB

azure-cli 2.28.0

Extensions:
portal 0.1.1
log-analytics 0.2.2
import-export 0.1.1

Additional Context

NakagawaMakoto avatar Sep 08 '21 03:09 NakagawaMakoto

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @macolso.

Issue Details

Describe the bug

Command Name az container logs does not work in 2.28.0. I works fine in 2.27.2

Errors:

The command failed with an unexpected error. Here is the traceback:
'ContainerInstanceManagementClient' object has no attribute 'container'
Traceback (most recent call last):
  File "/opt/az/lib/python3.6/site-packages/knack/cli.py", line 231, in invoke
    cmd_result = self.invocation.execute(args)
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 657, in execute
    raise ex
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 720, in _run_jobs_serially
    results.append(self._run_job(expanded_arg, cmd_copy))
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 691, in _run_job
    result = cmd_copy(params)
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 328, in __call__
    return self.handler(*args, **kwargs)
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/command_operation.py", line 112, in handler
    client = self.client_factory(self.cli_ctx, command_args) if self.client_factory else None
  File "/opt/az/lib/python3.6/site-packages/azure/cli/command_modules/container/_client_factory.py", line 18, in cf_container
    return _container_instance_client_factory(cli_ctx).container
AttributeError: 'ContainerInstanceManagementClient' object has no attribute 'container'

To Reproduce:

Steps to reproduce the behavior. Note that argument values have been redacted, as they may contain sensitive information.

  • Put any pre-requisite steps here...
  • az container logs -g xxxx -n xxxx

Expected Behavior

Logs from the container should be shown.

Environment Summary

Linux-5.13.12-x86_64-with-debian-11.0, Debian GNU/Linux 11 (bullseye)
Python 3.6.10
Installer: DEB

azure-cli 2.28.0

Extensions:
portal 0.1.1
log-analytics 0.2.2
import-export 0.1.1

Additional Context

Author: NakagawaMakoto
Assignees: -
Labels:

Service Attention, Container Instances, customer-reported

Milestone: -

ghost avatar Sep 08 '21 04:09 ghost

route to service team

yonzhan avatar Sep 08 '21 04:09 yonzhan

I am also having this problem with the az container exec ... command. I get a similar error message:

The command failed with an unexpected error. Here is the traceback:
'ContainerInstanceManagementClient' object has no attribute 'container'
Traceback (most recent call last):
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/cli.py", line 231, in invoke
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 657, in execute
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 720, in _run_jobs_serially
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 691, in _run_job
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 328, in __call__
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/command_operation.py", line 121, in handler
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/container/custom.py", line 609, in container_exec
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/container/_client_factory.py", line 18, in cf_container
AttributeError: 'ContainerInstanceManagementClient' object has no attribute 'container'
To open an issue, please run: 'az feedback'

(azure-cli installed via chocolatey)

visimo-jarod avatar Sep 15 '21 19:09 visimo-jarod

I have also similar problem when using az container exec I installed az cli with windows installer.

JanneHarju avatar Sep 16 '21 08:09 JanneHarju

As @NakagawaMakoto mention, after I downgrade to 2.27.2 exec command works nicely. Here is link for installer https://azurecliprod.blob.core.windows.net/msi/azure-cli-2.27.2.msi

JanneHarju avatar Sep 16 '21 14:09 JanneHarju

+1 Plus MS have upgraded their MS hosted agents in Azure DevOps on 13th to this version so downgrading isn't easy.

guywood13 avatar Sep 16 '21 21:09 guywood13

+1 Indeed @guywood13 , I had the same issue yesterday. I have created a task to downgrade az cli to the previous version


- task: Bash@3
  displayName: 'Change version of Az CLI'
  inputs:
    targetType: inline
    script: |
      sudo apt-get update
      sudo apt-get install ca-certificates curl apt-transport-https lsb-release gnupg
      curl -sL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/microsoft.gpg > /dev/null
      AZ_REPO=$(lsb_release -cs)
      echo "deb [arch=amd64] https://packages.microsoft.com/repos/azure-cli/ $AZ_REPO main" | sudo tee /etc/apt/sources.list.d/azure-cli.list
      sudo apt-get update
      sudo apt-get install --allow-downgrades azure-cli=2.27.2-1~bionic

mhomm avatar Sep 17 '21 08:09 mhomm

Nice @mhomm - thank you

guywood13 avatar Sep 17 '21 13:09 guywood13

@mhomm I am getting the below error when i tried to downgrade.. I also tried with 2.27.1 and got a similar error. Any idea?

E: Version '2.27.2-1~bionic' for 'azure-cli' was not found

ata18 avatar Sep 17 '21 20:09 ata18

I'm running az with docker for now:

$ cat az
#!/usr/bin/env bash

if [ ! -d ${XDG_DATA_HOME}/docker-az ] ; then
  echo "\${XDG_DATA_HOME}/docker-az does not exist. Aborting"
  exit 1
fi

docker run -u $(id -u):$(id -g) -v ${XDG_DATA_HOME}/docker-az:/home/az -e HOME=/home/az --rm -i mcr.microsoft.com/azure-cli:2.27.2 az "${@}"

Hope this helps someone!

ivarref avatar Sep 17 '21 20:09 ivarref

@mhomm I am getting the below error when i tried to downgrade.. I also tried with 2.27.1 and got a similar error. Any idea?

E: Version '2.27.2-1~bionic' for 'azure-cli' was not found

You might need a different version, for me 2.27.2-1~focal worked. See the link below for other versions.

https://pkgs.org/download/azure-cli

Het-Eendje avatar Sep 20 '21 08:09 Het-Eendje

Same issue here, with az container exec:

ContainerInstanceManagementClient' object has no attribute 'container

Fails both on my local linux machine and in the Azure cloud CLI.

NeroVanbiervliet avatar Sep 20 '21 09:09 NeroVanbiervliet

there is a gigantic blocker if you are using AzureCli Task on Azure DevOps. There is no way to specify to this task the version to be use, so latest is always used .

gonzalocSO avatar Sep 20 '21 13:09 gonzalocSO

I'm getting the same error when doing az container attach

tmakowka-tc avatar Sep 21 '21 06:09 tmakowka-tc

I'm also having this issue with azure-cli 2.28 on MacOS 10.15.7

glauber-md avatar Sep 21 '21 22:09 glauber-md

Probably https://github.com/Azure/azure-cli/issues/19489?


@mhomm I am getting the below error when i tried to downgrade.. I also tried with 2.27.1 and got a similar error. Any idea?

E: Version '2.27.2-1~bionic' for 'azure-cli' was not found

Do this to get the correct package name:

apt-cache show azure-cli | grep 'Version: 2.27.2'

davetapley avatar Sep 22 '21 01:09 davetapley

similar issue of az cli version in "az container ***" when using azure devops pipeline

wenbya avatar Sep 22 '21 08:09 wenbya

I have the same error as well when I run both az container attach and az container logs I attached some traceback

'ContainerInstanceManagementClient' object has no attribute 'container'
Traceback (most recent call last):
  File "/opt/az/lib/python3.6/site-packages/knack/cli.py", line 231, in invoke
    cmd_result = self.invocation.execute(args)
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 657, in execute
    raise ex
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 720, in _run_jobs_serially
    results.append(self._run_job(expanded_arg, cmd_copy))
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 691, in _run_job
    result = cmd_copy(params)
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 328, in __call__
    return self.handler(*args, **kwargs)
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/command_operation.py", line 121, in handler
    return op(**command_args)
  File "/opt/az/lib/python3.6/site-packages/azure/cli/command_modules/container/custom.py", line 740, in attach_to_container
    container_client = cf_container(cmd.cli_ctx)
  File "/opt/az/lib/python3.6/site-packages/azure/cli/command_modules/container/_client_factory.py", line 18, in cf_container
    return _container_instance_client_factory(cli_ctx).container
AttributeError: 'ContainerInstanceManagementClient' object has no attribute 'container'

0verwtch avatar Sep 22 '21 20:09 0verwtch

Confirming have the same issue with CLI 2.28.0. He are using MS hosted agents and no way to downgrade. Any suggestions?

AlexisHW avatar Sep 24 '21 09:09 AlexisHW

if your use-case is DELETE, here is a workaround that avoids downgrading the CLI, and uses it to take care of the auth

RESOURCE_GROUP=my-rg
ACI_CONTAINER_NAME=containername
SUBSCRIPTION_ID="xxxxxxxxxxxxxxxxxxxxxxxx"
az rest --method delete \
        --uri "/subscriptions/{subscriptionId}/resourceGroups/${RESOURCE_GROUP}/providers/Microsoft.ContainerInstance/containerGroups/${ACI_CONTAINER_NAME}?api-version=2019-12-01" \
        --subscription ${SUBSCRIPTION_ID}

serbrech avatar Sep 27 '21 07:09 serbrech