Merge ~chad.smith/cloud-init:fix-ec2-fallback-nic into cloud-init:master
| Status: | Merged | ||||
|---|---|---|---|---|---|
| Approved by: | Scott Moser on 2017-11-20 | ||||
| Approved revision: | c8864aca05cdbc6a8a35c944f0f75d6d687e92fb | ||||
| Merged at revision: | 281a82181716183d526e76f4e0415e0a6f680cbe | ||||
| Proposed branch: | ~chad.smith/cloud-init:fix-ec2-fallback-nic | ||||
| Merge into: | cloud-init:master | ||||
| Diff against target: |
144 lines (+67/-13) 3 files modified
cloudinit/net/dhcp.py (+1/-2) cloudinit/sources/DataSourceEc2.py (+33/-11) tests/unittests/test_datasource/test_ec2.py (+33/-0) |
||||
| Related bugs: |
|
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Scott Moser | 2017-11-18 | Approve on 2017-11-20 | |
| Server Team CI bot | continuous-integration | Approve on 2017-11-20 | |
|
Review via email:
|
|||
Commit Message
EC2: Fix bug using fallback_nic and metadata when restoring from cache.
If user upgraded to new cloud-init and attempted to run 'cloud-init init'
without rebooting, cloud-init restores the datasource object from pickle.
The older version pickled datasource object had no value for
_network_config or fallback_nic. This caused the Ec2 datasource to attempt
to reconfigure networking with a None fallback_nic. The pickled object
also cached an older version of ec2 metadata which didn't contain network
information.
This branch does two things:
- Add a fallback_interface property to DatasourceEC2 to support reading the
old .fallback_nic attribute if it was set. New versions will
call net.find_
- Re-crawl metadata if we are on Ec2 and don't have a 'network' key in
metadata
LP: #1732917
Description of the Change
EC2: Fix bug using fallback_nic and metadata when restoring from cache.
If user upgraded to new cloud-init and attempted to run 'cloud-init init'
without rebooting, cloud-init restores the datasource object from pickle.
The older version pickled datasource object had no value for
_network_config or fallback_nic. This caused the Ec2 datasource to attempt
to reconfigure networking with a None fallback_nic. The pickled object
also cached an older version of ec2 metadata which didn't contain network
information.
This branch does two things:
- Add a fallback_interface property to DatasourceEC2 to support reading the
old .fallback_nic attribute if it was set. New versions will
call net.find_
- Re-crawl metadata if we are on Ec2 and don't have a 'network' key in
metadata
LP: #1732917
| Ryan Harper (raharper) wrote : | # |
| Chad Smith (chad.smith) wrote : | # |
Just tested on Ec2
ubuntu@
sudo rm -rf /var/log/
sudo cloud-init init
ubuntu@
(Reading database ... 51123 files and directories currently installed.)
Preparing to unpack cloud-init_
Unpacking cloud-init (17.1-44-
Setting up cloud-init (17.1-44-
Installing new version of config file /etc/cloud/
Installing new version of config file /etc/cloud/
Installing new version of config file /etc/cloud/
Installing new version of config file /etc/cloud/
ubuntu@
Cloud-init v. 17.1 running 'init' at Sat, 18 Nov 2017 03:01:33 +0000. Up 17185.03 seconds.
ci-info: +++++++
ci-info: +------
ci-info: | Device | Up | Address | Mask | Scope | Hw-Address |
ci-info: +------
ci-info: | eth0 | True | 172.31.16.165 | 255.255.240.0 | . | 06:23:bc:a9:a4:fa |
ci-info: | eth0 | True | fe80::423:
ci-info: | lo | True | 127.0.0.1 | 255.0.0.0 | . | . |
ci-info: | lo | True | ::1/128 | . | host | . |
ci-info: +------
ci-info: +++++++
ci-info: +------
ci-info: | Route | Destination | Gateway | Genmask | Interface | Flags |
ci-info: +------
ci-info: | 0 | 0.0.0.0 | 172.31.16.1 | 0.0.0.0 | eth0 | UG |
ci-info: | 1 | 172.31.16.0 | 0.0.0.0 | 255.255.240.0 | eth0 | U |
ci-info: +------
ubuntu@
● cloud-init.service - Initial cloud-init job (metadata service crawler)
Loaded: loaded (/lib/systemd/
Active: active (exited) since Fri 2017-11-17 23:01:14 UTC; 4h 0min ago
Main PID: 3781 (code=exited, status=0/SUCCESS)
Nov 17 23:01:14 ip-172-31-16-165 cloud-init[3781]: ci-info: | lo | True | ::1/128 | . | host | . |
Nov 17 23:01:14 ip-172-31-16-165 cloud-init[3781]: ci-info: +------
Nov 17 23:01:14 ip-172-31-16-165 ...
FAILED: Continuous integration, rev:c8864aca05c
https:/
Executed test runs:
SUCCESS: Checkout
SUCCESS: Unit & Style Tests
SUCCESS: Ubuntu LTS: Build
SUCCESS: Ubuntu LTS: Integration
FAILED: MAAS Compatability Testing
Click here to trigger a rebuild:
https:/
| Scott Moser (smoser) wrote : | # |
one comment inline.
PASSED: Continuous integration, rev:
https:/
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:/


I'm some what leery of recrawling merely because someone ran 'cloud-init init' when there is a cached object for the current instance-id. Wouldn't it be better to *not* re-read metadata?
Now, thinking about a reboot; due to Ec2 datasource not providing a check_instance_id() method, we always throw out the previous boot's Datasource cached object. Prior to local datasource Ec2, we always re-read metadata when acquiring an EC2 datasource; every boot we always read metadata.
I think that reasonably convinces (at least myself) that any time we instantiate an Ec2 datasource object (whether from unpickle or reboot); it's going to read the metadata.