Activity log for bug #1969809

Date Who What changed Old value New value Message
2022-04-21 16:28:51 Jerry Larivee bug added bug
2022-04-21 16:28:51 Jerry Larivee attachment added Log file with stack trace https://bugs.launchpad.net/bugs/1969809/+attachment/5582153/+files/UA-Bug.txt
2022-04-27 13:57:50 Lucas Albuquerque Medeiros de Moura ubuntu-advantage-tools (Ubuntu): status New Confirmed
2022-05-19 18:21:59 Grant Orndorff description I'm using the ua tool (version 27.7~16.04.1). I'm unable to enable the esm-infra service because a couple of the packages that I have installed have been completely removed from the launchpad server. Specifically: deb http://ppa.launchpad.net/jonathonf/ffmpeg-3/ubuntu xenial main deb http://ppa.launchpad.net/jonathonf/python-3.6/ubuntu xenial main When I remove these package definitions from /etc/apt/sources.list.d/ the command succeeds. I've attached a log file that includes this stack trace. Traceback (most recent call last): File "/usr/lib/python3/dist-packages/uaclient/cli.py", line 1629, in wrapper return func(*args, **kwargs) File "/usr/lib/python3/dist-packages/uaclient/cli.py", line 1725, in main return args.action(args, cfg=cfg) File "/usr/lib/python3/dist-packages/uaclient/cli.py", line 480, in action_fix fix_status = security.fix_security_issue_id(cfg, args.security_issue) File "/usr/lib/python3/dist-packages/uaclient/security.py", line 607, in fix_security_issue_id usn_released_pkgs=usn_released_pkgs, File "/usr/lib/python3/dist-packages/uaclient/security.py", line 982, in prompt_for_affected_packages num_pkgs=count, File "/usr/lib/python3/dist-packages/uaclient/security.py", line 872, in _handle_released_package_fixes cfg, binary_pkgs, pocket File "/usr/lib/python3/dist-packages/uaclient/security.py", line 1223, in upgrade_packages_and_attach if not _check_subscription_for_required_service(pocket, cfg): File "/usr/lib/python3/dist-packages/uaclient/security.py", line 1139, in _check_subscription_for_required_service if _prompt_for_enable(cfg, ent.name): File "/usr/lib/python3/dist-packages/uaclient/security.py", line 1118, in _prompt_for_enable cfg, File "/usr/lib/python3/dist-packages/uaclient/cli.py", line 200, in new_f if cmd_args.format == "json" and not cmd_args.assume_yes: AttributeError: 'Namespace' object has no attribute 'format' [Impact] This bug causes enabling services during a `ua fix` operation to fail. That means that any user that is attached to a UA contract, but needs a particular service to fix a USN or CVE could run into this bug if they try to use `ua fix` to fix that USN/CVE. In practice, this probably mostly affects xenial users who are attached to a UA contract, but don't have `esm-infra` enabled. For them, many `ua fix` attempts will fail because they attempt to enable `esm-infra`. The bug occurred because we are re-using a function to `enable` that has a required argument that isn't checked by mypy. When this new required argument got added to the function, we failed to update this callsite. That happened because the args are currently passed via an argparse Namespace object and so the discrepancy wasn't captured by mypy. The fix is to pass the required argument. [Test Plan] To Reproduce: ``` lxc launch ubuntu-daily:xenial x-1969809 lxc exec x-1969809 -- apt update lxc exec x-1969809 -- apt upgrade lxc exec x-1969809 -- apt install apache2 lxc exec x-1969809 -- ua attach --no-auto-enable $YOUR_TOKEN lxc exec x-1969809 -- ua fix usn-4994-2 # respond with "e" to the prompt ``` You should see "Unexpected error(s) occurred." To see that release 27.9 of ubuntu-advantage-tools fixes the problem, you can use the build in `ppa:ua-client/staging` for now (or once it is in -proposed, just enable proposed). ``` lxc launch ubuntu-daily:xenial x-1969809 lxc exec x-1969809 -- add-apt-repository ppa:ua-client/staging lxc exec x-1969809 -- apt update lxc exec x-1969809 -- apt upgrade lxc exec x-1969809 -- apt install apache2 lxc exec x-1969809 -- ua attach --no-auto-enable $YOUR_TOKEN lxc exec x-1969809 -- ua fix usn-4994-2 # respond with "e" to the prompt ``` You should see "USN-4994-2 is resolved." [Where problems could occur] Because the fix just adds the required argument, similar problems could occur in the future if we add a new required argument (or rename an argument, etc) and again forget to update this callsite. If our fix of passing the required arg is wrong somehow (e.g. mispelled), then this same bug will continue to occur. If our fix is egregiously wrong (e.g. invalid python), then all `ua fix` attempts could fail, not just those that require a service enabled in the middle. [Other Info] In the future, we should move away from re-using the cli action functions with Namespace args for this functionality. Instead we should use functions with mypy-type-checked arguments. We will likely do this soon as a refactor of `ua fix` is on our roadmap for this cycle. [Original Description] I'm using the ua tool (version 27.7~16.04.1). I'm unable to enable the esm-infra service because a couple of the packages that I have installed have been completely removed from the launchpad server. Specifically: deb http://ppa.launchpad.net/jonathonf/ffmpeg-3/ubuntu xenial main deb http://ppa.launchpad.net/jonathonf/python-3.6/ubuntu xenial main When I remove these package definitions from /etc/apt/sources.list.d/ the command succeeds. I've attached a log file that includes this stack trace. Traceback (most recent call last):   File "/usr/lib/python3/dist-packages/uaclient/cli.py", line 1629, in wrapper     return func(*args, **kwargs)   File "/usr/lib/python3/dist-packages/uaclient/cli.py", line 1725, in main     return args.action(args, cfg=cfg)   File "/usr/lib/python3/dist-packages/uaclient/cli.py", line 480, in action_fix     fix_status = security.fix_security_issue_id(cfg, args.security_issue)   File "/usr/lib/python3/dist-packages/uaclient/security.py", line 607, in fix_security_issue_id     usn_released_pkgs=usn_released_pkgs,   File "/usr/lib/python3/dist-packages/uaclient/security.py", line 982, in prompt_for_affected_packages     num_pkgs=count,   File "/usr/lib/python3/dist-packages/uaclient/security.py", line 872, in _handle_released_package_fixes     cfg, binary_pkgs, pocket   File "/usr/lib/python3/dist-packages/uaclient/security.py", line 1223, in upgrade_packages_and_attach     if not _check_subscription_for_required_service(pocket, cfg):   File "/usr/lib/python3/dist-packages/uaclient/security.py", line 1139, in _check_subscription_for_required_service     if _prompt_for_enable(cfg, ent.name):   File "/usr/lib/python3/dist-packages/uaclient/security.py", line 1118, in _prompt_for_enable     cfg,   File "/usr/lib/python3/dist-packages/uaclient/cli.py", line 200, in new_f     if cmd_args.format == "json" and not cmd_args.assume_yes: AttributeError: 'Namespace' object has no attribute 'format'
2022-06-19 14:36:24 Launchpad Janitor ubuntu-advantage-tools (Ubuntu): status Confirmed Fix Released