Merge lp://staging/~tobijk/livecd-rootfs/image-sets into lp://staging/livecd-rootfs

Proposed by Tobias Koch
Status: Merged
Merged at revision: 1735
Proposed branch: lp://staging/~tobijk/livecd-rootfs/image-sets
Merge into: lp://staging/livecd-rootfs
Diff against target: 565 lines (+343/-62)
18 files modified
live-build/auto/config (+13/-0)
live-build/ubuntu-cpc/README.cpc.md (+68/-0)
live-build/ubuntu-cpc/hooks.d/base/disk-image.binary (+3/-1)
live-build/ubuntu-cpc/hooks.d/base/qcow2-image.binary (+0/-9)
live-build/ubuntu-cpc/hooks.d/base/root-squashfs.binary (+0/-9)
live-build/ubuntu-cpc/hooks.d/base/series/base (+7/-0)
live-build/ubuntu-cpc/hooks.d/base/series/disk-image (+3/-0)
live-build/ubuntu-cpc/hooks.d/base/series/qcow2 (+2/-0)
live-build/ubuntu-cpc/hooks.d/base/series/root-dir (+1/-0)
live-build/ubuntu-cpc/hooks.d/base/series/squashfs (+2/-0)
live-build/ubuntu-cpc/hooks.d/base/series/tarball (+2/-0)
live-build/ubuntu-cpc/hooks.d/base/series/vagrant (+2/-0)
live-build/ubuntu-cpc/hooks.d/base/series/vmdk (+3/-0)
live-build/ubuntu-cpc/hooks.d/base/vagrant.binary (+0/-9)
live-build/ubuntu-cpc/hooks.d/base/vmdk-image.binary (+0/-9)
live-build/ubuntu-cpc/hooks.d/base/vmdk-ova-image.binary (+0/-9)
live-build/ubuntu-cpc/hooks.d/make-hooks (+237/-0)
live-build/ubuntu-cpc/hooks/999-extras.binary (+0/-16)
To merge this branch: bzr merge lp://staging/~tobijk/livecd-rootfs/image-sets
Reviewer Review Type Date Requested Status
Steve Langasek Approve
Philip Roche (community) Abstain
Dan Watkins (community) Approve
Francis Ginther (community) Approve
Review via email: mp+356246@code.staging.launchpad.net

Commit message

Use series files with dependency handling to generate hook symlinks dynamically

This patch currently only applies to the "ubuntu-cpc" project.

More and more logic has been going into the hook scripts to decide under which conditions they should run or not. As we are moving to parallelized builds of image sets, this will get even more complicated. Base hooks will have to know which image sets they belong to and modification of the dependency chain between scripts will become more complicated and prone to errors, as the number of image sets grows.

This patch introduces explicit ordering and dependency handling for scripts through the use of `series` files and an explicit syntax for dependency specification.

Description of the change

Please read

    https://bazaar.launchpad.net/~tobijk/livecd-rootfs/image-sets/view/head:/live-build/ubuntu-cpc/README.cpc.md

In order to try out the hook generation, change to

    live-build/ubuntu-cpc/hooks.d

and call `make-hooks` with different arguments, for example:

    ./make-hooks --hooks-dir hook-test vagrant

or

    ./make-hooks --hooks-dir hook-test squashfs disk-image vagrant

Take a look at hooks.d/base/series for available series files.

To post a comment you must log in.
Revision history for this message
Dan Watkins (oddbloke) wrote :

Overall, I really like this. The code is well laid out, and the series concept should serve us well in the future due to its flexibility. Thanks!

(I have some inline comments on the Python script, but none of these relate to the overall behaviour of the script or this MP.)

review: Needs Fixing
Revision history for this message
Tobias Koch (tobijk) wrote :

Thanks a lot for the detailed review, @daniel-thewatkins! I think I have addressed everything you brought up in the new submission below. I also verified that the script works as Python3-only on Xenial.

Revision history for this message
Philip Roche (philroche) wrote :

Very nice approach and the Readme is very helpful. I would like some docstrings in the python script though as I know future me will need them ;p

Apart from that I am +1

review: Needs Fixing
Revision history for this message
Tobias Koch (tobijk) wrote :

Thank you @philroche, let me know if this works or if anything needs further clarification.

Revision history for this message
Francis Ginther (fginther) wrote :

Is the intention that the execution order of hooks be identical once this change lands? That currently isn't the case and may lead to changes in the images. For example, the following generates:

./make-hooks --hooks-dir ../hooks vmdk vagrant
...
[HOOK] 005-ssh_authentication.chroot => chroot/ssh_authentication.chroot
...
[HOOK] 016-vagrant.binary => base/vagrant.binary

But prior to this change, these two hooks were in the opposite order:

042-vagrant.binary
052-ssh_authentication.chroot

Am I missing something (like are all the chroot hooks executed before the binary hooks)?

I also have a concern with defining the RESOURCE map in the make-hooks script (see inline comment).

Otherwise, I think this is a good approach to the problem. Thanks for working on it.

review: Needs Fixing
Revision history for this message
Steve Langasek (vorlon) wrote :

On Thu, Oct 25, 2018 at 03:47:11PM -0000, Francis Ginther wrote:
> Am I missing something (like are all the chroot hooks executed before the
> binary hooks)?

Yes, all chroot hooks are executed before the binary hooks.

Revision history for this message
Tobias Koch (tobijk) wrote :

> Am I missing something (like are all the chroot hooks executed before the
> binary hooks)?

Yes, exactly, chroot hooks and binary hooks are run in separate batches, it is not possible to interleave them. See the ACHTUNG note in the script header.

Revision history for this message
Francis Ginther (fginther) wrote :

> > Am I missing something (like are all the chroot hooks executed before the
> > binary hooks)?
>
> Yes, exactly, chroot hooks and binary hooks are run in separate batches, it is
> not possible to interleave them. See the ACHTUNG note in the script header.

DOH! Thanks for already mentioning this in the comments.

My only remaining concern is the definition of the extra RESOURCES.

Revision history for this message
Tobias Koch (tobijk) wrote :

@fginther, nobody reads the comments ;) I think you having missed that piece of information is really just bad documentation. I added the same note to the README, where it really belongs.

Thank you for suggesting to take out the resource mappings. That really makes a lot of sense. Following your suggestion, the script now looks for base/resources.yaml and extra/resources.yaml.

I also updated

https://code.launchpad.net/~cloudware/livecd-rootfs/+git/cpc_packaging.extra/+merge/356266

to match these changes.

@daniel-thewatkins, @philroche, I believe I have addressed your concerns, as well. Please have another look.

Revision history for this message
Francis Ginther (fginther) wrote :

Thanks for working on the resource map. I'm happy with this approach.

I do prefer to use yaml.safe_load() over yaml.load(), but I think it's use is fine here considering we're only loading our own code.

review: Approve
Revision history for this message
Dan Watkins (oddbloke) wrote :

Thanks!

review: Approve
Revision history for this message
Philip Roche (philroche) wrote :

Happy to go merge with the two current approvals

review: Abstain
Revision history for this message
Steve Langasek (vorlon) wrote :

Apologies for taking so long to give feedback on this. I knew that such a significant refactor was owed a thorough review, and I didn't find time to do so until now.

Comments inline.

review: Needs Fixing
Revision history for this message
Tobias Koch (tobijk) wrote :

Also revamped this taking into account @xnox's comments on

https://code.launchpad.net/~tobijk/livecd-rootfs/snap-coherence/+merge/358632

Revision history for this message
Tobias Koch (tobijk) wrote :

@vorlon, thank you so much for taking the time to review this in depth!

* There is now also a series file for the qcow2 target.

* It turned out that copying resources was not even necessary, because all scripts except one reference resources relative to their location. So I have removed that part completely.

I would like to keep the series file for the chroot, because:

* I find it more consistent to have all hooks placed/generated in the same way in the CPC subproject.

* We will want to augment the syntax of the series files in the future to also take into account arch, subarch and other attributes of the build that are currently handled by case statements in the scripts and this can also be useful for chroot customization,

* This is not on the table, right now, but I can imagine that we will find it useful to drop the ability to build different image target sets together and do per target set (and arch) chroot customizations. There can be advantages to this such being able to seed all target specific packages and snaps into the chroot instead of having to mount, fiddle and re-sparsen an image.

Revision history for this message
Dan Watkins (oddbloke) wrote :

On Fri, Nov 30, 2018 at 01:01:15PM -0000, Tobias Koch wrote:
> * This is not on the table, right now, but I can imagine that we will find it useful to drop the ability to build different image target sets together and do per target set (and arch) chroot customizations. There can be advantages to this such being able to seed all target specific packages and snaps into the chroot instead of having to mount, fiddle and re-sparsen an image.

+1, we definitely want to leave the door open to be able to do this in
the future.

Revision history for this message
Steve Langasek (vorlon) wrote :

On Fri, Nov 30, 2018 at 02:27:22PM -0000, Dan Watkins wrote:
> On Fri, Nov 30, 2018 at 01:01:15PM -0000, Tobias Koch wrote:
> > * This is not on the table, right now, but I can imagine that we will
> > find it useful to drop the ability to build different image target
> > sets together and do per target set (and arch) chroot customizations.
> > There can be advantages to this such being able to seed all target
> > specific packages and snaps into the chroot instead of having to
> > mount, fiddle and re-sparsen an image.

> +1, we definitely want to leave the door open to be able to do this in
> the future.

I would argue, however, that until this actually *is* on the table, such
handling of chroot scripts is still just unnecessary complexity.

Revision history for this message
Tobias Koch (tobijk) wrote :

So is that a veto? Subsystem maintainers are +1.

Revision history for this message
Steve Langasek (vorlon) wrote :

> So is that a veto? Subsystem maintainers are +1.

Yes, I think I do have to insist that the changes to chroot hooks not be included here. Having to keep the list of chroot hooks in sync between the directory contents and the series file is error-prone, and should be avoided unless and until there is a reason to define a series that doesn't include all the chroot hooks.

review: Needs Fixing
Revision history for this message
Tobias Koch (tobijk) wrote :

@vorlon, I have made the necessary changes. Please check, if you are ok with this. Thanks!

Revision history for this message
Steve Langasek (vorlon) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches