Comment 6 for bug 1712680

Revision history for this message
Scott Moser (smoser) wrote :

Networking is intended to only be rendered once per instance.
This re-rendering happens in MAAS because MAAS is a network datasource, and
network information is provided to cloud-init via system config (in
/etc/cloud/cloud.cfg.d by curtin).

So what happens is:
 a.) cloud-init-local executes and does not find a local datasource.
 b.) since nothing is found, we render default networking configuration
     so that we can search for network datasources. in this case the default
     networking configuration comes from /etc/cloud/cloud.cfg.d
 c.) cloud-init-net runs and finds maas datasource, and even that this is
     not a new instance, which woudl prevent it from rendering network config.

The problem is that to get the instance-id to verify, we had to render
network config, so its too late at the point when we could determine
that we did not / should not re-render networking.

The fix for this is to make the MAAS datasource have a 'check_instance_id'
function. If that returns true, then we skip 'b', as this is determined to
not be a new instance id, and even some portions of 'c' are skipped.

The reason that MAAS datasource does not have a 'check_instance_id' is
that there is no local way to verify that the the cached data (in
/var/lib/cloud/instance/) is valid.

The easiest solution is to jsut add the method and have it return True.
The issue with doing this is then snapshot and re-provision of a new
image requires cleaning of /var/lib/cloud/instance (as otherwise it
would never know it was a new instance).

MAAS doesn't *have* an instance-id. (bug 944325). However, it seems
that the fix that went in for bug 1507586 will change the token on
each deploy. Since that token is available to cloud-init, and will
be updated on every install (by curtin) we can compare current token to
cached token and use that as 'check_instance_id'.

That will mean that capturing an image of a MAAS deployed system and
then deploying that on another datasource will not work correctly.
In order to do that the user would have "clean" the image with either:
  rm -Rf /var/lib/cloud/
  rm -f /etc/cloud/cloud.cfg.d/*curtin*