azure-cli: global import of antlr4 for optional sub-feature

Bug #1897586 reported by Luca Boccassi
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
azure-cli (Debian)
Fix Released
Unknown
azure-cli (Ubuntu)
Fix Released
Undecided
Unassigned
Focal
Fix Released
Undecided
Unassigned

Bug Description

[Impact]

The monitor sub-command imports antlr4 at the global level, although it is necessary only for an optional sub-option of the sub-command. Given antlr4 is not available, this restricts usage of the whole sub-command unnecessarily.

[Test Case]

  $ az vm list
  The command failed with an unexpected error. Here is the traceback:

  No module named 'antlr4'
  Traceback (most recent call last):
    File "/usr/lib/python3/dist-packages/knack/cli.py", line 215, in invoke
      cmd_result = self.invocation.execute(args)
    File "/usr/lib/python3/dist-packages/azure/cli/core/commands/__init__.py", line 553, in execute
      self.commands_loader.load_arguments(command)
    File "/usr/lib/python3/dist-packages/azure/cli/core/__init__.py", line 345, in load_arguments
      loader.load_arguments(command) # this adds entries to the argument registries
    File "/usr/lib/python3/dist-packages/azure/cli/command_modules/vm/__init__.py", line 31, in load_arguments
      from azure.cli.command_modules.vm._params import load_arguments
    File "/usr/lib/python3/dist-packages/azure/cli/command_modules/vm/_params.py", line 31, in <module>
      from azure.cli.command_modules.monitor.actions import get_period_type
    File "/usr/lib/python3/dist-packages/azure/cli/command_modules/monitor/actions.py", line 7, in <module>
      import antlr4
  ModuleNotFoundError: No module named 'antlr4'

[Regression Potential]

Minimal. The same patch has already been upstream for a few releases now, and has been shipping in Debian unstable/testing since early August.

[Other Info]

The issue has been fixed upstream, and the import is now reduced in scope:

https://github.com/Azure/azure-cli/pull/14712

Version 2.10.1-1, which is available in 20.10 Groovy, already contains a backport of this patch.

This issue has been reported upstream by Focal users, so it would be good to get the patch backported.

Revision history for this message
Luca Boccassi (bluca) wrote :

debdiff of fixed package

Revision history for this message
Luca Boccassi (bluca) wrote :

individual patch backported from https://github.com/Azure/azure-cli/pull/14712

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

Actually fixed in Debian and Groovy already.

Changed in azure-cli (Ubuntu):
status: New → Fix Released
Changed in azure-cli (Ubuntu Focal):
status: New → Triaged
Luca Boccassi (bluca)
description: updated
Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

Thanks for adding the SRU Template.

I checked this and it mostly LGTM.
Minor changes:
1. version number for SRU will be ubuntu0.1
2. add Bug-Ubuntu reference
3. run update-maintainer
4. put LP bug refernce into brackets as it is the usual style

I did those on review and will sponsor it into Focal unapproved for the SRU Team.

Uploading to ubuntu (via ftp to upload.ubuntu.com):
  Uploading azure-cli_2.0.81+ds-4ubuntu0.1.dsc: done.
  Uploading azure-cli_2.0.81+ds-4ubuntu0.1.debian.tar.xz: done.
  Uploading azure-cli_2.0.81+ds-4ubuntu0.1_source.buildinfo: done.
  Uploading azure-cli_2.0.81+ds-4ubuntu0.1_source.changes: done.
Successfully uploaded packages.

Changed in azure-cli (Ubuntu Focal):
status: Triaged → In Progress
Changed in azure-cli (Debian):
status: Unknown → New
Revision history for this message
Brian Murray (brian-murray) wrote : Please test proposed package

Hello Luca, or anyone else affected,

Accepted azure-cli into focal-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/azure-cli/2.0.81+ds-4ubuntu0.1 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, what testing has been performed on the package and change the tag from verification-needed-focal to verification-done-focal. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-focal. In either case, without details of your testing we will not be able to proceed.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance for helping!

N.B. The updated package will be released to -updates after the bug(s) fixed by this package have been verified and the package has been in -proposed for a minimum of 7 days.

Changed in azure-cli (Ubuntu Focal):
status: In Progress → Fix Committed
tags: added: verification-needed verification-needed-focal
Revision history for this message
Luca Boccassi (bluca) wrote :

Unfortunately there's a test that tries to connect to the network, that I missed when doing the original sweep-and-ignore, so it fails to build on the build machine. It works fine from my 20.04.1 VM, so I didn't catch it when building the patch, sorry about that.

This is not related to the patch, it's an independent issue. This test should be added to the ignore list:

--- debian/rules
+++ debian/rules
@@ -72,6 +72,7 @@
  --deselect=tests_core/test_extension.py::TestExtensions::test_extension_not_exists \
  --deselect=tests_core/test_extension.py::TestExtensions::test_get_extension \
  --deselect=tests_core/test_extension.py::TestExtensions::test_get_extension_names \
+ --deselect=tests_core/test_cloud.py::SubscriptionSuppressionTest::test_subscription_suppression \
  --ignore=tests_core/test_generic_update.py
 export SUBDIRS = $(shell find src -name setup.py -printf "%h ")
 export MODULES = $(sort $(filter-out %-nspkg,$(SUBDIRS)))

Would it be possible to do that? Thanks!

Revision history for this message
Luca Boccassi (bluca) wrote :

Apart from that, built the package manually and installed it on a 20.04.1 VM and it works fine, the original bug is solved:

ubuntu@ubuntu:/tmp$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.1 LTS
Release: 20.04
Codename: focal
ubuntu@ubuntu:/tmp$ apt-cache policy azure-cli
azure-cli:
  Installed: 2.0.81+ds-4ubuntu0.1
  Candidate: 2.0.81+ds-4ubuntu0.1
  Version table:
 *** 2.0.81+ds-4ubuntu0.1 100
        100 /var/lib/dpkg/status
     2.0.81+ds-4 500
        500 http://archive.ubuntu.com/ubuntu focal/universe amd64 Packages
ubuntu@ubuntu:/tmp$ az vm list | head -n 3
[
  {
    "additionalCapabilities": null,

Revision history for this message
Luca Boccassi (bluca) wrote :

If a 0.2 is needed, debdiff attached.

Revision history for this message
Luca Boccassi (bluca) wrote :

Note that this unit test is not an issue on the newer version in Groovy

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

Thanks for the explanation, LGTM sponsored

Revision history for this message
Timo Aaltonen (tjaalton) wrote :

Hello Luca, or anyone else affected,

Accepted azure-cli into focal-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/azure-cli/2.0.81+ds-4ubuntu0.2 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, what testing has been performed on the package and change the tag from verification-needed-focal to verification-done-focal. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-focal. In either case, without details of your testing we will not be able to proceed.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance for helping!

N.B. The updated package will be released to -updates after the bug(s) fixed by this package have been verified and the package has been in -proposed for a minimum of 7 days.

Revision history for this message
Luca Boccassi (bluca) wrote :

Tested with -proposed enabled on a 20.04.1 VM, works fine:

ubuntu@ubuntu:~$ az login
To sign in, use a web browser to open the page https://microsoft.com/devicelogin and enter the code ... to authenticate.
ubuntu@ubuntu:~$ az vm list | head
[
  {
    "additionalCapabilities": null,
    "availabilitySet": null,
    "billingProfile": null,
    "diagnosticsProfile": {
      "bootDiagnostics": {
        "enabled": true,
        "storageUri": "https://anparrirgdiag487.blob.core.windows.net/"
      }
ubuntu@ubuntu:~$ az vm list | head -n 6
[
  {
    "additionalCapabilities": null,
    "availabilitySet": null,
    "billingProfile": null,
    "diagnosticsProfile": {
ubuntu@ubuntu:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.1 LTS
Release: 20.04
Codename: focal
ubuntu@ubuntu:~$ apt-cache policy azure-cli
azure-cli:
  Installed: 2.0.81+ds-4ubuntu0.2
  Candidate: 2.0.81+ds-4ubuntu0.2
  Version table:
 *** 2.0.81+ds-4ubuntu0.2 500
        500 http://archive.ubuntu.com/ubuntu focal-proposed/universe amd64 Packages
        100 /var/lib/dpkg/status
     2.0.81+ds-4 500
        500 http://archive.ubuntu.com/ubuntu focal/universe amd64 Packages

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

This was tested successfully and I heard nothing negative so far, updating the tags accordingly.

tags: added: verification-done verification-done-focal
removed: verification-needed verification-needed-focal
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package azure-cli - 2.0.81+ds-4ubuntu0.2

---------------
azure-cli (2.0.81+ds-4ubuntu0.2) focal; urgency=medium

  * Skip test_subscription_suppression, requires a network connection.

azure-cli (2.0.81+ds-4ubuntu0.1) focal; urgency=medium

  * Add antlr4_workaround.patch to workaround missing antlr4.
    (LP: #1897586)

 -- Luca Boccassi <email address hidden> Wed, 30 Sep 2020 15:53:44 +0000

Changed in azure-cli (Ubuntu Focal):
status: Fix Committed → Fix Released
Revision history for this message
Łukasz Zemczak (sil2100) wrote : Update Released

The verification of the Stable Release Update for azure-cli has completed successfully and the package is now being released to -updates. Subsequently, the Ubuntu Stable Release Updates Team is being unsubscribed and will not receive messages about this bug report. In the event that you encounter a regression using the package from -updates please report a new bug using ubuntu-bug and tag the bug report regression-update so we can easily find any regressions.

Changed in azure-cli (Debian):
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.