cloud-init-dev team mailing list archive
-
cloud-init-dev team
-
Mailing list archive
-
Message #02192
[Merge] ~smoser/cloud-init:bug/1683038-ec2-no-warn-on-explicit into cloud-init:master
Scott Moser has proposed merging ~smoser/cloud-init:bug/1683038-ec2-no-warn-on-explicit into cloud-init:master.
Requested reviews:
cloud-init commiters (cloud-init-dev)
Related bugs:
Bug #1683038 in cloud-init: "Need to convince cloud-init we really want Ec2 datasource"
https://bugs.launchpad.net/cloud-init/+bug/1683038
For more details, see:
https://code.launchpad.net/~smoser/cloud-init/+git/cloud-init/+merge/324274
--
Your team cloud-init commiters is requested to review the proposed merge of ~smoser/cloud-init:bug/1683038-ec2-no-warn-on-explicit into cloud-init:master.
diff --git a/cloudinit/sources/DataSourceEc2.py b/cloudinit/sources/DataSourceEc2.py
index 2f9c7ed..818a639 100644
--- a/cloudinit/sources/DataSourceEc2.py
+++ b/cloudinit/sources/DataSourceEc2.py
@@ -64,7 +64,8 @@ class DataSourceEc2(sources.DataSource):
LOG.debug("strict_mode: %s, cloud_platform=%s",
strict_mode, self.cloud_platform)
if strict_mode == "true" and self.cloud_platform == Platforms.UNKNOWN:
- return False
+ if not _is_explicit_dslist(self.sys_cfg.get('datasource_list')):
+ return False
try:
if not self.wait_for_metadata_service():
@@ -266,6 +267,12 @@ def parse_strict_mode(cfgval):
return mode, sleep
+def _is_explicit_dslist(dslist):
+ if 'Ec2' not in dslist:
+ return False
+ return (len(dslist) == 1 or (len(dslist) == 2 and 'None' in dslist))
+
+
def warn_if_necessary(cfgval, cfg):
try:
mode, sleep = parse_strict_mode(cfgval)
@@ -276,6 +283,12 @@ def warn_if_necessary(cfgval, cfg):
if mode == "false":
return
+ dslist = cfg.get('datasource_list')
+ if _is_explicit_dslist(cfg.get('datasource_list')):
+ LOG.debug("mode=%s but explicit dslist (%s), not warning.",
+ mode, dslist)
+ return
+
warnings.show_warning('non_ec2_md', cfg, mode=True, sleep=sleep)
diff --git a/tests/unittests/test_ds_identify.py b/tests/unittests/test_ds_identify.py
index 9e14885..8559e1f 100644
--- a/tests/unittests/test_ds_identify.py
+++ b/tests/unittests/test_ds_identify.py
@@ -210,6 +210,13 @@ class TestDsIdentify(CiTestCase):
mydata['files'][cfgpath] = 'datasource_list: ["NoCloud"]\n'
self._check_via_dict(mydata, rc=RC_FOUND, dslist=['NoCloud', DS_NONE])
+ def test_configured_list_with_none(self):
+ """If user set a datasource_list, that should be used."""
+ mydata = copy.deepcopy(VALID_CFG['GCE'])
+ cfgpath = 'etc/cloud/cloud.cfg.d/myds.cfg'
+ mydata['files'][cfgpath] = 'datasource_list: ["Ec2", "None"]\n'
+ self._check_via_dict(mydata, rc=RC_FOUND, dslist=['Ec2', DS_NONE])
+
def blkid_out(disks=None):
"""Convert a list of disk dictionaries into blkid content."""
diff --git a/tools/ds-identify b/tools/ds-identify
index aff26eb..74d2653 100755
--- a/tools/ds-identify
+++ b/tools/ds-identify
@@ -963,10 +963,11 @@ found() {
# do not pass an empty line through.
shift
fi
- # always write the None datasource last.
- if [ "$list" != "None" ]; then
- list="${list:+${list}, }None"
- fi
+ # if None is not already in the list, then add it last.
+ case " $list " in
+ *\ None,\ *|*\ None\ ) :;;
+ *) list=${list:+${list}, None};;
+ esac
write_result "datasource_list: [ $list ]" "$@"
return
}
Follow ups
-
[Merge] ~smoser/cloud-init:bug/1683038-ec2-no-warn-on-explicit into cloud-init:master
From: Scott Moser, 2017-07-18
-
Re: [Merge] ~smoser/cloud-init:bug/1683038-ec2-no-warn-on-explicit into cloud-init:master
From: Scott Moser, 2017-07-17
-
Re: [Merge] ~smoser/cloud-init:bug/1683038-ec2-no-warn-on-explicit into cloud-init:master
From: Scott Moser, 2017-06-14
-
Re: [Merge] ~smoser/cloud-init:bug/1683038-ec2-no-warn-on-explicit into cloud-init:master
From: Server Team CI bot, 2017-05-31
-
Re: [Merge] ~smoser/cloud-init:bug/1683038-ec2-no-warn-on-explicit into cloud-init:master
From: Server Team CI bot, 2017-05-31
-
Re: [Merge] ~smoser/cloud-init:bug/1683038-ec2-no-warn-on-explicit into cloud-init:master
From: Server Team CI bot, 2017-05-31
-
Re: [Merge] ~smoser/cloud-init:bug/1683038-ec2-no-warn-on-explicit into cloud-init:master
From: Scott Moser, 2017-05-31
-
[Merge] ~smoser/cloud-init:bug/1683038-ec2-no-warn-on-explicit into cloud-init:master
From: Scott Moser, 2017-05-31
-
Re: [Merge] ~smoser/cloud-init:bug/1683038-ec2-no-warn-on-explicit into cloud-init:master
From: Server Team CI bot, 2017-05-30
-
Re: [Merge] ~smoser/cloud-init:bug/1683038-ec2-no-warn-on-explicit into cloud-init:master
From: Server Team CI bot, 2017-05-24
-
Re: [Merge] ~smoser/cloud-init:bug/1683038-ec2-no-warn-on-explicit into cloud-init:master
From: Scott Moser, 2017-05-24
-
Re: [Merge] ~smoser/cloud-init:bug/1683038-ec2-no-warn-on-explicit into cloud-init:master
From: Chad Smith, 2017-05-24
-
Re: [Merge] ~smoser/cloud-init:bug/1683038-ec2-no-warn-on-explicit into cloud-init:master
From: Chad Smith, 2017-05-24
-
Re: [Merge] ~smoser/cloud-init:bug/1683038-ec2-no-warn-on-explicit into cloud-init:master
From: Server Team CI bot, 2017-05-23
-
Re: [Merge] ~smoser/cloud-init:bug/1683038-ec2-no-warn-on-explicit into cloud-init:master
From: Server Team CI bot, 2017-05-23
-
Re: [Merge] ~smoser/cloud-init:bug/1683038-ec2-no-warn-on-explicit into cloud-init:master
From: Scott Moser, 2017-05-23
-
Re: [Merge] ~smoser/cloud-init:bug/1683038-ec2-no-warn-on-explicit into cloud-init:master
From: Scott Moser, 2017-05-23
-
Re: [Merge] ~smoser/cloud-init:bug/1683038-ec2-no-warn-on-explicit into cloud-init:master
From: Chad Smith, 2017-05-22
-
Re: [Merge] ~smoser/cloud-init:bug/1683038-ec2-no-warn-on-explicit into cloud-init:master
From: Chad Smith, 2017-05-22
-
Re: [Merge] ~smoser/cloud-init:bug/1683038-ec2-no-warn-on-explicit into cloud-init:master
From: Chad Smith, 2017-05-22
-
Re: [Merge] ~smoser/cloud-init:bug/1683038-ec2-no-warn-on-explicit into cloud-init:master
From: Ryan Harper, 2017-05-22
-
Re: [Merge] ~smoser/cloud-init:bug/1683038-ec2-no-warn-on-explicit into cloud-init:master
From: Server Team CI bot, 2017-05-18
-
[Merge] ~smoser/cloud-init:bug/1683038-ec2-no-warn-on-explicit into cloud-init:master
From: Scott Moser, 2017-05-18