updateSeriesVersions() gets called too late in the initialization process

Bug #1434092 reported by Oleg Strikov
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
juju-core
New
Undecided
Unassigned

Bug Description

Juju uses internal table of known ubuntu releases which is called 'ubuntuSeries'
version/supportedseries.go:

var ubuntuSeries = map[string]string{
        "precise": "12.04",
        <...>
        "utopic": "14.10",
        "vivid": "15.04",
}

This table is used to convert 'VERSION_ID' (e.g. '15.04') provided by /etc/os-release into series name (e.g. 'vivid)
version/osversion.go:

func readSeries() (string, error) {
        <....>
        switch values["ID"] {
        case strings.ToLower(Ubuntu.String()):
                return getValue(ubuntuSeries, values["VERSION_ID"])
        <....>
        }
}

List of known ubuntu releases might be outdated.
To deal with that Juju tries to update this list against /usr/share/distro-info/ubuntu.csv available on the machine.
This happens inside updateDistroInfo() which is called by updateSeriesVersions() (both available at version/supportedseries.go).

Unfortunately, 'ubuntuSeries' table seems to be first accessed *before* it gets updated agains ubuntu.csv file.

Let's reproduce the situation when ubuntuSeries list is outdated.
To do that we 'create' an aditional ubuntu release which is not available at ubuntuSeries list.
I call it 'Whacky Worm' because it seems to be the official name of the next release.

Caution!
Following commands may do some damage to your machine.
Please backup files you plan to change or run these commands on a cloud instance you can recreate easily.

$ sudo tee -a /usr/share/distro-info/ubuntu.csv << EOF
15.10,Whacky Worm,whacky,2015-04-17,2015-10-23,2016-07-23
EOF

$ sudo tee /etc/os-release << EOF
NAME="Ubuntu"
VERSION="15.10 (Whacky Worm)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu Whacky Worm"
VERSION_ID="15.10"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
EOF

$ sudo tee /etc/lsb-release << EOF
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=15.10
DISTRIB_CODENAME=whacky
DISTRIB_DESCRIPTION="Ubuntu 15.10"
EOF

Our machine pretends to run 15.10 now (at least from Juju's standpoint because it reads only these files to identify release).

$ juju version
panic: osVersion reported an error: Could not determine series

This happens because 'VERSION_ID' from /etc/os-release identifies release as '15.10' but hardcoded 'ubuntuSeries' table doesn't contain this entry.
We added information about '15.10' to /usr/share/distro-info/ubuntu.csv before running 'juju version' but Juju didn't update 'ubuntuSeries' table as required.

To force Juju to update 'ubuntuSeries' table earlier I added a call to updateSeriesVersions() to readSeries() (available at version/osversion.go) which generates the initial error that gets propagated to other procedures:

--- a/version/osversion.go
+++ b/version/osversion.go
@@ -72,16 +72,17 @@ func getValue(from map[string]string, val string) (string, error) {
        return "unknown", errors.New("Could not determine series")
 }

 func readSeries() (string, error) {
        values, err := readOSRelease()
        if err != nil {
                return "unknown", err
        }
+ updateSeriesVersions()
        switch values["ID"] {
        case strings.ToLower(Ubuntu.String()):
                return getValue(ubuntuSeries, values["VERSION_ID"])
        case strings.ToLower(CentOS.String()):
                return getValue(centosSeries, values["VERSION_ID"])
        default:
                return "unknown", nil
        }

With this change our issue disappears:

$ juju version
1.24-alpha1-whacky-amd64

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.