Skip to content

Commit f1ab775

Browse files
authored
Merge pull request #1164 from ckyrouac/reinstall-cloudinit
reinstall: Pull podman image early
2 parents b26d5ca + 3e1b0bf commit f1ab775

File tree

2 files changed

+22
-10
lines changed

2 files changed

+22
-10
lines changed

system-reinstall-bootc/src/main.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,16 @@ fn run() -> Result<()> {
2020

2121
let config = config::ReinstallConfig::load().context("loading config")?;
2222

23+
podman::ensure_podman_installed()?;
24+
25+
//pull image early so it can be inspected, e.g. to check for cloud-init
26+
let mut pull_image_command = podman::pull_image_command(&config.bootc_image);
27+
pull_image_command
28+
.run_with_cmd_context()
29+
.context(format!("pulling image {}", &config.bootc_image))?;
30+
31+
println!();
32+
2333
let ssh_key_file = tempfile::NamedTempFile::new()?;
2434
let ssh_key_file_path = ssh_key_file
2535
.path()
@@ -30,18 +40,14 @@ fn run() -> Result<()> {
3040

3141
prompt::get_ssh_keys(ssh_key_file_path)?;
3242

33-
let mut reinstall_podman_command = podman::command(&config.bootc_image, ssh_key_file_path);
43+
let mut reinstall_podman_command =
44+
podman::reinstall_command(&config.bootc_image, ssh_key_file_path);
3445

3546
println!();
36-
3747
println!("Going to run command {:?}", reinstall_podman_command);
3848

3949
prompt::temporary_developer_protection_prompt()?;
4050

41-
// At this poihnt, the user has already given us permission to reinstall their system, so we
42-
// feel confident with just installing podman without any further user interaction.
43-
podman::ensure_podman_installed()?;
44-
4551
reinstall_podman_command
4652
.run_with_cmd_context()
4753
.context("running reinstall command")?;

system-reinstall-bootc/src/podman.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
use crate::prompt;
2+
13
use super::ROOT_KEY_MOUNT_POINT;
24
use anyhow::{ensure, Context, Result};
35
use bootc_utils::CommandRunExt;
46
use std::process::Command;
57
use which::which;
68

7-
pub(crate) fn command(image: &str, ssh_key_file: &str) -> Command {
9+
pub(crate) fn reinstall_command(image: &str, ssh_key_file: &str) -> Command {
810
let mut podman_command_and_args = [
911
// We use podman to run the bootc container. This might change in the future to remove the
1012
// podman dependency.
@@ -62,6 +64,12 @@ pub(crate) fn command(image: &str, ssh_key_file: &str) -> Command {
6264
command
6365
}
6466

67+
pub(crate) fn pull_image_command(image: &str) -> Command {
68+
let mut command = Command::new("podman");
69+
command.args(["pull", image]);
70+
command
71+
}
72+
6573
/// Path to the podman installation script. Can be influenced by the build
6674
/// SYSTEM_REINSTALL_BOOTC_INSTALL_PODMAN_PATH parameter to override. Defaults
6775
/// to /usr/lib/system-reinstall-bootc/install-podman
@@ -78,9 +86,7 @@ pub(crate) fn ensure_podman_installed() -> Result<()> {
7886
return Ok(());
7987
}
8088

81-
tracing::warn!(
82-
"Podman was not found on this system. It's required in order to install a bootc image. Attempting to install it automatically."
83-
);
89+
prompt::ask_yes_no("Podman was not found on this system. It's required in order to install a bootc image. Do you want to install it now?", true)?;
8490

8591
ensure!(
8692
which(podman_install_script_path()).is_ok(),

0 commit comments

Comments
 (0)