-
Notifications
You must be signed in to change notification settings - Fork 9
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
Add convert command using bib #58
base: main
Are you sure you want to change the base?
Conversation
I'd be tempted to ignore the AWS-specific features. I am sure there AWS-specific CLI tools which can do that already, so just converting to an AMI checks the box for me. |
Do you mean also removing |
For now, yes. Let's focus on converting first. AWS integration is up to debate IMO. |
I almost forgot, at DevConf.cz I talked to @ondrejbudai, and he told me that he intends to use |
SGTM 👍 |
If we are going to support uploads, I would prefer these options to become more generic. I would figure users would want similar support for Azure and Google Cloud ... |
I'm worried about an explosion of options, maybe instead of
so each "format" is a sub-command with its own options if it's needed, o none like
|
This strongly relates to https://gitlab.com/fedora/bootc/tracker/-/issues/2 which argues that in a nutshell:
In this world it's actually bootc-sdk that has sub-verbs, not the tool here. |
Agreed, but in the meantime we need to do something here to support bib. I think going to a sub-command per format is nicer from a UI perspective. I still need to understand how the sdk will work, I thought it will be more like a library, in any case I agree that podma-bootc should be a wrapper around it |
👍 podman-bootc convert is something we need short term. The SDK idea needs more cooking beyond August. |
Although I prefer |
Add convert command that uses bootc image builder (bib) to create disk images Signed-off-by: German Maglione <gmaglione@redhat.com>
RootCmd.AddCommand(convertCmd) | ||
convertCmd.Flags().BoolVar(&quiet, "quiet", false, "Suppress output from disk image creation") | ||
convertCmd.Flags().StringVar(&options.Config, "config", "", "Image builder config file") | ||
convertCmd.Flags().StringVar(&options.Output, "output", ".", "output directory (default \".\")") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
convertCmd.Flags().StringVar(&options.Output, "output", ".", "output directory (default \".\")") | |
convertCmd.Flags().StringVar(&options.Output, "output", ".", "output directory") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To avoid it being displayed twice.
|
||
_, err = os.Stat(buildOption.Config) | ||
if err != nil { | ||
return fmt.Errorf("config file %s: %w", buildOption.Config, err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return fmt.Errorf("config file %s: %w", buildOption.Config, err) | |
return fmt.Errorf("config file %q: %w", buildOption.Config, err) |
func Build(ctx context.Context, user user.User, imageNameOrId string, quiet bool, buildOption BuildOption) error { | ||
outputInfo, err := os.Stat(buildOption.Output) | ||
if err != nil { | ||
return fmt.Errorf("output directory %s: %w", buildOption.Output, err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return fmt.Errorf("output directory %s: %w", buildOption.Output, err) | |
return fmt.Errorf("output directory %q: %w", buildOption.Output, err) |
BibExtraArgs []string | ||
} | ||
|
||
func Build(ctx context.Context, user user.User, imageNameOrId string, quiet bool, buildOption BuildOption) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should error out early here when --output or --config haven't been set.
For the config, we could consider creating an empty temp file and pass that on?
} | ||
|
||
if !outputInfo.IsDir() { | ||
return fmt.Errorf("%s is not a directory ", buildOption.Output) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return fmt.Errorf("%s is not a directory ", buildOption.Output) | |
return fmt.Errorf("%q is not a directory ", buildOption.Output) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome work! 🚀
// the image | ||
convertCmd.Flags().StringVar(&options.Filesystem, "filesystem", "", "Overrides the root filesystem (e.g. xfs, btrfs, ext4)") | ||
// Corresponds to bib '--type', using '--format' to be consistent with podman | ||
convertCmd.Flags().StringVar(&options.Format, "format", "qcow2", "Disk image type (ami, anaconda-iso, iso, qcow2, raw, vmdk) [default: qcow2]") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should iso be dropped as it's an alias for anaconda-iso?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it was also removed from the README, see: https://github.com/osbuild/bootc-image-builder?tab=readme-ov-file#-image-types
|
||
func bibArguments(imageNameOrId string, buildOption BuildOption) []string { | ||
args := []string{ | ||
"--local", // we pull the image if necessary, so don't pull it from a registry |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
--local is always true now and is being deprecated, so no need for this.
}, | ||
{ | ||
Source: "/var/lib/containers/storage", | ||
Destination: "/var/lib/containers/storage", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm assuming that this command is always running in sudo / root and we shouldn't use ~/.local/share/containers/storage/
right?
This would cause an issue if a user did podman pull
not sudo podman pull
before running podman-bootc.
Unsure to be honest how this should be worked around / I guess we assume that podman-bootc is always running privileged?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we assume that podman-bootc is always running privileged?
No; we assume the container is running privileged inside podman machine.
I'd still shoot for a |
Add convert command that uses bootc image builder (bib) to create disk images
It's marked as draft because it requires some refactoring to cache the results. And complete the AMI options
The bib doc (https://github.com/osbuild/bootc-image-builder?tab=readme-ov-file#%EF%B8%8F-cloud-uploaders) show how to pass some of the AWS configuration using env vars and the aws directory:
So, I'm not sure if adding a generic
--env-file
or more specific ones:--aws-env-vars
and--aws-cfg-dir
I think there is a bug in osbuild, the export function (that calls "cp --reflink=auto ...") returns an error if stdin is not connected to the container, that is the reason
--quiet
shows an error even after succeeding, and for some reason that error doesn't happen if podman machine uses virtiofsd.