← Back to team overview

cloud-init-dev team mailing list archive

Re: [Merge] ~chad.smith/cloud-init:set-hostname-before-network into cloud-init:master

 

hm...
Does UserDataProcessor.process() actually get part handlers and such called?

If so, we're absolutely changing their contract.  Now they'd be running without a network.

I'm really sorry this is so hard. :-(


Diff comments:

> diff --git a/cloudinit/cmd/main.py b/cloudinit/cmd/main.py
> index d2f1b77..a311264 100644
> --- a/cloudinit/cmd/main.py
> +++ b/cloudinit/cmd/main.py
> @@ -354,6 +355,20 @@ def main_init(name, args):
>      LOG.debug("[%s] %s will now be targeting instance id: %s. new=%s",
>                mode, name, iid, init.is_new_instance())
>  
> +    cloud = init.cloudify()
> +    if mode == sources.DSMODE_LOCAL:
> +        # Before network comes up, set any configured hostname to allow
> +        # dhcp clients to advertize this hostname to any DDNS services
> +        # lp:1746455.

LP: #XXXXX

> +        init.update()  # Process any user-data and vendor-data available
> +        (hostname, _fqdn) = util.get_hostname_fqdn(
> +            init.cfg, cloud, metadata_only=True)
> +        if hostname:  # meta-data or user-data hostname content
> +            try:
> +                cc_set_hostname.handle(
> +                    'init-local-set-hostname', init.cfg, cloud, LOG, None)
> +            except cc_set_hostname.SetHostnameError:
> +                LOG.debug('Will retry set_hostname when networking is up.')

lets put the message of the error we did get.
and maybe a message like:
"Failed setting hostname during local stage. Will try again in network stage (%s)", e)

>      init.apply_network_config(bring_up=bool(mode != sources.DSMODE_LOCAL))
>  
>      if mode == sources.DSMODE_LOCAL:
> @@ -370,6 +385,14 @@ def main_init(name, args):
>      init.setup_datasource()
>      # update fully realizes user-data (pulling in #include if necessary)
>      init.update()
> +    (hostname, _fqdn) = util.get_hostname_fqdn(

maybe move this hunk to a method and re-use it above and here.
I think all that differs is the debug message, right?

> +        init.cfg, cloud, metadata_only=True)
> +    if hostname:
> +        try:
> +            cc_set_hostname.handle(
> +                'init-network-set-hostname', init.cfg, cloud, LOG, None)
> +        except cc_set_hostname.SetHostnameError:
> +            LOG.debug('Will retry set_hostname in modules:config stage.')
>      # Stage 7
>      try:
>          # Attempt to consume the data per instance.


-- 
https://code.launchpad.net/~chad.smith/cloud-init/+git/cloud-init/+merge/339720
Your team cloud-init commiters is requested to review the proposed merge of ~chad.smith/cloud-init:set-hostname-before-network into cloud-init:master.


References