Merge ~smoser/cloud-init:feature/full-version-in-logs into cloud-init:master

Proposed by Scott Moser
Status: Merged
Approved by: Scott Moser
Approved revision: 301ab4b33c8a072cb721f408621f4ddd7d326d2d
Merge reported by: Scott Moser
Merged at revision: 5446c788160412189200c6cc688b14c9f9071943
Proposed branch: ~smoser/cloud-init:feature/full-version-in-logs
Merge into: cloud-init:master
Diff against target: 75 lines (+23/-0)
3 files modified
cloudinit/tests/test_version.py (+17/-0)
cloudinit/version.py (+4/-0)
packages/debian/rules.in (+2/-0)
Reviewer Review Type Date Requested Status
Server Team CI bot continuous-integration Approve
Chad Smith Approve
Ryan Harper Approve
Review via email: mp+346429@code.launchpad.net

Commit message

Update version.version_string to contain packaged version.

This modifies version.version_string to support having the package
build write the *packaged* version in with a easy replace.
Then, when cloud-init reports its version it will include the full
packaged version.

Also modified here are upstream package build files to get that done.

Note part of the trickery in packages/debian/rules.in was to avoid
the 'basic' templater consuming the '$variable' variable names.

LP: #1770712

Description of the change

see commit message

To post a comment you must log in.
Revision history for this message
Server Team CI bot (server-team-bot) wrote :

FAILED: Continuous integration, rev:83115a059ef0003a35788a1bec2f5f32c3a2bd04
https://jenkins.ubuntu.com/server/job/cloud-init-ci/21/
Executed test runs:
    SUCCESS: Checkout
    FAILED: Unit & Style Tests

Click here to trigger a rebuild:
https://jenkins.ubuntu.com/server/job/cloud-init-ci/21/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Server Team CI bot (server-team-bot) wrote :

FAILED: Continuous integration, rev:84c4610cf8bfb8be123bbc9eba0c3616ef380069
https://jenkins.ubuntu.com/server/job/cloud-init-ci/22/
Executed test runs:
    SUCCESS: Checkout
    FAILED: Unit & Style Tests

Click here to trigger a rebuild:
https://jenkins.ubuntu.com/server/job/cloud-init-ci/22/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Ryan Harper (raharper) wrote :

Nice!

review: Approve
Revision history for this message
Chad Smith (chad.smith) wrote :

cloudinit/tests/test_version.py:25:5: E303 too many blank lines (2)

Other than pycodestyle, +1.

review: Approve
Revision history for this message
Server Team CI bot (server-team-bot) wrote :

PASSED: Continuous integration, rev:318c66ee34d6727797a573276fc40272660a83aa
https://jenkins.ubuntu.com/server/job/cloud-init-ci/25/
Executed test runs:
    SUCCESS: Checkout
    SUCCESS: Unit & Style Tests
    SUCCESS: Ubuntu LTS: Build
    SUCCESS: Ubuntu LTS: Integration
    SUCCESS: MAAS Compatability Testing
    IN_PROGRESS: Declarative: Post Actions

Click here to trigger a rebuild:
https://jenkins.ubuntu.com/server/job/cloud-init-ci/25/rebuild

review: Approve (continuous-integration)
Revision history for this message
Server Team CI bot (server-team-bot) wrote :

PASSED: Continuous integration, rev:301ab4b33c8a072cb721f408621f4ddd7d326d2d
https://jenkins.ubuntu.com/server/job/cloud-init-ci/27/
Executed test runs:
    SUCCESS: Checkout
    SUCCESS: Unit & Style Tests
    SUCCESS: Ubuntu LTS: Build
    SUCCESS: Ubuntu LTS: Integration
    SUCCESS: MAAS Compatability Testing
    IN_PROGRESS: Declarative: Post Actions

Click here to trigger a rebuild:
https://jenkins.ubuntu.com/server/job/cloud-init-ci/27/rebuild

review: Approve (continuous-integration)
Revision history for this message
Scott Moser (smoser) wrote :

An upstream commit landed for this bug.

To view that commit see the following URL:
https://git.launchpad.net/cloud-init/commit/?id=5446c788

There was an error fetching revisions from git servers. Please try again in a few minutes. If the problem persists, contact Launchpad support.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/tests/unittests/test_version.py b/cloudinit/tests/test_version.py
2index d012f69..a96c2a4 100644
3--- a/tests/unittests/test_version.py
4+++ b/cloudinit/tests/test_version.py
5@@ -3,6 +3,8 @@
6 from cloudinit.tests.helpers import CiTestCase
7 from cloudinit import version
8
9+import mock
10+
11
12 class TestExportsFeatures(CiTestCase):
13 def test_has_network_config_v1(self):
14@@ -11,4 +13,19 @@ class TestExportsFeatures(CiTestCase):
15 def test_has_network_config_v2(self):
16 self.assertIn('NETWORK_CONFIG_V2', version.FEATURES)
17
18+
19+class TestVersionString(CiTestCase):
20+ @mock.patch("cloudinit.version._PACKAGED_VERSION",
21+ "17.2-3-gb05b9972-0ubuntu1")
22+ def test_package_version_respected(self):
23+ """If _PACKAGED_VERSION is filled in, then it should be returned."""
24+ self.assertEqual("17.2-3-gb05b9972-0ubuntu1", version.version_string())
25+
26+ @mock.patch("cloudinit.version._PACKAGED_VERSION", "@@PACKAGED_VERSION@@")
27+ @mock.patch("cloudinit.version.__VERSION__", "17.2")
28+ def test_package_version_skipped(self):
29+ """If _PACKAGED_VERSION is not modified, then return __VERSION__."""
30+ self.assertEqual("17.2", version.version_string())
31+
32+
33 # vi: ts=4 expandtab
34diff --git a/cloudinit/version.py b/cloudinit/version.py
35index ccd0f84..ce3b8c1 100644
36--- a/cloudinit/version.py
37+++ b/cloudinit/version.py
38@@ -5,6 +5,7 @@
39 # This file is part of cloud-init. See LICENSE file for license information.
40
41 __VERSION__ = "18.2"
42+_PACKAGED_VERSION = '@@PACKAGED_VERSION@@'
43
44 FEATURES = [
45 # supports network config version 1
46@@ -15,6 +16,9 @@ FEATURES = [
47
48
49 def version_string():
50+ """Extract a version string from cloud-init."""
51+ if not _PACKAGED_VERSION.startswith('@@'):
52+ return _PACKAGED_VERSION
53 return __VERSION__
54
55 # vi: ts=4 expandtab
56diff --git a/packages/debian/rules.in b/packages/debian/rules.in
57index 4aa907e..e542c7f 100755
58--- a/packages/debian/rules.in
59+++ b/packages/debian/rules.in
60@@ -3,6 +3,7 @@
61 INIT_SYSTEM ?= systemd
62 export PYBUILD_INSTALL_ARGS=--init-system=$(INIT_SYSTEM)
63 PYVER ?= python${pyver}
64+DEB_VERSION := $(shell dpkg-parsechangelog --show-field=Version)
65
66 %:
67 dh $@ --with $(PYVER),systemd --buildsystem pybuild
68@@ -14,6 +15,7 @@ override_dh_install:
69 cp tools/21-cloudinit.conf debian/cloud-init/etc/rsyslog.d/21-cloudinit.conf
70 install -D ./tools/Z99-cloud-locale-test.sh debian/cloud-init/etc/profile.d/Z99-cloud-locale-test.sh
71 install -D ./tools/Z99-cloudinit-warnings.sh debian/cloud-init/etc/profile.d/Z99-cloudinit-warnings.sh
72+ flist=$$(find $(CURDIR)/debian/ -type f -name version.py) && sed -i 's,@@PACKAGED_VERSION@@,$(DEB_VERSION),' $${flist:-did-not-find-version-py-for-replacement}
73
74 override_dh_auto_test:
75 ifeq (,$(findstring nocheck,$(DEB_BUILD_OPTIONS)))

Subscribers

People subscribed via source and target branches