Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd: add new image-builder binary and initial list-distros #997

Draft
wants to merge 20 commits into
base: main
Choose a base branch
from

Conversation

mvo5
Copy link
Contributor

@mvo5 mvo5 commented Oct 28, 2024

[draft as this is sill WIP and questions like where to get the authorative list of distros/repos and if we should embed them via "embed:" to have a simpler distribution mechanism etc]

This commit adds a new image-builder binary that will be capable
to build images standalone (daemonless). There are various use-cases
for this, the most important one is CI/CD pipelines.

This binary should eventually also replace the existing "cmd/list-images" and
"cmd/build" binaries (and potentially more) and it will cherry pick a lot of the
functionality from there. I decided against starting from one of the exiting binaries
because it allows a slightly cleaner start but this work is early so we could still
reconsider if people feel strongly it should be done the other way around.

@mvo5 mvo5 requested a review from achilleas-k October 28, 2024 10:40
@mvo5 mvo5 force-pushed the add-image-builder-cmd branch 9 times, most recently from e727cd2 to e130485 Compare October 30, 2024 18:07
Comment on lines 33 to 34
// XXX: what/how much do we expose here?
var options distro.ImageOptions
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For on-prem, we use ImageOptions for the stuff that is passed on the CLI and is not part of the BP. E.g. image size.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is something we need to think about. The image options, like Tomáš said, is (mostly) for things that come from the command line. This includes:

  • image size
  • ostree options (url, ref, and parent, when using composer-cli compose start-ostree).

https://github.com/osbuild/osbuild-composer/blob/a7cd521325504a43d3708f8f91ab63999862b279/internal/weldr/api.go#L2549-L2556

But it's also used for other things that get set automatically (or semi-automatically):

Copy link
Member

@achilleas-k achilleas-k left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really like this PR (what it's starting, in particular). I realise there are many reasons why it's a draft, but it makes me worry that it will be forgotten if we don't move towards something more concrete and start merging soon.

I think we might get the ball rolling if we start small. A PR that only implements list-images for example would be very quick to merge, and after that we'd have the image-builder command ready to expand on and start using in testing (replacing the existing cmd/list-images).

Comment on lines +63 to +72
// XXX: this will list 802 images right now, we need a sensible
// default here, maybe without --filter just list all available
// distro names?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's fine to list everything if it's unfiltered. Perhaps in the human-readable version we can have a count on the last line with a suggestion to look into --filter, so it's clear that the user is getting too much output.
For the machine readable case, listing all is definitely ok as far as I'm concerned.

mvo5 added a commit to mvo5/images that referenced this pull request Nov 6, 2024
This commit creates a new `imagefilter` package that can be used
to create a filter for the available images that can be build by
the images library.

Support for prefixes and fnmatch style globbing is available.

This will eventually allows us to do:
```
$ image-builder --list-images --filter src:aarch64 --filter type:qcow*
or
$ image-builder --list-images --filter ami
```

The filtering can be both with or without a prefix, i.e. when doing
a "simple" search all common fields (disro,arch,imageType) are checked
but with a prefix search things can be narrowed down more.

Initially the following prefixes filters are supported:
"distro:" - the distro name, e.g. rhel-9, or fedora*
"arch:" - the architecture, e.g. x86_64
"type": - the image type, e.g. ami, or qcow?
"bootmode": - the bootmode, e.g. "legacy", "uefi", "hybrid"

(Split out from the spike in osbuild#997)
mvo5 added a commit to mvo5/images that referenced this pull request Nov 6, 2024
This commit creates a new `imagefilter` package that can be used
to create a filter for the available images that can be build by
the images library.

Support for prefixes and fnmatch style globbing is available.

This will eventually allows us to do:
```
$ image-builder --list-images --filter src:aarch64 --filter type:qcow*
or
$ image-builder --list-images --filter ami
```

The filtering can be both with or without a prefix, i.e. when doing
a "simple" search all common fields (disro,arch,imageType) are checked
but with a prefix search things can be narrowed down more.

Initially the following prefixes filters are supported:
"distro:" - the distro name, e.g. rhel-9, or fedora*
"arch:" - the architecture, e.g. x86_64
"type": - the image type, e.g. ami, or qcow?
"bootmode": - the bootmode, e.g. "legacy", "uefi", "hybrid"

(Split out from the spike in osbuild#997)
@mvo5 mvo5 force-pushed the add-image-builder-cmd branch 2 times, most recently from eca4753 to 08ff6df Compare November 6, 2024 16:25
mvo5 added a commit to mvo5/images that referenced this pull request Nov 7, 2024
This commit creates a new `imagefilter` package that can be used
to create a filter for the available images that can be build by
the images library.

Support for prefixes and fnmatch style globbing is available.

This will eventually allows us to do:
```
$ image-builder --list-images --filter arch:aarch64 --filter type:qcow*
or
$ image-builder --list-images --filter ami
```

The filtering can be both with or without a prefix, i.e. when doing
a "simple" search all common fields (disro,arch,imageType) are checked
but with a prefix search things can be narrowed down more.

Initially the following prefixes filters are supported:
"distro:" - the distro name, e.g. rhel-9, or fedora*
"arch:" - the architecture, e.g. x86_64
"type": - the image type, e.g. ami, or qcow?
"bootmode": - the bootmode, e.g. "legacy", "uefi", "hybrid"

(Split out from the spike in osbuild#997)
mvo5 added a commit to mvo5/images that referenced this pull request Nov 8, 2024
This commit creates a new `imagefilter` package that can be used
to create a filter for the available images that can be build by
the images library.

Support for prefixes and fnmatch style globbing is available.

This will eventually allows us to do:
```
$ image-builder --list-images --filter arch:aarch64 --filter type:qcow*
or
$ image-builder --list-images --filter ami
```

The filtering can be both with or without a prefix, i.e. when doing
a "simple" search all common fields (disro,arch,imageType) are checked
but with a prefix search things can be narrowed down more.

Initially the following prefixes filters are supported:
"distro:" - the distro name, e.g. rhel-9, or fedora*
"arch:" - the architecture, e.g. x86_64
"type": - the image type, e.g. ami, or qcow?
"bootmode": - the bootmode, e.g. "legacy", "uefi", "hybrid"

(Split out from the spike in osbuild#997)
thozza pushed a commit to mvo5/images that referenced this pull request Nov 8, 2024
This commit creates a new `imagefilter` package that can be used
to create a filter for the available images that can be build by
the images library.

Support for prefixes and fnmatch style globbing is available.

This will eventually allows us to do:
```
$ image-builder --list-images --filter arch:aarch64 --filter type:qcow*
or
$ image-builder --list-images --filter ami
```

The filtering can be both with or without a prefix, i.e. when doing
a "simple" search all common fields (disro,arch,imageType) are checked
but with a prefix search things can be narrowed down more.

Initially the following prefixes filters are supported:
"distro:" - the distro name, e.g. rhel-9, or fedora*
"arch:" - the architecture, e.g. x86_64
"type": - the image type, e.g. ami, or qcow?
"bootmode": - the bootmode, e.g. "legacy", "uefi", "hybrid"

(Split out from the spike in osbuild#997)
mvo5 added a commit to mvo5/images that referenced this pull request Nov 9, 2024
This commit creates a new `imagefilter` package that can be used
to create a filter for the available images that can be build by
the images library.

Support for prefixes and fnmatch style globbing is available.

This will eventually allows us to do:
```
$ image-builder --list-images --filter src:aarch64 --filter type:qcow*
or
$ image-builder --list-images --filter ami
```

The filtering can be both with or without a prefix, i.e. when doing
a "simple" search all common fields (disro,arch,imageType) are checked
but with a prefix search things can be narrowed down more.

Initially the following prefixes filters are supported:
"distro:" - the distro name, e.g. rhel-9, or fedora*
"arch:" - the architecture, e.g. x86_64
"type": - the image type, e.g. ami, or qcow?
"bootmode": - the bootmode, e.g. "legacy", "uefi", "hybrid"

(Split out from the spike in osbuild#997)
github-merge-queue bot pushed a commit that referenced this pull request Nov 11, 2024
This commit creates a new `imagefilter` package that can be used
to create a filter for the available images that can be build by
the images library.

Support for prefixes and fnmatch style globbing is available.

This will eventually allows us to do:
```
$ image-builder --list-images --filter arch:aarch64 --filter type:qcow*
or
$ image-builder --list-images --filter ami
```

The filtering can be both with or without a prefix, i.e. when doing
a "simple" search all common fields (disro,arch,imageType) are checked
but with a prefix search things can be narrowed down more.

Initially the following prefixes filters are supported:
"distro:" - the distro name, e.g. rhel-9, or fedora*
"arch:" - the architecture, e.g. x86_64
"type": - the image type, e.g. ami, or qcow?
"bootmode": - the bootmode, e.g. "legacy", "uefi", "hybrid"

(Split out from the spike in #997)
@mvo5
Copy link
Contributor Author

mvo5 commented Nov 12, 2024

Just FTR - this will be transferred to https://github.com/osbuild/image-builder-cli (unless someone has concerns)

@mvo5 mvo5 force-pushed the add-image-builder-cmd branch 3 times, most recently from f6194f3 to b8cb4e8 Compare November 12, 2024 19:29
@mvo5 mvo5 force-pushed the add-image-builder-cmd branch 2 times, most recently from bd762f4 to f232368 Compare November 15, 2024 09:59
mvo5 and others added 19 commits November 15, 2024 16:00
This commit contains an abreviated version of an osbuild jsonseq
output log. Most of the repetitive data from the curl and rpm
stages got removed as they don't add (much) to the understanding.

The data was generated via:
```
$ sudo python3 -m osbuild --libdir . --monitor JSONSeqMonitor \
   --export image --output-directory /tmp/out \
   ./test/data/manifests/fedora-boot.json > osbuild-status-output.json
```
This commit adds support for the jsonseq based monitoring that
osbuild provides. This is useful for machine readable status
reporting.
This commit adds a `Status.Trace` string in the osbuildmonitor.

Trace contains a single log line, usually very low-level or
stage output bug useful for e.g. bug reporting. Should in
general not be displayed to the user but the concatenation
of all "trace" lines should give the same information as
running osbuild on a terminal.
This commit adds `Status.Timestamp` so that it's easier to correlate
what took how long when reconstructing the log (e.g. for bugreporting).

See also:
https://github.com/osbuild/images/compare/main...mvo5:osbuildmonitor-testdata?expand=1
for the full log.
This commit adds support cabilities to filter the list of distros
based on a given search expression. Those are:
```
foo
name:foo
arch:i386
type:ami
bootmode:uefi
```
and they will filter the list of distros.
This commit adds a new `image-builder` binary that will (eventually)
be capable to build images standalone (daemonless). There are various
use-cases for this, the most important one is CI/CD pipelines but also
providing a common abstraction over the "images" library (and potentially
later "otk").

This commit implements basic a `list-images` command with filtering
and text and json output, e.g.
```
$ image-builder list-images --filter bootmode:none --filter name:fedora-39 --filter arch:s390x
fedora-39 --arch s390x --type container

$ ./image-builder list-images --filter bootmode:none --filter name:fedora-39 --filter arch:s390x --format=json
{"distro":{"name":"fedora-39"},"arch":{"name":"s390x"},"image_type":{"name":"container"}}
```
This commit adds support to filter image based on (unresolved)
packages. E.g.:
```
$ ./image-builder list-images --filter pkg:gdisk
...
rhel-9.6 type:vhd arch:x86_64
```

Based on an idea from Achilleas-k, many thanks.
This commit allows to change the filename when creating a
manifest from an image type. This is useful when doing a UI for users,
e.g. this will allow us to support:
```
$ image-builder build rhel-9 type:qcow2 --output foo.img
```
(this will also be useful for bootc-image-builder).

Well, osbuild itself will still put it under a directory when
doing main_cli.py:exports() but that is something orthogonal.
@mvo5 mvo5 force-pushed the add-image-builder-cmd branch 2 times, most recently from 313e543 to eba44b4 Compare November 15, 2024 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants