diff --git a/rust/agama-lib/src/profile.rs b/rust/agama-lib/src/profile.rs index bae6db9e8c..203a1adc5d 100644 --- a/rust/agama-lib/src/profile.rs +++ b/rust/agama-lib/src/profile.rs @@ -23,12 +23,7 @@ use anyhow::Context; use jsonschema::JSONSchema; use log::info; use serde_json; -use std::{ - fs::{self, File}, - io::Write, - path::Path, - process::Command, -}; +use std::{fs, io::Write, path::Path, process::Command}; use tempfile::{tempdir, TempDir}; use url::Url; @@ -38,7 +33,7 @@ pub struct AutoyastProfileImporter { } impl AutoyastProfileImporter { - pub fn read(url: &Url) -> anyhow::Result { + pub async fn read(url: &Url) -> anyhow::Result { let path = url.path(); if !path.ends_with(".xml") && !path.ends_with(".erb") && !path.ends_with('/') { let msg = format!("Unsupported AutoYaST format at {}", url); @@ -49,9 +44,11 @@ impl AutoyastProfileImporter { const AUTOINST_JSON: &str = "autoinst.json"; let tmp_dir = TempDir::with_prefix(TMP_DIR_PREFIX)?; - Command::new("agama-autoyast") + tokio::process::Command::new("agama-autoyast") + .env("YAST_SKIP_PROFILE_FETCH_ERROR", "1") .args([url.as_str(), &tmp_dir.path().to_string_lossy()]) .status() + .await .context("Failed to run agama-autoyast")?; let autoinst_json = tmp_dir.path().join(AUTOINST_JSON); @@ -61,16 +58,6 @@ impl AutoyastProfileImporter { ))?; Ok(Self { content }) } - - pub fn write(&self, mut file: impl Write) -> anyhow::Result<()> { - file.write_all(self.content.as_bytes())?; - Ok(()) - } - - pub fn write_file>(&self, path: P) -> anyhow::Result<()> { - let mut file = File::create(path)?; - self.write(&mut file) - } } use serde::{Deserialize, Serialize}; diff --git a/rust/agama-server/src/profile/web.rs b/rust/agama-server/src/profile/web.rs index 718a03ddae..e7c063ff44 100644 --- a/rust/agama-server/src/profile/web.rs +++ b/rust/agama-server/src/profile/web.rs @@ -224,7 +224,7 @@ async fn autoyast( } let url = Url::parse(query.url.as_ref().unwrap()).map_err(anyhow::Error::new)?; - let importer_res = AutoyastProfileImporter::read(&url); + let importer_res = AutoyastProfileImporter::read(&url).await; match importer_res { Ok(importer) => Ok(importer.content), Err(error) => { diff --git a/rust/package/agama.changes b/rust/package/agama.changes index 2243e5c12b..ba1603770f 100644 --- a/rust/package/agama.changes +++ b/rust/package/agama.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Fri Apr 11 06:53:04 UTC 2025 - Imobach Gonzalez Sosa + +- Prevent agama-web-server from getting stuck in the POST + /api/profile/autoyast calls (gh#agama-project/agama#2259). +- Temporarily disable AutoYaST profiles fetch errors. + ------------------------------------------------------------------- Thu Apr 10 20:24:06 UTC 2025 - Josef Reidinger