[SRU] Error when parsing lsb_release, landscape-package-reporter unable to report package list to server

Bug #2031036 reported by Steven LaCosse
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Landscape Client
Fix Committed
Undecided
Unassigned
landscape-client (Ubuntu)
Invalid
Undecided
Unassigned
Focal
Won't Fix
Undecided
Unassigned
Jammy
Fix Released
Undecided
Unassigned

Bug Description

[ Impact ]

 * The version of Landscape Client in the Ubuntu main repository for Focal and Jammy fails to report package information Landscape Server when the client machine has lsb modules installed (ex. lsb-core) as a `ValueError` is raised when attempting to parse the output.
 * This was fixed upstream prior to being released so Noble, so Noble and later are not affected.

[ Test Plan ]

 * `sudo apt update && sudo apt install -y landscape-client`

 * `lsb_release -a # Check no lsb modules`

 * `sudo apt-get install -y lsb-core # install lsb module`

 * `sudo landscape-config --silent --url="$LANDSCAPE_ROOT_URL/message-system" --ping-url="$LANDSCAPE_ROOT_URL/ping" --account-name $ACCOUNT_NAME --registration-key $REGISTRATION_KEY --computer-title $HOSTNAME`

 * Accept the machine's registration if needed and wait for package reporting to (try and) check the logs:

     * tail /var/log/landscape/package-reporter.log

 * You should see `ValueError: too many values to unpack`.

 * In a fresh instance, install an LSB module (ex. `lsb-core`) and the proposed version of Landscape Client.

 * Now register the client with Landscape Server, wait for package-reporter to run again and verify no errors are raised.

 * Additionally, make sure that package-reporter can report package information to the server properly.

[ Where problems could occur ]

 * Because the fix also changed the approach to read the os-release file instead of the lsb_release command output, this could introduce unforeseen behavior with code that was written with the original implementation in mind.

 * However, without these fixes, Landscape Client cannot report package data with lsb modules installed so it is hard to imagine how this would be worse.

[ Other Info ]

 * GH PR for the fix: https://github.com/canonical/landscape-client/pull/170

--------

Original bug report below:

--------

Package reporter from landscape client is failing to report to server because seemingly of a lsb parse issue.

/var/log/landscape/package-reporter.log

2023-08-10 13:42:00,414 ERROR [MainThread] None
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/twisted/internet/defer.py", line 653, in _runCallbacks
    current.result = callback(current.result, *args, **kw)
  File "/usr/lib/python3/dist-packages/landscape/client/package/taskhandler.py", line 217, in got_server_uuid
    lsb_release_info = parse_lsb_release(self.lsb_release_filename)
  File "/usr/lib/python3/dist-packages/landscape/lib/lsb_release.py", line 31, in parse_lsb_release
    dist, desc, release, code_name, _ = lsb_info.decode().split("\n")
ValueError: too many values to unpack (expected 5)

Multiple LSB Packages are installed

/usr/bin/lsb_release
LSB Version: core-9.20170808ubuntu1-noarch:printing-9.20170808ubuntu1-noarch:security-9.20170808ubuntu1-noarch

lsb_release -a
LSB Version: core-9.20170808ubuntu1-noarch:printing-9.20170808ubuntu1-noarch:security-9.20170808ubuntu1-noarch
Distributor ID: Ubuntu
Description: Ubuntu 18.04.3 LTS
Release: 18.04
Codename: bionic

Related branches

description: updated
description: updated
description: updated
Revision history for this message
Steven LaCosse (motosteven) wrote :

I have a workaround to point back to /etc/lsb-release filename in /usr/lib/python3/dist-packages/landscape/lib/lsb_release.py

Looks like issue was introduced by

https://git.launchpad.net/~landscape/landscape-client/+git/master/commit/?id=78c8c9568913b02d7df997437aa3aa5d832f7fb1

Revision history for this message
Juanmi Taboada (juanmitaboada) wrote (last edit ):

I have:
- Added tests for no LSB modules and several modules
- Improved parse_lsb_release() function to recognize modules

The solution has been provided in:
https://github.com/canonical/landscape-client/pull/170

Changed in landscape-client:
status: New → In Progress
Revision history for this message
Mitch Burton (mitchburton) wrote :

May I suggest we move away from parsing lsb_release output (or file) and instead use /etc/os-release or /usr/lib/os-release? I think generally it's more standardized.

See example: https://github.com/Perfect5th/landscape-client/blob/c5f6a4b673eb5f86281a8183242ae26e8580ca6b/landscape/lib/lsb_release.py#L73-L87

Revision history for this message
Juanmi Taboada (juanmitaboada) wrote : Re: [Bug 2031036] Re: Error when parsing lsb_release, landscape-package-reporter unable to report package list to server

I agree with you. I will have a look on it.

On Fri, 11 Aug 2023, 23:55 Mitch Burton, <email address hidden> wrote:

> May I suggest we move away from parsing lsb_release output (or file) and
> instead use /etc/os-release or /usr/lib/os-release? I think generally
> it's more standardized.
>
> See example: https://github.com/Perfect5th/landscape-
>
> client/blob/c5f6a4b673eb5f86281a8183242ae26e8580ca6b/landscape/lib/lsb_release.py#L73-L87
>
> --
> You received this bug notification because you are subscribed to
> Landscape Project.
> Matching subscriptions: Landscape Project
> https://bugs.launchpad.net/bugs/2031036
>
> Title:
> Error when parsing lsb_release, landscape-package-reporter unable to
> report package list to server
>
> Status in Landscape Client:
> In Progress
>
> Bug description:
> Package reporter from landscape client is failing to report to server
> because seemingly of a lsb parse issue.
>
> /var/log/landscape/package-reporter.log
>
> 2023-08-10 13:42:00,414 ERROR [MainThread] None
> Traceback (most recent call last):
> File "/usr/lib/python3/dist-packages/twisted/internet/defer.py", line
> 653, in _runCallbacks
> current.result = callback(current.result, *args, **kw)
> File
> "/usr/lib/python3/dist-packages/landscape/client/package/taskhandler.py",
> line 217, in got_server_uuid
> lsb_release_info = parse_lsb_release(self.lsb_release_filename)
> File "/usr/lib/python3/dist-packages/landscape/lib/lsb_release.py",
> line 31, in parse_lsb_release
> dist, desc, release, code_name, _ = lsb_info.decode().split("\n")
> ValueError: too many values to unpack (expected 5)
>
> Multiple LSB Packages are installed
>
> /usr/bin/lsb_release
> LSB Version:
> core-9.20170808ubuntu1-noarch:printing-9.20170808ubuntu1-noarch:security-9.20170808ubuntu1-noarch
>
> lsb_release -a
> LSB Version:
> core-9.20170808ubuntu1-noarch:printing-9.20170808ubuntu1-noarch:security-9.20170808ubuntu1-noarch
> Distributor ID: Ubuntu
> Description: Ubuntu 18.04.3 LTS
> Release: 18.04
> Codename: bionic
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/landscape-client/+bug/2031036/+subscriptions
>
>

Revision history for this message
Juanmi Taboada (juanmitaboada) wrote : Re: Error when parsing lsb_release, landscape-package-reporter unable to report package list to server

I just sent an update on the PR related to this issue.

Changed in landscape-client:
status: In Progress → Fix Committed
description: updated
description: updated
description: updated
description: updated
description: updated
description: updated
description: updated
description: updated
description: updated
description: updated
description: updated
description: updated
Revision history for this message
Dave Jones (waveform) wrote :

Targetting for focal and jammy, marking invalid for development release and adding [SRU] tag to title.

Changed in landscape-client (Ubuntu):
status: New → Invalid
Changed in landscape-client (Ubuntu Focal):
status: New → Triaged
Changed in landscape-client (Ubuntu Jammy):
status: New → Triaged
summary: - Error when parsing lsb_release, landscape-package-reporter unable to
- report package list to server
+ [SRU] Error when parsing lsb_release, landscape-package-reporter unable
+ to report package list to server
Revision history for this message
Andreas Hasenack (ahasenack) wrote :

Focal is EOSS, closing.

Changed in landscape-client (Ubuntu Focal):
status: Triaged → Won't Fix
description: updated
Revision history for this message
Nick Rosbrook (enr0n) wrote : Proposed package upload rejected

An upload of landscape-client to jammy-proposed has been rejected from the upload queue for the following reason: "Please re-upload with the latest patch from LP: #2087852, which will unblock the version currently in jammy-proposed.".

Revision history for this message
Andreas Hasenack (ahasenack) wrote : Please test proposed package

Hello Steven, or anyone else affected,

Accepted landscape-client into jammy-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/landscape-client/23.02-0ubuntu1~22.04.6 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-jammy to verification-done-jammy. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-jammy. 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 landscape-client (Ubuntu Jammy):
status: Triaged → Fix Committed
tags: added: verification-needed verification-needed-jammy
Revision history for this message
Jan-Yaeger Dhillon (jansdhillon) wrote (last edit ):
Download full text (5.2 KiB)

I have been testing the proposed package against the test plan and I'm happy to report this passes validation! See the steps I took below.

---

Install terraform and LXD

    sudo snap install terraform --classic
    sudo snap install lxd

Make sure you're in the `lxd` group:

    if ! getent group lxd | grep "$USER"; then
        sudo usermod -aG lxd "$USER"
        newgrp lxd
    fi

If you've not already set up LXD do so now:

    lxd init --minimal

Start up Landscape Server, enable autoregistration and get the registration info.

Create a file called `main.tf` and paste the following, making sure to replace the server/pro info. This will create two jammy instances, one with the proposed version of Landscape Client and one with the current version in the jammy archives, install lsb-core in them, and then register them with Landscape Server. Then, it will run the provided `runcmd`:

    module "landscape-client" {
        source = "jansdhillon/landscape-client/lxd"
        version = "1.0.5"
        pro_token = "xxxxx" # replace with real pro token
        account_name = "onward"
        landscape_root_url = "10.1.77.207"
        registration_key = "key"
        image_alias = "jammy"

        instances = [
            {
            client_config = {
                computer_title = "jammy-lp2031036-proposed-validator"
                ping_interval = 10
                exchange_interval = 10
                urgent_exchange_interval = 10
            }

            landscape_client_package = "landscape-client=23.02-0ubuntu1~22.04.6"

            files = [
                {
                content = <<EOT
                Package: landscape-client landscape-common
                Pin: release a=jammy-proposed
                Pin-Priority: 600
                EOT
                target_path = "/etc/apt/preferences.d/proposed"
                }
            ]

            additional_cloud_init = <<EOT
            #cloud-config
            apt:
                sources:
                    jammy-proposed:
                        source: "deb http://archive.ubuntu.com/ubuntu jammy-proposed main restricted universe multiverse"

            package-upgrades: true
            packages:
                - lsb-core
            runcmd:
                - mkdir -p /tmp/landscape
                - 'sleep 60 && grep "ValueError: too many values to unpack" /var/log/landscape/package-reporter.log > /tmp/landscape/value-error-result.txt'
            EOT

            },
            {
            client_config = {
                computer_title = "jammy-lp2031036-control-validator"
                ping_interval = 10
                exchange_interval = 10
                urgent_exchange_interval = 10
            }

            landscape_client_package = "landscape-client=23.02-0ubuntu1~22.04.4"

            additional_cloud_init = <<EOT
            #cloud-config
            package-upgrades: true
            packages:
                - lsb-core
            runcmd:
                - mkdir -p /tmp/landscape
                - 'sleep 60 && grep "ValueError: too many...

Read more...

tags: added: verification-done-jammy
removed: verification-needed-jammy
tags: removed: verification-needed
Revision history for this message
Julian Andres Klode (juliank) wrote : Update Released

The verification of the Stable Release Update for landscape-client 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.

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package landscape-client - 23.02-0ubuntu1~22.04.6

---------------
landscape-client (23.02-0ubuntu1~22.04.6) jammy; urgency=medium

  * d/p/package-reporter-high-cpu.patch: backport fix to reduce CPU usage of
    package-reporter by avoiding creating Origin objects from the Python
    apt package. (LP: #2099283)
  * d/p/parse-lsb-output.patch: backport fix for error raised by package-reporter
    when parsing lsb output and add support for lsb modules. (LP: #2031036)

landscape-client (23.02-0ubuntu1~22.04.5) jammy; urgency=medium

  * d/p/2087852-feat-manage-ubuntu-sources-glob.patch: include DEB822
    formatted sources when managing apt sources by regex matching .sources
    files (LP: #2087852)

 -- Jan-Yaeger Dhillon <email address hidden> Fri, 9 May 2025 11:19:45 -0700

Changed in landscape-client (Ubuntu Jammy):
status: Fix Committed → 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.