Merge ~chad.smith/cloud-init:ubuntu/xenial into cloud-init:ubuntu/xenial
- Git
- lp:~chad.smith/cloud-init
- ubuntu/xenial
- Merge into ubuntu/xenial
Status: | Merged |
---|---|
Merged at revision: | 833adcdf6f85ec2305e62bea5a20f9363bf95507 |
Proposed branch: | ~chad.smith/cloud-init:ubuntu/xenial |
Merge into: | cloud-init:ubuntu/xenial |
Diff against target: |
292 lines (+264/-0) 4 files modified
debian/changelog (+11/-0) debian/patches/azure-apply-network-config-false.patch (+23/-0) debian/patches/cpick-1d5e9aef-azure-Add-apply_network_config-option-to-disable (+228/-0) debian/patches/series (+2/-0) |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Server Team CI bot | continuous-integration | Approve | |
Scott Moser | Approve | ||
Review via email:
|
Commit message
Cherry pick 1d5e9aef: Add azure apply_network_
Add debian patch: to set apply_network_
Upload to xenial as the fixes an SRU -proposed regression.
Description of the change

Server Team CI bot (server-team-bot) wrote : | # |

Scott Moser (smoser) wrote : | # |
I think you didn't add the azure-apply patch ? patches/series.
(need git-add)

Chad Smith (chad.smith) : | # |

Scott Moser (smoser) wrote : | # |
if c-i approves i do.

Chad Smith (chad.smith) wrote : | # |
Just added the patch in git, built the deb and tested on azure that the fix doesn't remove ENI hotplug scripts, but still gets IMDS data in instance-data.json
ubuntu@
{'config': [{'params': {'driver': 'hv_netvsc', 'device_id': '0x3'}, 'name': 'eth0', 'type': 'physical', 'mac_address': '00:0d:
ubuntu@

Server Team CI bot (server-team-bot) wrote : | # |
PASSED: Continuous integration, rev:833adcdf6f8
https:/
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:/
Preview Diff
1 | diff --git a/debian/changelog b/debian/changelog | |||
2 | index 2bdfd36..74e8dc2 100644 | |||
3 | --- a/debian/changelog | |||
4 | +++ b/debian/changelog | |||
5 | @@ -1,3 +1,14 @@ | |||
6 | 1 | cloud-init (18.4-0ubuntu1~16.04.2) xenial; urgency=medium | ||
7 | 2 | |||
8 | 3 | * cherry-pick 1d5e9aef: azure: Add apply_network_config option to | ||
9 | 4 | disable network (LP: #1798424) | ||
10 | 5 | * debian/patches/openstack-no-network-config.patch | ||
11 | 6 | add patch to default Azure apply_network_config to False. Only | ||
12 | 7 | fallback network config on eth0 is generated by cloud-init. IMDS | ||
13 | 8 | network_config is ignored. | ||
14 | 9 | |||
15 | 10 | -- Chad Smith <chad.smith@canonical.com> Wed, 17 Oct 2018 12:51:09 -0600 | ||
16 | 11 | |||
17 | 1 | cloud-init (18.4-0ubuntu1~16.04.1) xenial-proposed; urgency=medium | 12 | cloud-init (18.4-0ubuntu1~16.04.1) xenial-proposed; urgency=medium |
18 | 2 | 13 | ||
19 | 3 | * drop the following cherry-picks now included: | 14 | * drop the following cherry-picks now included: |
20 | diff --git a/debian/patches/azure-apply-network-config-false.patch b/debian/patches/azure-apply-network-config-false.patch | |||
21 | 4 | new file mode 100644 | 15 | new file mode 100644 |
22 | index 0000000..281c19c | |||
23 | --- /dev/null | |||
24 | +++ b/debian/patches/azure-apply-network-config-false.patch | |||
25 | @@ -0,0 +1,23 @@ | |||
26 | 1 | Description: Azure apply_network_config default to False | ||
27 | 2 | Azure cloud-images on Xenial already contain hotplug network scripts so | ||
28 | 3 | default behavior for should remain to only generate fallback network | ||
29 | 4 | configuration which is to dhcp on eth0 and let image hotplug scripts add | ||
30 | 5 | network configuration for any additional nics that show up. | ||
31 | 6 | Author: Chad Smith <chad.smith@canonical.com> | ||
32 | 7 | Origin: backport | ||
33 | 8 | Bug: https://bugs.launchpad.net/cloud-init/+bug/1798424 | ||
34 | 9 | Forwarded: not-needed | ||
35 | 10 | Last-Update: 2018-10-17 | ||
36 | 11 | Index: cloud-init/cloudinit/sources/DataSourceAzure.py | ||
37 | 12 | =================================================================== | ||
38 | 13 | --- cloud-init.orig/cloudinit/sources/DataSourceAzure.py | ||
39 | 14 | +++ cloud-init/cloudinit/sources/DataSourceAzure.py | ||
40 | 15 | @@ -207,7 +207,7 @@ BUILTIN_DS_CONFIG = { | ||
41 | 16 | }, | ||
42 | 17 | 'disk_aliases': {'ephemeral0': RESOURCE_DISK_PATH}, | ||
43 | 18 | 'dhclient_lease_file': LEASE_FILE, | ||
44 | 19 | - 'apply_network_config': True, # Use IMDS published network configuration | ||
45 | 20 | + 'apply_network_config': False, # Use fallback network config not IMDS | ||
46 | 21 | } | ||
47 | 22 | # RELEASE_BLOCKER: Xenial and earlier apply_network_config default is False | ||
48 | 23 | |||
49 | diff --git a/debian/patches/cpick-1d5e9aef-azure-Add-apply_network_config-option-to-disable b/debian/patches/cpick-1d5e9aef-azure-Add-apply_network_config-option-to-disable | |||
50 | 0 | new file mode 100644 | 24 | new file mode 100644 |
51 | index 0000000..67f9f0e | |||
52 | --- /dev/null | |||
53 | +++ b/debian/patches/cpick-1d5e9aef-azure-Add-apply_network_config-option-to-disable | |||
54 | @@ -0,0 +1,228 @@ | |||
55 | 1 | From 1d5e9aefdab06a2574d78e644deed6c6fa1da171 Mon Sep 17 00:00:00 2001 | ||
56 | 2 | From: Chad Smith <chad.smith@canonical.com> | ||
57 | 3 | Date: Wed, 17 Oct 2018 18:47:35 +0000 | ||
58 | 4 | Subject: [PATCH] azure: Add apply_network_config option to disable network | ||
59 | 5 | from IMDS | ||
60 | 6 | MIME-Version: 1.0 | ||
61 | 7 | Content-Type: text/plain; charset=UTF-8 | ||
62 | 8 | Content-Transfer-Encoding: 8bit | ||
63 | 9 | |||
64 | 10 | Azure generates network configuration from the IMDS service and removes | ||
65 | 11 | any preexisting hotplug network scripts which exist in Azure cloud images. | ||
66 | 12 | Add a datasource configuration option which allows for writing a default | ||
67 | 13 | network configuration which sets up dhcp on eth0 and leave the hotplug | ||
68 | 14 | handling to the cloud-image scripts. | ||
69 | 15 | |||
70 | 16 | To disable network-config from Azure IMDS, add the following to | ||
71 | 17 | /etc/cloud/cloud.cfg.d/99-azure-no-imds-network.cfg: | ||
72 | 18 | datasource: | ||
73 | 19 | Azure: | ||
74 | 20 | apply_network_config: False | ||
75 | 21 | |||
76 | 22 | LP: #1798424 | ||
77 | 23 | --- | ||
78 | 24 | cloudinit/sources/DataSourceAzure.py | 11 +++- | ||
79 | 25 | doc/rtd/topics/datasources/azure.rst | 46 +++++++++++++++ | ||
80 | 26 | tests/unittests/test_datasource/test_azure.py | 56 +++++++++++++++++-- | ||
81 | 27 | 3 files changed, 107 insertions(+), 6 deletions(-) | ||
82 | 28 | |||
83 | 29 | --- a/cloudinit/sources/DataSourceAzure.py | ||
84 | 30 | +++ b/cloudinit/sources/DataSourceAzure.py | ||
85 | 31 | @@ -207,7 +207,9 @@ BUILTIN_DS_CONFIG = { | ||
86 | 32 | }, | ||
87 | 33 | 'disk_aliases': {'ephemeral0': RESOURCE_DISK_PATH}, | ||
88 | 34 | 'dhclient_lease_file': LEASE_FILE, | ||
89 | 35 | + 'apply_network_config': True, # Use IMDS published network configuration | ||
90 | 36 | } | ||
91 | 37 | +# RELEASE_BLOCKER: Xenial and earlier apply_network_config default is False | ||
92 | 38 | |||
93 | 39 | BUILTIN_CLOUD_CONFIG = { | ||
94 | 40 | 'disk_setup': { | ||
95 | 41 | @@ -450,7 +452,8 @@ class DataSourceAzure(sources.DataSource | ||
96 | 42 | except sources.InvalidMetaDataException as e: | ||
97 | 43 | LOG.warning('Could not crawl Azure metadata: %s', e) | ||
98 | 44 | return False | ||
99 | 45 | - if self.distro and self.distro.name == 'ubuntu': | ||
100 | 46 | + if (self.distro and self.distro.name == 'ubuntu' and | ||
101 | 47 | + self.ds_cfg.get('apply_network_config')): | ||
102 | 48 | maybe_remove_ubuntu_network_config_scripts() | ||
103 | 49 | |||
104 | 50 | # Process crawled data and augment with various config defaults | ||
105 | 51 | @@ -611,7 +614,11 @@ class DataSourceAzure(sources.DataSource | ||
106 | 52 | the blacklisted devices. | ||
107 | 53 | """ | ||
108 | 54 | if not self._network_config: | ||
109 | 55 | - self._network_config = parse_network_config(self._metadata_imds) | ||
110 | 56 | + if self.ds_cfg.get('apply_network_config'): | ||
111 | 57 | + nc_src = self._metadata_imds | ||
112 | 58 | + else: | ||
113 | 59 | + nc_src = None | ||
114 | 60 | + self._network_config = parse_network_config(nc_src) | ||
115 | 61 | return self._network_config | ||
116 | 62 | |||
117 | 63 | |||
118 | 64 | --- a/doc/rtd/topics/datasources/azure.rst | ||
119 | 65 | +++ b/doc/rtd/topics/datasources/azure.rst | ||
120 | 66 | @@ -57,6 +57,52 @@ in order to use waagent.conf with cloud- | ||
121 | 67 | ResourceDisk.MountPoint=/mnt | ||
122 | 68 | |||
123 | 69 | |||
124 | 70 | +Configuration | ||
125 | 71 | +------------- | ||
126 | 72 | +The following configuration can be set for the datasource in system | ||
127 | 73 | +configuration (in `/etc/cloud/cloud.cfg` or `/etc/cloud/cloud.cfg.d/`). | ||
128 | 74 | + | ||
129 | 75 | +The settings that may be configured are: | ||
130 | 76 | + | ||
131 | 77 | + * **agent_command**: Either __builtin__ (default) or a command to run to getcw | ||
132 | 78 | + metadata. If __builtin__, get metadata from walinuxagent. Otherwise run the | ||
133 | 79 | + provided command to obtain metadata. | ||
134 | 80 | + * **apply_network_config**: Boolean set to True to use network configuration | ||
135 | 81 | + described by Azure's IMDS endpoint instead of fallback network config of | ||
136 | 82 | + dhcp on eth0. Default is True. For Ubuntu 16.04 or earlier, default is False. | ||
137 | 83 | + * **data_dir**: Path used to read metadata files and write crawled data. | ||
138 | 84 | + * **dhclient_lease_file**: The fallback lease file to source when looking for | ||
139 | 85 | + custom DHCP option 245 from Azure fabric. | ||
140 | 86 | + * **disk_aliases**: A dictionary defining which device paths should be | ||
141 | 87 | + interpreted as ephemeral images. See cc_disk_setup module for more info. | ||
142 | 88 | + * **hostname_bounce**: A dictionary Azure hostname bounce behavior to react to | ||
143 | 89 | + metadata changes. | ||
144 | 90 | + * **hostname_bounce**: A dictionary Azure hostname bounce behavior to react to | ||
145 | 91 | + metadata changes. Azure will throttle ifup/down in some cases after metadata | ||
146 | 92 | + has been updated to inform dhcp server about updated hostnames. | ||
147 | 93 | + * **set_hostname**: Boolean set to True when we want Azure to set the hostname | ||
148 | 94 | + based on metadata. | ||
149 | 95 | + | ||
150 | 96 | +An example configuration with the default values is provided below: | ||
151 | 97 | + | ||
152 | 98 | +.. sourcecode:: yaml | ||
153 | 99 | + | ||
154 | 100 | + datasource: | ||
155 | 101 | + Azure: | ||
156 | 102 | + agent_command: __builtin__ | ||
157 | 103 | + apply_network_config: true | ||
158 | 104 | + data_dir: /var/lib/waagent | ||
159 | 105 | + dhclient_lease_file: /var/lib/dhcp/dhclient.eth0.leases | ||
160 | 106 | + disk_aliases: | ||
161 | 107 | + ephemeral0: /dev/disk/cloud/azure_resource | ||
162 | 108 | + hostname_bounce: | ||
163 | 109 | + interface: eth0 | ||
164 | 110 | + command: builtin | ||
165 | 111 | + policy: true | ||
166 | 112 | + hostname_command: hostname | ||
167 | 113 | + set_hostname: true | ||
168 | 114 | + | ||
169 | 115 | + | ||
170 | 116 | Userdata | ||
171 | 117 | -------- | ||
172 | 118 | Userdata is provided to cloud-init inside the ovf-env.xml file. Cloud-init | ||
173 | 119 | --- a/tests/unittests/test_datasource/test_azure.py | ||
174 | 120 | +++ b/tests/unittests/test_datasource/test_azure.py | ||
175 | 121 | @@ -254,7 +254,8 @@ scbus-1 on xpt0 bus 0 | ||
176 | 122 | ]) | ||
177 | 123 | return dsaz | ||
178 | 124 | |||
179 | 125 | - def _get_ds(self, data, agent_command=None, distro=None): | ||
180 | 126 | + def _get_ds(self, data, agent_command=None, distro=None, | ||
181 | 127 | + apply_network=None): | ||
182 | 128 | |||
183 | 129 | def dsdevs(): | ||
184 | 130 | return data.get('dsdevs', []) | ||
185 | 131 | @@ -310,6 +311,8 @@ scbus-1 on xpt0 bus 0 | ||
186 | 132 | data.get('sys_cfg', {}), distro=distro, paths=self.paths) | ||
187 | 133 | if agent_command is not None: | ||
188 | 134 | dsrc.ds_cfg['agent_command'] = agent_command | ||
189 | 135 | + if apply_network is not None: | ||
190 | 136 | + dsrc.ds_cfg['apply_network_config'] = apply_network | ||
191 | 137 | |||
192 | 138 | return dsrc | ||
193 | 139 | |||
194 | 140 | @@ -414,14 +417,26 @@ fdescfs /dev/fd fdes | ||
195 | 141 | |||
196 | 142 | def test_get_data_on_ubuntu_will_remove_network_scripts(self): | ||
197 | 143 | """get_data will remove ubuntu net scripts on Ubuntu distro.""" | ||
198 | 144 | + sys_cfg = {'datasource': {'Azure': {'apply_network_config': True}}} | ||
199 | 145 | odata = {'HostName': "myhost", 'UserName': "myuser"} | ||
200 | 146 | data = {'ovfcontent': construct_valid_ovf_env(data=odata), | ||
201 | 147 | - 'sys_cfg': {}} | ||
202 | 148 | + 'sys_cfg': sys_cfg} | ||
203 | 149 | |||
204 | 150 | dsrc = self._get_ds(data, distro='ubuntu') | ||
205 | 151 | dsrc.get_data() | ||
206 | 152 | self.m_remove_ubuntu_network_scripts.assert_called_once_with() | ||
207 | 153 | |||
208 | 154 | + def test_get_data_on_ubuntu_will_not_remove_network_scripts_disabled(self): | ||
209 | 155 | + """When apply_network_config false, do not remove scripts on Ubuntu.""" | ||
210 | 156 | + sys_cfg = {'datasource': {'Azure': {'apply_network_config': False}}} | ||
211 | 157 | + odata = {'HostName': "myhost", 'UserName': "myuser"} | ||
212 | 158 | + data = {'ovfcontent': construct_valid_ovf_env(data=odata), | ||
213 | 159 | + 'sys_cfg': sys_cfg} | ||
214 | 160 | + | ||
215 | 161 | + dsrc = self._get_ds(data, distro='ubuntu') | ||
216 | 162 | + dsrc.get_data() | ||
217 | 163 | + self.m_remove_ubuntu_network_scripts.assert_not_called() | ||
218 | 164 | + | ||
219 | 165 | def test_crawl_metadata_returns_structured_data_and_caches_nothing(self): | ||
220 | 166 | """Return all structured metadata and cache no class attributes.""" | ||
221 | 167 | yaml_cfg = "{agent_command: my_command}\n" | ||
222 | 168 | @@ -503,8 +518,10 @@ fdescfs /dev/fd fdes | ||
223 | 169 | |||
224 | 170 | def test_network_config_set_from_imds(self): | ||
225 | 171 | """Datasource.network_config returns IMDS network data.""" | ||
226 | 172 | + sys_cfg = {'datasource': {'Azure': {'apply_network_config': True}}} | ||
227 | 173 | odata = {} | ||
228 | 174 | - data = {'ovfcontent': construct_valid_ovf_env(data=odata)} | ||
229 | 175 | + data = {'ovfcontent': construct_valid_ovf_env(data=odata), | ||
230 | 176 | + 'sys_cfg': sys_cfg} | ||
231 | 177 | expected_network_config = { | ||
232 | 178 | 'ethernets': { | ||
233 | 179 | 'eth0': {'set-name': 'eth0', | ||
234 | 180 | @@ -783,9 +800,10 @@ fdescfs /dev/fd fdes | ||
235 | 181 | @mock.patch('cloudinit.net.generate_fallback_config') | ||
236 | 182 | def test_imds_network_config(self, mock_fallback): | ||
237 | 183 | """Network config is generated from IMDS network data when present.""" | ||
238 | 184 | + sys_cfg = {'datasource': {'Azure': {'apply_network_config': True}}} | ||
239 | 185 | odata = {'HostName': "myhost", 'UserName': "myuser"} | ||
240 | 186 | data = {'ovfcontent': construct_valid_ovf_env(data=odata), | ||
241 | 187 | - 'sys_cfg': {}} | ||
242 | 188 | + 'sys_cfg': sys_cfg} | ||
243 | 189 | |||
244 | 190 | dsrc = self._get_ds(data) | ||
245 | 191 | ret = dsrc.get_data() | ||
246 | 192 | @@ -803,6 +821,36 @@ fdescfs /dev/fd fdes | ||
247 | 193 | |||
248 | 194 | @mock.patch('cloudinit.net.get_interface_mac') | ||
249 | 195 | @mock.patch('cloudinit.net.get_devicelist') | ||
250 | 196 | + @mock.patch('cloudinit.net.device_driver') | ||
251 | 197 | + @mock.patch('cloudinit.net.generate_fallback_config') | ||
252 | 198 | + def test_imds_network_ignored_when_apply_network_config_false( | ||
253 | 199 | + self, mock_fallback, mock_dd, mock_devlist, mock_get_mac): | ||
254 | 200 | + """When apply_network_config is False, use fallback instead of IMDS.""" | ||
255 | 201 | + sys_cfg = {'datasource': {'Azure': {'apply_network_config': False}}} | ||
256 | 202 | + odata = {'HostName': "myhost", 'UserName': "myuser"} | ||
257 | 203 | + data = {'ovfcontent': construct_valid_ovf_env(data=odata), | ||
258 | 204 | + 'sys_cfg': sys_cfg} | ||
259 | 205 | + fallback_config = { | ||
260 | 206 | + 'version': 1, | ||
261 | 207 | + 'config': [{ | ||
262 | 208 | + 'type': 'physical', 'name': 'eth0', | ||
263 | 209 | + 'mac_address': '00:11:22:33:44:55', | ||
264 | 210 | + 'params': {'driver': 'hv_netsvc'}, | ||
265 | 211 | + 'subnets': [{'type': 'dhcp'}], | ||
266 | 212 | + }] | ||
267 | 213 | + } | ||
268 | 214 | + mock_fallback.return_value = fallback_config | ||
269 | 215 | + | ||
270 | 216 | + mock_devlist.return_value = ['eth0'] | ||
271 | 217 | + mock_dd.return_value = ['hv_netsvc'] | ||
272 | 218 | + mock_get_mac.return_value = '00:11:22:33:44:55' | ||
273 | 219 | + | ||
274 | 220 | + dsrc = self._get_ds(data) | ||
275 | 221 | + self.assertTrue(dsrc.get_data()) | ||
276 | 222 | + self.assertEqual(dsrc.network_config, fallback_config) | ||
277 | 223 | + | ||
278 | 224 | + @mock.patch('cloudinit.net.get_interface_mac') | ||
279 | 225 | + @mock.patch('cloudinit.net.get_devicelist') | ||
280 | 226 | @mock.patch('cloudinit.net.device_driver') | ||
281 | 227 | @mock.patch('cloudinit.net.generate_fallback_config') | ||
282 | 228 | def test_fallback_network_config(self, mock_fallback, mock_dd, | ||
283 | diff --git a/debian/patches/series b/debian/patches/series | |||
284 | index d5a24c5..0e26411 100644 | |||
285 | --- a/debian/patches/series | |||
286 | +++ b/debian/patches/series | |||
287 | @@ -2,3 +2,5 @@ azure-use-walinux-agent.patch | |||
288 | 2 | ds-identify-behavior-xenial.patch | 2 | ds-identify-behavior-xenial.patch |
289 | 3 | stable-release-no-jsonschema-dep.patch | 3 | stable-release-no-jsonschema-dep.patch |
290 | 4 | openstack-no-network-config.patch | 4 | openstack-no-network-config.patch |
291 | 5 | cpick-1d5e9aef-azure-Add-apply_network_config-option-to-disable | ||
292 | 6 | azure-apply-network-config-false.patch |
FAILED: Continuous integration, rev:67629006c3d 363ab59488f0730 715eab7a70173d /jenkins. ubuntu. com/server/ job/cloud- init-ci/ 403/
https:/
Executed test runs:
SUCCESS: Checkout
SUCCESS: Unit & Style Tests
FAILED: Ubuntu LTS: Build
Click here to trigger a rebuild: /jenkins. ubuntu. com/server/ job/cloud- init-ci/ 403/rebuild
https:/