← Back to team overview

cloud-init team mailing list archive

Re: cloud-init + overlayfs: after ubuntu trusty -> xenial upgrade, missing 'workdir'

 

On Wed, May 31, 2017 at 4:25 PM, Graham Leggett <minfrin@xxxxxxxx> wrote:

> On 31 May 2017, at 9:36 PM, Ryan Harper <ryan.harper@xxxxxxxxxxxxx> wrote:
>
> Yes, the overlay module doesn't seem to have a way to find a default
> workdir value by itself.  =(
>
>
> This is an unfortunate regression.
>
> What needs to happen is that after the fs_setup step that creates
>> /mnt/postfix-overlay, but before the mounts section where the overlayfs is
>> created, the workdir and upperdir directories need to be created on the
>> /mnt/postfix-overlay disk as /mnt/postfix-overlay/upperdir and
>> /mnt/postfix-overlay/workdir (or something) respectively.
>>
>> Is there something that can be done in cloud-init to make this possible?
>>
>
> Surely it can; I think it's a matter of module timing: you need the
> directory to be created prior to the mounts module running.
> Looking at /etc/cloud/cloud.cfg, the cloud_init_modules list, shows that
> 'bootcmd'[1] will run before the 'mounts' stage, so
> it should be possible to include a command like this:
>
> bootcmd:
>   - mkdir -p /mnt/postfix-overlay-workdir
>
> And to update the overlayfs mount command to specify the workdir path.
>
> That's untested, but I think should do what you need.
>
> 1. http://cloudinit.readthedocs.io/en/latest/topics/modules.html#bootcmd
>
>
> Alas, bootcmd also runs before the disk_setup stage, and as a result the
> disk doesn’t exist yet that the directories need to be created on.
>

Yes, the workdir needs to be on the same filesystem as upper.


>
> # The modules that run in the 'config' stage
> cloud_config_modules:
> # Emit the cloud config ready event
> # this can be used by upstart jobs for 'start on cloud-config'.
>  - emit_upstart
>  - disk_setup
>  - mounts
>
> “mounts” seems to be run directly after “disk_setup”, giving no option to
> do anything in between.
>
> What is the cleanest way to fix this?
>

> Maybe something like this:
>
> fs_setup:
>  - label: postfix
>    device: /dev/xvde
>    filesystem: ext4
>    mkdir: upperdir workdir
>

I think we will need to amend the mounts module;  we cannot mkdir until the
filesystem is mounted
so adding config to fs_setup would mean we'd need to temp mount, mkdir, and
umount.

Looking at cc_mounts module, it already does  mkdir on the mount point in
the entry, I think it's reasonable
to check for a list of lower,upper,workdir values if the fstype is overlay;
and add this to the list of directories
that cc_mounts creates.

I've created https://bugs.launchpad.net/cloud-init/+bug/1695277 to track
the work.


>
> Regards,
> Graham
> —
>
>

References