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
23 changes: 5 additions & 18 deletions rust/agama-lib/src/profile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -38,7 +33,7 @@ pub struct AutoyastProfileImporter {
}

impl AutoyastProfileImporter {
pub fn read(url: &Url) -> anyhow::Result<Self> {
pub async fn read(url: &Url) -> anyhow::Result<Self> {
let path = url.path();
if !path.ends_with(".xml") && !path.ends_with(".erb") && !path.ends_with('/') {
let msg = format!("Unsupported AutoYaST format at {}", url);
Expand All @@ -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);
Expand All @@ -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<P: AsRef<Path>>(&self, path: P) -> anyhow::Result<()> {
let mut file = File::create(path)?;
self.write(&mut file)
}
}

use serde::{Deserialize, Serialize};
Expand Down
2 changes: 1 addition & 1 deletion rust/agama-server/src/profile/web.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
7 changes: 7 additions & 0 deletions rust/package/agama.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Fri Apr 11 06:53:04 UTC 2025 - Imobach Gonzalez Sosa <igonzalezsosa@suse.com>

- 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 <jreidinger@suse.com>

Expand Down