← Back to team overview

cloud-init-dev team mailing list archive

Re: [Merge] ~rjschwei/cloud-init:emptyStageOK into cloud-init:master

 

This log/condition is already 'handled' in cloudinit/cmd/main.py:110 with a message like the following:

No 'config' modules to run under section 'cloud_config_modules', but we should still avoid the Traceback as you say.

you can see this log on a system configured with an empty cloud_config_modules section by running  "cloud-init modules --mode config".

root@myb1:~# cloud-init modules --mode config
Cloud-init v. 18.2 running 'modules:config' at Thu, 10 May 2018 19:46:42 +0000. Up 1174.00 seconds.
No 'config' modules to run under section 'cloud_config_modules'


I propose we drop your additional log message, and just return module_list at that point in your patch.

Here is a patch with a test for that behavior not generating a Traceback.
http://paste.ubuntu.com/p/Dkb22CnkMm/


Diff comments:

> diff --git a/cloudinit/stages.py b/cloudinit/stages.py
> index 3998cf6..7531b5a 100644
> --- a/cloudinit/stages.py
> +++ b/cloudinit/stages.py
> @@ -698,6 +698,10 @@ class Modules(object):
>          if name not in self.cfg:
>              return module_list
>          cfg_mods = self.cfg[name]

We should just cfg_mods = self.cfg.get(name)
if not cfg_mods:
  return module_list

> +        if not cfg_mods:
> +            LOG.info("No configuration modules defined for stage: "
> +                     "%s SKipping stage", name)
> +            return module_list
>          # Create 'module_list', an array of hashes
>          # Where hash['mod'] = module name
>          #       hash['freq'] = frequency


-- 
https://code.launchpad.net/~rjschwei/cloud-init/+git/cloud-init/+merge/345377
Your team cloud-init commiters is requested to review the proposed merge of ~rjschwei/cloud-init:emptyStageOK into cloud-init:master.


References