public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@siemens.com>
To: Cedric Hombourger <Cedric_Hombourger@mentor.com>,
	isar-users@googlegroups.com
Cc: joe_macdonald@mentor.com,
	Henning Schild <henning.schild@siemens.com>,
	"Cirujano-Cuesta, Silvano" <silvano.cirujano-cuesta@siemens.com>
Subject: Re: [RFC] Image templates
Date: Tue, 1 Dec 2020 09:40:41 +0100	[thread overview]
Message-ID: <6218fc7b-2515-5b81-91b6-6fd0d275ae02@siemens.com> (raw)
In-Reply-To: <6bf9a786-51b8-2430-90f5-2857746d003f@mentor.com>

On 01.12.20 08:59, Cedric Hombourger wrote:
> Image Templates for ISAR
> ========================
> 
> Introduction
> ------------
> 
> Embedded System projects may have multiple teams working at different
> levels. It is not uncommon to have groups creating a "base platform"
> which is handed over to product teams to customize further.
> Thanks to ISAR leveraging bitbake, image recipes from a base layer may
> be easily extended by product layers but also with its ability to
> produce and use a `base-apt` instead of upstream package feeds.
> This workflow functions well in many cases, it may not be optimal for
> application teams. Such teams are typically receiving a base platform
> release that is likely to be left untouched for weeks.
> Creating a product image for those teams is sometimes as easy as adding
> a few packages.

There is another use case, even for base image developers: accelerating
the turn-around time when working only on few, widely isolated packages,
may it be the kernel or a bootloader artifact.

For that scenario, it should be possible to define an image template
excluding those bits, only injecting them on top in a second step.

> 
> In such cases, it may be desirable to have a mechanism for ISAR to
> construct product images starting from the base platform root
> file-system instead of ISAR's bootstrap root file-system. We will refer
> to these base platform root file-systems as _Template Images_.
> 
> This document will describe both the construction and the use of
> _template images_.
> 
> Construction
> ------------
> 
> Developers needing to produce image templates in addition to bootable
> system images will have their image recipes `inherit` the
> `produce-image-template` class either as part of their image development
> or by extending an existing image with an appropriate `.bbappend`.
> 
> The class would invoke a `do_rootfs_template` task after
> `do_rootfs_install` and before the post-processing tasks (which should
> be applied on the final image). This new task would simply create a
> template image in the deploy folder built from the common root
> file-system artifacts. Some systems may have additional, more extensive
> post-processing operations that must be performed on the final
> image, this class will still allow for such operations to function
> normally.
> 
> It is anticipated that configuration files in `/etc/apt/sources.list.d`
> and `/etc/resolv.conf` should be excluded (they should be recreated
> while the template image is imported). A subsequent update
> will define a criteria for determining which files should be excluded
> from the tarball. As yet the specific mechanism has not been determined,
> whether it would be a file list, pattern or some other
> external attributes. We anticipate other objects that may need to be
> excluded are `/etc/hosts` and proxy configuration, to name two simple
> examples.
> 
> The process of constructing the base image would then continue as usual
> (with post-processing and imager tasks).
> 
> It is suggested to expose the produced image template as an opaque
> binary blob and use a `.tmpl.img` file extension although the initial
> implementation is anticipated to be a compressed tarball.
> The template filesystem may need embedded meta-data to be consumed by
> import mechanism or image recipes that make use of templates but omitted
> from the final rootfs. It would be useful at the outset
> to either specify a minimal set of metadata (build date, image name and
> feature list is the initial list to be considered) and the structure of
> that metadata (currently considering either JSON-formatted
> suitable for extraction with `jq` or `deb` packaging, which has embedded
> metadata in the cpio archive).
> 
> Usage
> -----
> 
> Application teams may create image recipes referencing image templates
> in their SRC_URI list. As noted above, image templates would use the
> `.tmpl.img` file extension. This would be used by ISAR's `rootfs`
> class to locate image templates in the list and make sure that only one
> template is specified (extracting a template over another would have
> unpredictable results).
> 
> If the bulk of the template intelligence is present in the `do_rootfs`
> stages, the `do_rootfs_prepare` task from the `rootfs` class would
> behave differently.  In this case, an image template may be added to
> an image SRC_URI. Instead of copying ISAR's bootstrap rootfs, the
> template feature would instead unpack the specified template. It would
> also be necessary to copy `/etc/apt/sources.list.d` from the bootstrap
> and possibly other files (e.g. `/etc/resolv.conf`). As the environment
> may include different apt sources, a complete `apt-get update` would be
> in order.
> 
> ISAR would then "enter" the unpacked template carrying updated apt
> sources to install packages listed in `IMAGE_INSTALL` and
> `IMAGE_PREINSTALL` using `apt- get install` as it does today in
> `do_rootfs_install`.
> 
> This design should allow images constructed from an image template to
> produce a new image template (e.g. a base platform could provide a
> template having a BSP and a minimal Debian system, and middleware teams
> could then produce their own template with middleware stacks added and
> finally consumed by application teams to produce a final system image).
> 

There will likely be a number of traps we can stumble over, but the
general vision is shared.

One of the trap is that you may not only need a target image template
but also the corresponding buildchroots, if not isar-bootstraps.

Would your model be that a developer works within the layer that creates
the template? A key issue would be that changes to the layer that
invalidate the template would be detected and make the template-based
build fail or fall back to the full build.

Or would your model be that templating enforce a split build via
separate repos? That might be problematic from the maintenance
perspective as application injection will come before imaging, and the
latter is not the task of an application developer.

> Future Work
> -----------
> 
> It may be desirable to offer a mechanism to remove packages coming from
> an image template (application teams may need to optimize the final
> system image to meet the footprint constraints of their design and/or
> to reduce the attack surface by removing services they do not need).
> 
> Status
> ------
> 
> This high-level design was created to seek early feedback from the ISAR
> developer community by exposing the problem we are trying to solve and
> the mechanism we are proposing as a solution. The next step would be
> the development of a Proof-of-Concept in the event where positive
> comments are received. This document may also be updated as feedback is
> received and may result in different approaches being discussed.
> 
> We will be happy to answer questions you may have or provide more
> details in areas where this document would be too evasive.
> 

The whole thing also reminds me a lot of how docker images are created.
I wonder to which degree we can learn from that, reuse concepts or avoid
pitfalls. Adding Silvano with whom I was recently discussing base
container image generation via Isar.

Jan

-- 
Siemens AG, T RDA IOT
Corporate Competence Center Embedded Linux

  reply	other threads:[~2020-12-01  8:40 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-01  7:59 Cedric Hombourger
2020-12-01  8:40 ` Jan Kiszka [this message]
2020-12-02 14:42   ` Joe MacDonald
2020-12-02 15:01     ` Joe MacDonald
2020-12-01  9:13 ` Henning Schild
2020-12-01 10:10   ` Cedric Hombourger
2020-12-02 13:00 ` Claudius Heine
2020-12-02 16:37   ` Joe MacDonald
2020-12-03 12:23     ` Claudius Heine
2020-12-07  6:18       ` Jan Kiszka
2020-12-13 15:20 ` Baurzhan Ismagulov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6218fc7b-2515-5b81-91b6-6fd0d275ae02@siemens.com \
    --to=jan.kiszka@siemens.com \
    --cc=Cedric_Hombourger@mentor.com \
    --cc=henning.schild@siemens.com \
    --cc=isar-users@googlegroups.com \
    --cc=joe_macdonald@mentor.com \
    --cc=silvano.cirujano-cuesta@siemens.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox