← Back to team overview

cloud-init-dev team mailing list archive

Re: [Merge] ~smoser/cloud-init:bug/1683038-ec2-no-warn-on-explicit into cloud-init:master

 

I've pushed some new commits, please see and review.
thanks.


Diff comments:

> 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

probably.
I'll add something.

> @@ -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):

decided not to do this, because it made the line where it is used > 80 chars.
not that I think that is a good argument in general, but maybe a good argument against something identified as bikeshed.

> +    if 'Ec2' not in dslist:
> +        return False
> +    return (len(dslist) == 1 or (len(dslist) == 2 and 'None' in dslist))

see change here. now just doing
 return dslist in (['Ec2'], ['Ec2', 'None'])

> +
> +
>  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."""

no scott, chad was right.
i'm adjusting.

> +        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."""


-- 
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.


References