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

cli: add system-reinstall-bootc binary #1063

Merged
merged 5 commits into from
Feb 6, 2025

Conversation

omertuc
Copy link
Contributor

@omertuc omertuc commented Jan 27, 2025

See commit messages

@omertuc omertuc force-pushed the reinstallcli branch 2 times, most recently from 88934de to a645547 Compare January 27, 2025 14:11
Copy link
Collaborator

@cgwalters cgwalters left a comment

Choose a reason for hiding this comment

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

Nice, thanks for getting the ball rolling here!

reinstall-cli/Cargo.toml Outdated Show resolved Hide resolved
reinstall-cli/Cargo.toml Outdated Show resolved Hide resolved
reinstall-cli/src/main.rs Outdated Show resolved Hide resolved
reinstall-cli/src/main.rs Outdated Show resolved Hide resolved
@omertuc omertuc force-pushed the reinstallcli branch 11 times, most recently from f6f60e7 to 30b8271 Compare January 29, 2025 23:28
@omertuc omertuc changed the title WIP: bootc-reinstall CLI cli: add bootc-reinstall binary Jan 29, 2025
@omertuc omertuc marked this pull request as ready for review January 29, 2025 23:29
@omertuc omertuc force-pushed the reinstallcli branch 5 times, most recently from a4d4e6f to 7498bdf Compare January 30, 2025 09:57
Copy link
Collaborator

@cgwalters cgwalters left a comment

Choose a reason for hiding this comment

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

Awesome progress!! Various comments follow

reinstall-cli/src/podman.rs Outdated Show resolved Hide resolved
reinstall-cli/src/prompt.rs Outdated Show resolved Hide resolved
reinstall-cli/src/users.rs Outdated Show resolved Hide resolved
reinstall-cli/src/users.rs Outdated Show resolved Hide resolved
reinstall-cli/src/users.rs Outdated Show resolved Hide resolved
reinstall-cli/src/podman.rs Outdated Show resolved Hide resolved
reinstall-cli/src/podman.rs Outdated Show resolved Hide resolved
reinstall-cli/src/main.rs Outdated Show resolved Hide resolved
reinstall-cli/Cargo.toml Outdated Show resolved Hide resolved
reinstall-cli/src/config/mod.rs Outdated Show resolved Hide resolved
Copy link

@germag germag left a comment

Choose a reason for hiding this comment

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

Just a general comment, even if this simple comment, I think It will better to split some part in different commits, like adding tracing, etc.

reinstall-cli/Cargo.toml Outdated Show resolved Hide resolved
cli/Cargo.toml Show resolved Hide resolved
cli/src/main.rs Show resolved Hide resolved
contrib/packaging/bootc.spec Show resolved Hide resolved
reinstall-cli/src/users.rs Outdated Show resolved Hide resolved
reinstall-cli/src/config/mod.rs Outdated Show resolved Hide resolved
reinstall-cli/src/config/mod.rs Outdated Show resolved Hide resolved
reinstall-cli/src/config/mod.rs Outdated Show resolved Hide resolved
reinstall-cli/src/podman.rs Outdated Show resolved Hide resolved
reinstall-cli/src/podman.rs Outdated Show resolved Hide resolved
@omertuc omertuc changed the title cli: add bootc-reinstall binary cli: add system-reinstall-bootc binary Feb 5, 2025
Copy link
Collaborator

@cgwalters cgwalters left a comment

Choose a reason for hiding this comment

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

Looks sane to me! Missing DCO is the main thing

// The container needs to access the host's PID namespace to mount host directories
"--pid=host",
// Since https://github.com/containers/bootc/pull/919 this mount should not be needed, but
// some reason with e.g. quay.io/fedora/fedora-bootc:41 it is still needed.
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should try to root cause some of this. Let's pile onto #1053

@omertuc omertuc force-pushed the reinstallcli branch 2 times, most recently from b9743fd to 241ea1f Compare February 5, 2025 23:39
@omertuc
Copy link
Contributor Author

omertuc commented Feb 5, 2025

Branched off some discussions / issues / further work into:

#1080 #1081 #1082 #1083

@omertuc
Copy link
Contributor Author

omertuc commented Feb 5, 2025

EDIT: Done

Still need to fix Cargo.lock, couldn't build because I need to upgrade to Fedora 41 since the ostree dependency became 2025

Refactor the tracing initialization code into a utility function, so
that it can be shared with future CLIs that we'll add.

Signed-off-by: Omer Tuchfeld <[email protected]>
The CLI crate does not use clap directly, so it does not need to
depend on it.

It does use it indirectly, through the our lib crate

Signed-off-by: Omer Tuchfeld <[email protected]>
No reason for it to be different than what we have in the root
Cargo.toml

Signed-off-by: Omer Tuchfeld <[email protected]>
# Background

The current usage instructions for bootc involve a long podman
invocation.

# Issue

It's hard to remember and type the long podman invocation, making the
usage of bootc difficult for users.

See https://issues.redhat.com/browse/BIFROST-610 and https://issues.redhat.com/browse/BIFROST-611

(Epic https://issues.redhat.com/browse/BIFROST-594)

# Solution

We want to make the usage of bootc easier by providing a new Fedora/RHEL
subpackage that includes a new binary `system-reinstall-bootc`. This binary
will simplify the usage of bootc by providing a simple command line
interface (configured either through CLI flags or a configuration file)
with an interactive prompt that allows users to reinstall the current
system using bootc.

The commandline will handle helping the user choose SSH keys / users,
warn the user about the destructive nature of the operation, and
eventually report issues they might run into in the various clouds (e.g.
missing cloud agent on the target image)

# Implementation

Added new system-reinstall-bootc crate that outputs the new
system-reinstall-bootc binary. This new crate depends on the existing utils crate.

Refactored the tracing initialization from the bootc binary into the
utils crate so that it can be reused by the new crate.

The new CLI can either be configured through commandline flags or
through a configuration file in a path set by the environment variable
`BOOTC_REINSTALL_CONFIG`.

The configuration file is a YAML file.

# Limitations

Only root SSH keys are supported. The multi user selection TUI is
implemented, but if you choose anything other than root you will get an
error.

# TODO

Missing docs, missing functionality. Everything is in alpha stage. User
choice / SSH keys / prompt disabling should also eventually be supported
to be configured through commandline arguments or the configuration
file.

Signed-off-by: Omer Tuchfeld <[email protected]>
Modified the bootc.spec file to generate a new subpackage which includes
the new system-reinstall-bootc binary.

# Try

Try out instructions:

```bash
# Make srpm
cargo xtask package-srpm

# Mock group
sudo usermod -a -G mock $(whoami)
newgrp mock

# Build RPM for RHEL
mock --rebuild -r rhel+epel-9-x86_64 --rebuild target/bootc-*.src.rpm
```

Then install the RPM (`/var/lib/mock/rhel+epel-9-x86_64/result/bootc-reinstall-2*.el9.x86_64.rpm`) on [a rhel9 gcp vm](https://console.cloud.google.com/compute/instanceTemplates/details/rhel9-dev-1?project=bifrost-devel&authuser=1&inv=1&invt=Abn-jg) instance template

Signed-off-by: Omer Tuchfeld <[email protected]>
@cgwalters cgwalters merged commit c8e1fb8 into containers:main Feb 6, 2025
23 checks passed
@cgwalters
Copy link
Collaborator

Branched off some discussions / issues / further work into:

I also added a new label too!

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.

3 participants