Skip to content

Commit

Permalink
fix: do not freeze when downloading the logs (#1693)
Browse files Browse the repository at this point in the history
## Problem

If you try to download the logs using the web UI, `agama-web-server`
gets unresponsive.

## Solution

- Use `tokio::process::Command` to download the logs.
- Rename the endpoint to reflect the file format.

## To do

- The UI is not properly adapted yet but @dgdavid is working on it.
  • Loading branch information
imobachgs authored Oct 23, 2024
2 parents eeaf714 + fa11ed8 commit b2eafff
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
6 changes: 4 additions & 2 deletions rust/agama-server/src/manager/web.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ use axum::{
};
use rand::distributions::{Alphanumeric, DistString};
use serde::Serialize;
use std::{pin::Pin, process::Command};
use std::pin::Pin;
use tokio::process::Command;
use tokio_stream::{Stream, StreamExt};
use tower_http::services::ServeFile;

Expand Down Expand Up @@ -115,7 +116,7 @@ pub async fn manager_service(dbus: zbus::Connection) -> Result<Router, ServiceEr
.route("/install", post(install_action))
.route("/finish", post(finish_action))
.route("/installer", get(installer_status))
.route("/logs", get(download_logs))
.route("/logs.tar.gz", get(download_logs))
.merge(status_router)
.merge(progress_router)
.with_state(state))
Expand Down Expand Up @@ -252,6 +253,7 @@ async fn generate_logs() -> Result<String, Error> {
Command::new("agama")
.args(["logs", "store", "-d", path.as_str()])
.status()
.await
.map_err(|e| ServiceError::CannotGenerateLogs(e.to_string()))?;

let full_path = format!("{path}.tar.gz");
Expand Down
5 changes: 5 additions & 0 deletions rust/package/agama.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
-------------------------------------------------------------------
Wed Oct 23 15:25:36 UTC 2024 - Imobach Gonzalez Sosa <[email protected]>

- Fix the action to download the logs (gh#agama-project/agama#1693).

-------------------------------------------------------------------
Tue Oct 22 09:46:41 UTC 2024 - Imobach Gonzalez Sosa <[email protected]>

Expand Down
5 changes: 5 additions & 0 deletions web/package/agama-web-ui.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
-------------------------------------------------------------------
Wed Oct 23 15:26:29 UTC 2024 - Imobach Gonzalez Sosa <[email protected]>

- Adapt the URL to fetch the logs (gh#agama-project/agama#1693).

-------------------------------------------------------------------
Fri Oct 11 09:46:02 UTC 2024 - Imobach Gonzalez Sosa <[email protected]>

Expand Down
2 changes: 1 addition & 1 deletion web/src/api/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ const finishInstallation = () => post("/api/manager/finish");
/**
* Returns the binary content of the YaST logs file.
*/
const fetchLogs = () => get("/api/manager/logs");
const fetchLogs = () => get("/api/manager/logs.tar.gz");

export { startProbing, startInstallation, finishInstallation, fetchLogs };

0 comments on commit b2eafff

Please sign in to comment.