Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions rust/agama-autoinstall/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ agama-transfer = { path = "../agama-transfer" }
anyhow = { version = "1.0.98" }
tempfile = "3.20.0"
tokio = "1.46.0"
tracing = "0.1.44"
url = "2.5.4"
agama-l10n = { path = "../agama-l10n" }
18 changes: 12 additions & 6 deletions rust/agama-autoinstall/src/auto_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,16 @@ use agama_lib::http::BaseHTTPClient;
use anyhow::anyhow;

/// List of pre-defined locations for profiles.
const PREDEFINED_LOCATIONS: [&str; 6] = [
const PREDEFINED_LOCATIONS: [&str; 9] = [
// OEM drive (pre-installed systems)
"label://OEMDRV/autoinst.jsonnet",
"label://OEMDRV/autoinst.json",
"label://OEMDRV/autoinst.xml",
// root of the installation medium
"file:///run/initramfs/live/autoinst.jsonnet",
"file:///run/initramfs/live/autoinst.json",
"file:///run/initramfs/live/autoinst.xml",
// root filesystem (squashfs image)
"file:///autoinst.jsonnet",
"file:///autoinst.json",
"file:///autoinst.xml",
Expand Down Expand Up @@ -75,14 +81,14 @@ impl ConfigAutoLoader {
/// Loads configuration files specified by the user.
async fn load_user_config(&self, loader: ConfigLoader, urls: &[String]) -> anyhow::Result<()> {
for url in urls {
println!("Loading configuration from {url}");
tracing::info!("Loading configuration from {url}");
while let Err(error) = loader.load(url).await {
eprintln!("Could not load configuration from {url}: {error}");
tracing::error!("Could not load configuration from {url}: {error}");
if !self.should_retry(url, &error.to_string()).await? {
return Err(error);
}
}
println!("Configuration loaded from {url}");
tracing::info!("Configuration loaded from {url}");
}
Ok(())
}
Expand All @@ -92,10 +98,10 @@ impl ConfigAutoLoader {
for url in PREDEFINED_LOCATIONS {
match loader.load(url).await {
Ok(()) => {
println!("Configuration loaded from {url}");
tracing::info!("Configuration loaded from {url}");
return Ok(());
}
Err(_) => println!("Could not load the configuration from {url}"),
Err(_) => tracing::info!("No config loaded from {url}"),
}
}
Err(anyhow!("No configuration was found"))
Expand Down
21 changes: 16 additions & 5 deletions rust/agama-autoinstall/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ use agama_lib::{auth::AuthToken, http::BaseHTTPClient, manager::ManagerHTTPClien
use agama_utils::{
api::{status::Stage, FinishMethod},
kernel_cmdline::KernelCmdline,
logging::init_logging,
};
use anyhow::anyhow;
use anyhow::Context;
use tokio::time::sleep;

const API_URL: &str = "http://localhost/api";
Expand All @@ -43,6 +45,8 @@ pub fn insecure_from(cmdline: &KernelCmdline, key: &str) -> bool {

#[tokio::main]
async fn main() -> anyhow::Result<()> {
init_logging().context("Could not initialize the logger")?;

let args = KernelCmdline::parse()?;
let http = build_base_client()?;
let manager_client = ManagerHTTPClient::new(http.clone());
Expand All @@ -51,27 +55,33 @@ async fn main() -> anyhow::Result<()> {
let script_insecure = insecure_from(&args, "inst.script_insecure");
let mut runner = ScriptsRunner::new(http.clone(), "/run/agama/inst-scripts", script_insecure);
for url in scripts {
println!("Running script from {}", &url);
tracing::info!("Running script from {}", &url);
if let Err(error) = runner.run(&url).await {
eprintln!("Error running the script from {url}: {}", error);
tracing::error!("Error running the script from {url}: {}", error);
}
}

let auto_insecure = insecure_from(&args, "inst.auto_insecure");
let loader = ConfigAutoLoader::new(http.clone(), auto_insecure)?;
let urls = args.get("inst.auto");
if let Err(error) = loader.load(&urls).await {
eprintln!("Skipping the auto-installation: {error}");
if urls.is_empty() {
tracing::info!("No configuration found in the predefined locations");
return Ok(());
}

tracing::error!("Skipping the auto-installation: {error}");
return Ok(());
}

if let Some(should_install) = args.get("inst.install").first() {
if should_install == "0" {
println!("Skipping the auto-installation on user's request (inst.install=0)");
tracing::info!("Not starting the auto-installation on user's request (inst.install=0)");
return Ok(());
}
}

tracing::info!("Waiting for the installer to get ready");
// wait till config is properly set.
loop {
sleep(Duration::from_secs(1)).await;
Expand All @@ -81,6 +91,7 @@ async fn main() -> anyhow::Result<()> {
}
}

tracing::info!("Starting the auto-installation");
manager_client.install().await?;

// wait till install is done.
Expand All @@ -91,7 +102,7 @@ async fn main() -> anyhow::Result<()> {
break;
}
if status.stage == Stage::Failed {
eprintln!("Installation failed");
tracing::error!("Installation failed");
exit(1);
}
}
Expand Down
2 changes: 1 addition & 1 deletion rust/agama-lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ tempfile = "3.13.0"
thiserror = "2.0.12"
tokio = { version = "1.40.0", features = ["macros", "rt-multi-thread"] }
tokio-stream = "0.1.16"
tracing = "0.1.40"
tracing = "0.1.44"
url = { version = "2.5.2", features = ["serde"] }
utoipa = { version = "5.2.0", features = ["url"] }
zbus = { version = "5", default-features = false, features = ["tokio"] }
Expand Down
3 changes: 0 additions & 3 deletions rust/agama-proxy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,9 @@ agama-utils = { version = "0.1.0", path = "../agama-utils" }
anyhow = "1.0.100"
async-trait = "0.1.89"
gettext-rs = "0.7.7"
libsystemd = "0.7.2"
strum = "0.27.2"
thiserror = "2.0.18"
tracing = "0.1.44"
tracing-journald = "0.3.2"
tracing-subscriber = { version = "0.3.22", features = ["env-filter"] }

[[bin]]
name = "agama-proxy-setup"
Expand Down
31 changes: 1 addition & 30 deletions rust/agama-proxy/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,37 +19,8 @@
// find current contact information at www.suse.com.

use agama_proxy::model::ProxyConfig;
use agama_utils::logging::init_logging;
use anyhow::Context;
use libsystemd::logging;
use tracing::level_filters::LevelFilter;
use tracing_subscriber::{prelude::*, EnvFilter};

/// Initializes the logging mechanism.
///
/// It is based on [Tracing](https://github.com/tokio-rs/tracing), part of the Tokio ecosystem.
pub fn init_logging() -> anyhow::Result<()> {
let filter = EnvFilter::builder()
.with_default_directive(LevelFilter::INFO.into())
.with_env_var("AGAMA_LOG")
.from_env_lossy();

if logging::connected_to_journal() {
let journald = tracing_journald::layer().context("could not connect to journald")?;
tracing_subscriber::registry()
.with(filter)
.with(journald)
.init();
} else {
let subscriber = tracing_subscriber::fmt()
.with_env_filter(filter)
.with_file(true)
.with_line_number(true)
.compact()
.finish();
tracing::subscriber::set_global_default(subscriber)?;
}
Ok(())
}

fn main() -> Result<(), Box<dyn std::error::Error>> {
init_logging().context("Could not initialize the logger")?;
Expand Down
3 changes: 0 additions & 3 deletions rust/agama-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ tower-http = { version = "0.6.2", features = [
"trace",
"set-header",
] }
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
tracing-journald = "0.3.0"
tracing = "0.1.40"
clap = { version = "4.5.19", features = ["derive", "wrap_help"] }
tower = { version = "0.5.2", features = ["util"] }
Expand All @@ -51,7 +49,6 @@ tokio-openssl = "0.6.5"
futures-util = { version = "0.3.30", default-features = false, features = [
"alloc",
] }
libsystemd = "0.7.0"
gethostname = "1.0.0"
tokio-util = "0.7.12"
url = "2.5.2"
Expand Down
3 changes: 1 addition & 2 deletions rust/agama-server/src/agama-web-server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,9 @@ use agama_l10n::helpers as l10n_helpers;
use agama_lib::{auth::AuthToken, connection_to};
use agama_server::{
cert::Certificate,
logs::init_logging,
web::{self},
};
use agama_utils::api::event::Receiver;
use agama_utils::{api::event::Receiver, logging::init_logging};
use anyhow::Context;
use axum::{
extract::Request as AxumRequest,
Expand Down
1 change: 0 additions & 1 deletion rust/agama-server/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
pub mod cert;
pub mod dbus;
pub mod error;
pub mod logs;
pub mod profile;
pub mod web;
pub use web::service;
Expand Down
6 changes: 5 additions & 1 deletion rust/agama-utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ edition.workspace = true
[dependencies]
agama-locale-data = { path = "../agama-locale-data" }
agama-transfer = { path = "../agama-transfer" }
anyhow = { version = "1.0.98" }
async-trait = "0.1.89"
camino = "1.2.1"
serde = { version = "1.0.228", features = ["derive"] }
Expand All @@ -20,7 +21,10 @@ zbus = "5.7.1"
zvariant = "5.5.2"
gettext-rs = { version = "0.7.2", features = ["gettext-system"] }
regex = "1.12.2"
tracing = "0.1.41"
libsystemd = "0.7.2"
tracing = "0.1.44"
tracing-journald = "0.3.2"
tracing-subscriber = { version = "0.3.22", features = ["env-filter"] }
serde_yaml = "0.9.34"
uuid = { version = "1.10.0", features = ["v4"] }
cidr = { version = "0.3.1", features = ["serde"] }
Expand Down
2 changes: 1 addition & 1 deletion rust/agama-utils/src/kernel_cmdline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ impl KernelCmdline {
/// * `content`: file containing the kernel's cmdline arguments.
pub fn parse_file<P: std::fmt::Display + AsRef<Path>>(file: P) -> std::io::Result<Self> {
let content = std::fs::read_to_string(&file)
.inspect_err(|e| tracing::warn!("Could not read cmdline args file {e}",))?;
.inspect_err(|e| tracing::warn!("Could not read cmdline args file: {e}",))?;
Ok(Self::parse_str(&content))
}

Expand Down
1 change: 1 addition & 0 deletions rust/agama-utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ pub mod dbus;
pub mod issue;
pub mod kernel_cmdline;
pub mod licenses;
pub mod logging;
pub mod openapi;
pub mod products;
pub mod progress;
Expand Down
File renamed without changes.
8 changes: 8 additions & 0 deletions rust/package/agama.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
-------------------------------------------------------------------
Tue Apr 7 16:55:22 UTC 2026 - Ladislav Slezák <lslezak@suse.com>

- Automatically try loading the autoinstallation profile from the
root of the installation medium (jsc#PED-16010)
- Use journal logging with more details in the autoinstallation
CLI tool (log to stdout when running manually)

-------------------------------------------------------------------
Tue Mar 24 13:01:38 UTC 2026 - Ladislav Slezák <lslezak@suse.com>

Expand Down
Loading