Merge ~philroche/maas-images:bugfix/esm-eol-keyerror into maas-images:master

Proposed by Philip Roche
Status: Merged
Merge reported by: Andres Rodriguez
Merged at revision: a45f3e3c8d3bde939091d8b3129afb97387b1372
Proposed branch: ~philroche/maas-images:bugfix/esm-eol-keyerror
Merge into: maas-images:master
Diff against target: 31 lines (+8/-2)
1 file modified
meph2/ubuntu_info.py (+8/-2)
Reviewer Review Type Date Requested Status
Andres Rodriguez (community) Approve
Robert C Jennings (community) Approve
Review via email: mp+366911@code.launchpad.net

Commit message

ESM EOL code must support running on systems with older versions of python-distro-info

This was discovered when running this on Ubuntu Precise with python-distro-info 0.8.2ubuntu1
and distro-info-data 0.8ubuntu0.17

When running on a system like this the _rows attribute is used and as such the dict
key for ESM EOL is eol-esm and not eol_esm as it is on newer systems where we use a
dict representation of DistroRelease objects instead.

Description of the change

ESM EOL code must support running on systems with older versions of python-distro-info

This was discovered when running this on Ubuntu Precise with python-distro-info 0.8.2ubuntu1
and distro-info-data 0.8ubuntu0.17

When running on a system like this the _rows attribute is used and as such the dict
key for ESM EOL is eol-esm and not eol_esm as it is on newer systems where we use a
dict representation of DistroRelease objects instead.

To post a comment you must log in.
Revision history for this message
Philip Roche (philroche) wrote :

Following on from MP https://code.launchpad.net/~philroche/maas-images/+git/maas-images/+merge/366852

I am opening this MP to add another fix for issue found in https://cloud-images-jenkins.canonical.com/job/MAAS_v2_MasterBuilder/ARCH_TYPE=amd64/1442/console

```
10:51:54 if hack_all[codename]['eol_esm']:
10:51:54 KeyError: 'eol_esm'
```

I could not replicate this locally but could when testing on a 12.04 system with ESM.

Revision history for this message
Robert C Jennings (rcj) wrote :

This looks sane.

review: Approve
Revision history for this message
Andres Rodriguez (andreserl) wrote :

Lgtm! This will need to be landed manually as there is no longer setup for this repo!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/meph2/ubuntu_info.py b/meph2/ubuntu_info.py
2index 032ee5f..53775be 100644
3--- a/meph2/ubuntu_info.py
4+++ b/meph2/ubuntu_info.py
5@@ -74,18 +74,24 @@ def get_ubuntu_info(date=None):
6 # hack_all, because we're using '_rows', which is not supported
7 # however it is the only real way to get at EOL, and is convenient
8 # series there is codename to us
9+ eol_esm_key = "eol-esm"
10 try:
11 ubuntu_rows = udi._rows
12 except AttributeError:
13 ubuntu_rows = [row.__dict__ for row in udi._releases]
14+ # if we are using _rows directly then the dict
15+ # key for ESM eol is different to when we use a
16+ # dict representation of DistroRelease objects
17+ eol_esm_key = "eol_esm"
18
19 hack_all = {i['series']: i for i in ubuntu_rows}
20 for i, codename in enumerate(codenames):
21 title = "%s LTS" % versions[i] if lts[i] else versions[i]
22 eol = hack_all[codename]['eol'].strftime("%Y-%m-%d")
23
24- if hack_all[codename]['eol_esm']:
25- eol_esm = hack_all[codename]['eol_esm'].strftime("%Y-%m-%d")
26+ if eol_esm_key in hack_all[codename] and \
27+ hack_all[codename][eol_esm_key]:
28+ eol_esm = hack_all[codename][eol_esm_key].strftime("%Y-%m-%d")
29 else:
30 # If eol_esm is None then this release does not receive ESM support
31 # As such we should set the esm_eol to the same as eol

Subscribers

People subscribed via source and target branches