Thank you for this submission. I was awaiting feedback on this bug to
determine if you'd like to solve the outstanding issue that Extend...
links aren't presented on the software-properties-gtk UI for unattached
machines (and/or) dropping the error messages from the console. But, as
you mentioned error console messaging isn't presented to the UI so this
is a non-issue that we can remedy in future uploads.


That said, I also discovered that changes in ubuntu-advantage-tools 27.2
which have already SRU'd into xenial, bionic, focal and render this
current logic broken.


I've filed LP: #1939732 to capture upcoming features needed in the UI to better 
inform about Extending your support if desired on Bionic/Focal etc.

LP 1939732 could be fixed by this diff:

--- /usr/lib/python3/dist-packages/softwareproperties/gtk/utils.py.old  
2021-08-12 13:56:59.695413561 -0600
+++ /usr/lib/python3/dist-packages/softwareproperties/gtk/utils.py      
2021-08-12 14:12:28.597659801 -0600
@@ -26,6 +26,7 @@
 gi.require_version("Gtk", "3.0")
 from gi.repository import Gio, Gtk
 import json
+import os
 import subprocess
 
 import logging
@@ -79,24 +80,20 @@
     # which has already run `ua status`. Calling ua status directly on
     # network disconnected machines will raise a TimeoutException trying to
     # access contracts.canonical.com/v1/resources.
-    try:
-        # Success writes UA_STATUS_JSON
-        result = subprocess.run(['ua', 'status', '--format=json'], 
stdout=subprocess.PIPE)
-    except Exception as e:
-        print("Failed to call ubuntu advantage client:\n%s" % e)
-        return {}
-    if result.returncode != 0:
-        print("Ubuntu advantage client returned code %d" % result.returncode)
-        return {}
-
-    try:
-        status_file = open(UA_STATUS_JSON, "r")
-    except Exception as e:
-        print("No ua status file written:\n%s" % e)
-        return {}
-
-    with status_file as stream:
-        status_json = stream.read()
+    if os.path.exists(UA_STATUS_JSON):
+        with open(UA_STATUS_JSON) as stream:
+           status_json = stream.read()
+    else:
+        try:
+            # Success writes UA_STATUS_JSON
+            result = subprocess.run(['ua', 'status', '--format=json'], 
stdout=subprocess.PIPE)
+        except Exception as e:
+            print("Failed to call ubuntu advantage client:\n%s" % e)
+            return {}
+        if result.returncode != 0:
+            print("Ubuntu advantage client returned code %d" % 
result.returncode)
+            return {}
+        status_json = result.stdout
     try:
         status = json.loads(status_json)
     except json.JSONDecodeError as e:



 The UX "updates" tab no longer can correctly determine that the machine is 
attached because a new field "available" has been published in status.json. 


Current utils.py:get_ua_service_status relies on a now incorrect check:

            if service.get("available"):  # then we are not attached
                if service["available"] == "yes":
                     available = True
                     service_status = "disabled"  # Disabled since unattached

Since ua status output on attach machines now provides "available":
"yes" in version 27.2 it broke the assumption that "available" keys
represented a detached system.

This 2nd issue could be fixed by this diff

--- /usr/lib/python3/dist-packages/softwareproperties/gtk/utils.py.old  
2021-08-12 13:56:59.695413561 -0600
+++ /usr/lib/python3/dist-packages/softwareproperties/gtk/utils.py      
2021-08-12 13:57:13.951629355 -0600
@@ -123,7 +123,7 @@
     service_status = "n/a"
     for service in status.get("services", []):
         if service.get("name") == service_name:
-            if service.get("available"):  # then we are not attached
+            if status.get("attached", False) == False:  # we are not attached
                 if service["available"] == "yes":
                      available = True
                      service_status = "disabled"  # Disabled since unattached



the third issue is that the contract expiry date format of v 27.2 doesn't 
conform to software-properties-gtk expectations: with the above patches, we 
still see issues with ability to decode the expiry string in the console

unconverted data remains: +00:00 (<--- added print of the exception msg)
Unable to determine UA contract expiry


this patch would be needed to suport expiry datestring formatting for ua-tools 
27.2 in bionic focal etc
--- 
/usr/lib/python3/dist-packages/softwareproperties/gtk/SoftwarePropertiesGtk.py.old
  2021-08-12 14:43:33.570530853 -0600
+++ 
/usr/lib/python3/dist-packages/softwareproperties/gtk/SoftwarePropertiesGtk.py  
    2021-08-12 14:43:50.594751621 -0600
@@ -394,8 +394,11 @@
                 # gives software properties dialogs a chance to interact about
                 # renewals if needed.
                 try:
+                        # Ignore timezone to simplify formatting python < 3.7
+                        # 3.7+ has datetime.fromisoformat()
+                        dt, _sep, _tz = status.get("expires").partition("+")
                         eol_date = datetime.datetime.strptime(
-                                status.get("expires"), "%Y-%m-%dT%H:%M:%S"
+                                dt, "%Y-%m-%dT%H:%M:%S"
                         ).date()
                 except ValueError:
                         print("Unable to determine UA contract expiry")





The combined patches required against this upload is as follows:
https://paste.ubuntu.com/p/cgC56mTZ6g/




** Tags removed: verification-needed verification-needed-bionic 
verification-needed-focal verification-needed-hirsute
** Tags added: verification-failed verification-failed-bionic 
verification-failed-focal verification-failed-hirsute

-- 
You received this bug notification because you are a member of Ubuntu
Touch seeded packages, which is subscribed to software-properties in
Ubuntu.
https://bugs.launchpad.net/bugs/1920836

Title:
  Show Extended Security Maintenence status

Status in software-properties package in Ubuntu:
  Fix Released
Status in software-properties source package in Xenial:
  New
Status in software-properties source package in Bionic:
  Fix Committed
Status in software-properties source package in Focal:
  Fix Committed
Status in software-properties source package in Hirsute:
  Fix Committed

Bug description:
  [Impact]
  There is not currently a graphical method of determining if a system is 
subscribed to [Extended Security Maintenance](https://ubuntu.com/security/esm) 
updates. This is resolved by adding some [new 
UI](https://wiki.ubuntu.com/SoftwareUpdates#Extended_Security_Maintenance) to 
the software properties application.

  [Test Case]
  1. Install latest version of Ubuntu advantage:
  $ sudo add-apt-repository ppa:ua-client/stable
  $ sudo apt update
  $ sudo apt upgrade
  2. Open Software Properties
  3. Go to Updates tab.

  Expected result:
  Information is shown that indicates if this system is using Extended Security 
Maintenance updates, when updates will supported until, and a link to upgrade 
to ESM.

  Observed result:
  No ESM information currently shown.

  [Where problems could occur]
  - Software properties could hit a bug getting a response from the ua app. The 
current code carefully checks if and what is returned, falling back to a safe 
default behavior.
  - Launching software properties could trigger a bug in the ua app.
  - Software properties could show incorrect information, causing confusion for 
the user. The solution uses information from distro-info and the ua app which 
means software-properties contains no data about ESM, and instead relies on 
these apps that can be updated if things change.

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/software-properties/+bug/1920836/+subscriptions


-- 
Mailing list: https://launchpad.net/~touch-packages
Post to     : touch-packages@lists.launchpad.net
Unsubscribe : https://launchpad.net/~touch-packages
More help   : https://help.launchpad.net/ListHelp

Reply via email to