← Back to team overview

cloud-init-dev team mailing list archive

[Merge] ~daniel-thewatkins/cloud-init/+git/cloud-init:ubuntu/devel into cloud-init:ubuntu/devel

 

Dan Watkins has proposed merging ~daniel-thewatkins/cloud-init/+git/cloud-init:ubuntu/devel into cloud-init:ubuntu/devel.

Requested reviews:
  cloud-init commiters (cloud-init-dev)

For more details, see:
https://code.launchpad.net/~daniel-thewatkins/cloud-init/+git/cloud-init/+merge/365823
-- 
Your team cloud-init commiters is requested to review the proposed merge of ~daniel-thewatkins/cloud-init/+git/cloud-init:ubuntu/devel into cloud-init:ubuntu/devel.
diff --git a/cloudinit/sources/DataSourceScaleway.py b/cloudinit/sources/DataSourceScaleway.py
index 54bfc1f..b573b38 100644
--- a/cloudinit/sources/DataSourceScaleway.py
+++ b/cloudinit/sources/DataSourceScaleway.py
@@ -171,11 +171,10 @@ def query_data_api(api_type, api_address, retries, timeout):
 
 class DataSourceScaleway(sources.DataSource):
     dsname = "Scaleway"
+    update_events = {'network': [EventType.BOOT_NEW_INSTANCE, EventType.BOOT]}
 
     def __init__(self, sys_cfg, distro, paths):
         super(DataSourceScaleway, self).__init__(sys_cfg, distro, paths)
-        self.update_events = {
-            'network': {EventType.BOOT_NEW_INSTANCE, EventType.BOOT}}
 
         self.ds_cfg = util.mergemanydict([
             util.get_cfg_by_path(sys_cfg, ["datasource", "Scaleway"], {}),
diff --git a/cloudinit/sources/__init__.py b/cloudinit/sources/__init__.py
index 1604932..e6966b3 100644
--- a/cloudinit/sources/__init__.py
+++ b/cloudinit/sources/__init__.py
@@ -164,6 +164,9 @@ class DataSource(object):
     # A datasource which supports writing network config on each system boot
     # would call update_events['network'].add(EventType.BOOT).
 
+    # Default: generate network config on new instance id (first boot).
+    update_events = {'network': set([EventType.BOOT_NEW_INSTANCE])}
+
     # N-tuple listing default values for any metadata-related class
     # attributes cached on an instance by a process_data runs. These attribute
     # values are reset via clear_cached_attrs during any update_metadata call.
@@ -188,9 +191,6 @@ class DataSource(object):
         self.vendordata = None
         self.vendordata_raw = None
 
-        # Default: generate network config on new instance id (first boot).
-        self.update_events = {'network': {EventType.BOOT_NEW_INSTANCE}}
-
         self.ds_cfg = util.get_cfg_by_path(
             self.sys_cfg, ("datasource", self.dsname), {})
         if not self.ds_cfg:
diff --git a/cloudinit/sources/tests/test_init.py b/cloudinit/sources/tests/test_init.py
index cb1912b..6378e98 100644
--- a/cloudinit/sources/tests/test_init.py
+++ b/cloudinit/sources/tests/test_init.py
@@ -575,21 +575,6 @@ class TestDataSource(CiTestCase):
             " events: New instance first boot",
             self.logs.getvalue())
 
-    def test_data_sources_cant_mutate_update_events_for_others(self):
-        """update_events shouldn't be changed for other DSes (LP: #1819913)"""
-
-        class ModifyingDS(DataSource):
-
-            def __init__(self, sys_cfg, distro, paths):
-                # This mirrors what DataSourceAzure does which causes LP:
-                # #1819913
-                DataSource.__init__(self, sys_cfg, distro, paths)
-                self.update_events['network'].add(EventType.BOOT)
-
-        before_update_events = copy.deepcopy(self.datasource.update_events)
-        ModifyingDS(self.sys_cfg, self.distro, self.paths)
-        self.assertEqual(before_update_events, self.datasource.update_events)
-
 
 class TestRedactSensitiveData(CiTestCase):
 
diff --git a/debian/changelog b/debian/changelog
index f869278..0630854 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+cloud-init (18.5-62-g6322c2dd-0ubuntu1) disco; urgency=medium
+
+  * New upstream snapshot.
+    - Revert "DataSource: move update_events from a class to an instance..."
+
+ -- Daniel Watkins <oddbloke@xxxxxxxxxx>  Wed, 10 Apr 2019 16:23:25 -0400
+
 cloud-init (18.5-61-gb76714c3-0ubuntu1) disco; urgency=medium
 
   * New upstream snapshot.
diff --git a/tests/unittests/test_datasource/test_scaleway.py b/tests/unittests/test_datasource/test_scaleway.py
index 3bfd752..f96bf0a 100644
--- a/tests/unittests/test_datasource/test_scaleway.py
+++ b/tests/unittests/test_datasource/test_scaleway.py
@@ -7,7 +7,6 @@ import requests
 
 from cloudinit import helpers
 from cloudinit import settings
-from cloudinit.event import EventType
 from cloudinit.sources import DataSourceScaleway
 
 from cloudinit.tests.helpers import mock, HttprettyTestCase, CiTestCase
@@ -404,9 +403,3 @@ class TestDataSourceScaleway(HttprettyTestCase):
 
         netcfg = self.datasource.network_config
         self.assertEqual(netcfg, '0xdeadbeef')
-
-    def test_update_events_is_correct(self):
-        """ensure update_events contains correct data"""
-        self.assertEqual(
-            {'network': {EventType.BOOT_NEW_INSTANCE, EventType.BOOT}},
-            self.datasource.update_events)