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
diff --git a/tests/unittests/test_version.py b/cloudinit/tests/test_version.py
index d012f69..a96c2a4 100644
--- a/tests/unittests/test_version.py
+++ b/cloudinit/tests/test_version.py
@@ -3,6 +3,8 @@
3from cloudinit.tests.helpers import CiTestCase3from cloudinit.tests.helpers import CiTestCase
4from cloudinit import version4from cloudinit import version
55
6import mock
7
68
7class TestExportsFeatures(CiTestCase):9class TestExportsFeatures(CiTestCase):
8 def test_has_network_config_v1(self):10 def test_has_network_config_v1(self):
@@ -11,4 +13,19 @@ class TestExportsFeatures(CiTestCase):
11 def test_has_network_config_v2(self):13 def test_has_network_config_v2(self):
12 self.assertIn('NETWORK_CONFIG_V2', version.FEATURES)14 self.assertIn('NETWORK_CONFIG_V2', version.FEATURES)
1315
16
17class TestVersionString(CiTestCase):
18 @mock.patch("cloudinit.version._PACKAGED_VERSION",
19 "17.2-3-gb05b9972-0ubuntu1")
20 def test_package_version_respected(self):
21 """If _PACKAGED_VERSION is filled in, then it should be returned."""
22 self.assertEqual("17.2-3-gb05b9972-0ubuntu1", version.version_string())
23
24 @mock.patch("cloudinit.version._PACKAGED_VERSION", "@@PACKAGED_VERSION@@")
25 @mock.patch("cloudinit.version.__VERSION__", "17.2")
26 def test_package_version_skipped(self):
27 """If _PACKAGED_VERSION is not modified, then return __VERSION__."""
28 self.assertEqual("17.2", version.version_string())
29
30
14# vi: ts=4 expandtab31# vi: ts=4 expandtab
diff --git a/cloudinit/version.py b/cloudinit/version.py
index ccd0f84..ce3b8c1 100644
--- a/cloudinit/version.py
+++ b/cloudinit/version.py
@@ -5,6 +5,7 @@
5# This file is part of cloud-init. See LICENSE file for license information.5# This file is part of cloud-init. See LICENSE file for license information.
66
7__VERSION__ = "18.2"7__VERSION__ = "18.2"
8_PACKAGED_VERSION = '@@PACKAGED_VERSION@@'
89
9FEATURES = [10FEATURES = [
10 # supports network config version 111 # supports network config version 1
@@ -15,6 +16,9 @@ FEATURES = [
1516
1617
17def version_string():18def version_string():
19 """Extract a version string from cloud-init."""
20 if not _PACKAGED_VERSION.startswith('@@'):
21 return _PACKAGED_VERSION
18 return __VERSION__22 return __VERSION__
1923
20# vi: ts=4 expandtab24# vi: ts=4 expandtab
diff --git a/packages/debian/rules.in b/packages/debian/rules.in
index 4aa907e..e542c7f 100755
--- a/packages/debian/rules.in
+++ b/packages/debian/rules.in
@@ -3,6 +3,7 @@
3INIT_SYSTEM ?= systemd3INIT_SYSTEM ?= systemd
4export PYBUILD_INSTALL_ARGS=--init-system=$(INIT_SYSTEM)4export PYBUILD_INSTALL_ARGS=--init-system=$(INIT_SYSTEM)
5PYVER ?= python${pyver}5PYVER ?= python${pyver}
6DEB_VERSION := $(shell dpkg-parsechangelog --show-field=Version)
67
7%:8%:
8 dh $@ --with $(PYVER),systemd --buildsystem pybuild9 dh $@ --with $(PYVER),systemd --buildsystem pybuild
@@ -14,6 +15,7 @@ override_dh_install:
14 cp tools/21-cloudinit.conf debian/cloud-init/etc/rsyslog.d/21-cloudinit.conf15 cp tools/21-cloudinit.conf debian/cloud-init/etc/rsyslog.d/21-cloudinit.conf
15 install -D ./tools/Z99-cloud-locale-test.sh debian/cloud-init/etc/profile.d/Z99-cloud-locale-test.sh16 install -D ./tools/Z99-cloud-locale-test.sh debian/cloud-init/etc/profile.d/Z99-cloud-locale-test.sh
16 install -D ./tools/Z99-cloudinit-warnings.sh debian/cloud-init/etc/profile.d/Z99-cloudinit-warnings.sh17 install -D ./tools/Z99-cloudinit-warnings.sh debian/cloud-init/etc/profile.d/Z99-cloudinit-warnings.sh
18 flist=$$(find $(CURDIR)/debian/ -type f -name version.py) && sed -i 's,@@PACKAGED_VERSION@@,$(DEB_VERSION),' $${flist:-did-not-find-version-py-for-replacement}
1719
18override_dh_auto_test:20override_dh_auto_test:
19ifeq (,$(findstring nocheck,$(DEB_BUILD_OPTIONS)))21ifeq (,$(findstring nocheck,$(DEB_BUILD_OPTIONS)))

Subscribers

People subscribed via source and target branches