Merge ~mgerdts/cloud-init:lp1765801.1 into cloud-init:master

Proposed by Mike Gerdts
Status: Merged
Approved by: Ryan Harper
Approved revision: caff922b0d2b430e597e9d86f46a4d2f22d8ec73
Merge reported by: Server Team CI bot
Merged at revision: not available
Proposed branch: ~mgerdts/cloud-init:lp1765801.1
Merge into: cloud-init:master
Diff against target: 70 lines (+15/-2)
2 files modified
cloudinit/sources/DataSourceSmartOS.py (+7/-1)
tests/unittests/test_datasource/test_smartos.py (+8/-1)
Reviewer Review Type Date Requested Status
Server Team CI bot continuous-integration Approve
Ryan Harper Approve
Review via email: mp+374989@code.launchpad.net

Commit message

DataSourceSmartOS: reconfigure network on each boot

In typical cases, SmartOS does not use DHCP for network configuration.
As such, if the network configuration changes that is reflected in
metadata and will be picked up during the next boot.

LP: #1765801
Joyent: OS-6902 cloud-init should reconfigure network on each boot

To post a comment you must log in.
Revision history for this message
Mike Gerdts (mgerdts) wrote :

I've created a fresh branch and submitted a new merge proposal to get past the bogus diff shown in https://code.launchpad.net/~mgerdts/cloud-init/+git/cloud-init/+merge/374987

Revision history for this message
Ryan Harper (raharper) wrote :

This looks fine to me. I'm pointing CI at this. One question, in the previous Merge Proposal there was a comment around emitting network: {config: disabled} in some cases. Is that related to this change?

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

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

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

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

Discussed in IRC, the comment around disabling network-config is not currently relevant.
This passed CI and looks good to me.

Thanks!

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

Commit message lints:
- Line #7 has 3 too many characters. Line starts with: "Joyent: OS-6902 cloud-init"...

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/cloudinit/sources/DataSourceSmartOS.py b/cloudinit/sources/DataSourceSmartOS.py
2index 32b57cd..cf67650 100644
3--- a/cloudinit/sources/DataSourceSmartOS.py
4+++ b/cloudinit/sources/DataSourceSmartOS.py
5@@ -1,5 +1,5 @@
6 # Copyright (C) 2013 Canonical Ltd.
7-# Copyright (c) 2018, Joyent, Inc.
8+# Copyright 2019 Joyent, Inc.
9 #
10 # Author: Ben Howard <ben.howard@canonical.com>
11 #
12@@ -34,6 +34,7 @@ from cloudinit import log as logging
13 from cloudinit import serial
14 from cloudinit import sources
15 from cloudinit import util
16+from cloudinit.event import EventType
17
18 LOG = logging.getLogger(__name__)
19
20@@ -178,6 +179,7 @@ class DataSourceSmartOS(sources.DataSource):
21 self.metadata = {}
22 self.network_data = None
23 self._network_config = None
24+ self.update_events['network'].add(EventType.BOOT)
25
26 self.script_base_d = os.path.join(self.paths.get_cpath("scripts"))
27
28@@ -319,6 +321,10 @@ class DataSourceSmartOS(sources.DataSource):
29
30 @property
31 def network_config(self):
32+ # sources.clear_cached_data() may set _network_config to '_unset'.
33+ if self._network_config == sources.UNSET:
34+ self._network_config = None
35+
36 if self._network_config is None:
37 if self.network_data is not None:
38 self._network_config = (
39diff --git a/tests/unittests/test_datasource/test_smartos.py b/tests/unittests/test_datasource/test_smartos.py
40index 42ac697..d5b1c29 100644
41--- a/tests/unittests/test_datasource/test_smartos.py
42+++ b/tests/unittests/test_datasource/test_smartos.py
43@@ -1,5 +1,5 @@
44 # Copyright (C) 2013 Canonical Ltd.
45-# Copyright (c) 2018, Joyent, Inc.
46+# Copyright 2019 Joyent, Inc.
47 #
48 # Author: Ben Howard <ben.howard@canonical.com>
49 #
50@@ -31,6 +31,7 @@ from cloudinit.sources.DataSourceSmartOS import (
51 convert_smartos_network_data as convert_net,
52 SMARTOS_ENV_KVM, SERIAL_DEVICE, get_smartos_environ,
53 identify_file)
54+from cloudinit.event import EventType
55
56 import six
57
58@@ -653,6 +654,12 @@ class TestSmartOSDataSource(FilesystemMockingTestCase):
59 self.assertEqual(dsrc.device_name_to_device('FOO'),
60 mydscfg['disk_aliases']['FOO'])
61
62+ def test_reconfig_network_on_boot(self):
63+ # Test to ensure that network is configured from metadata on each boot
64+ dsrc = self._get_ds(mockdata=MOCK_RETURNS)
65+ self.assertSetEqual(set([EventType.BOOT_NEW_INSTANCE, EventType.BOOT]),
66+ dsrc.update_events['network'])
67+
68
69 class TestIdentifyFile(CiTestCase):
70 """Test the 'identify_file' utility."""

Subscribers

People subscribed via source and target branches