Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(dgw): add recording_storage_is_writeable in heartbeat #835

Merged
merged 1 commit into from
May 2, 2024
Merged
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
15 changes: 15 additions & 0 deletions devolutions-gateway/src/api/heartbeat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ pub(crate) struct Heartbeat {
version: &'static str,
/// Number of running sessions
running_session_count: usize,
/// Whether the recording storage is writteable or not.
recording_storage_is_writteable: bool,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: writeable

/// The total space of the disk used to store recordings, in bytes.
#[serde(skip_serializing_if = "Option::is_none")]
recording_storage_total_space: Option<u64>,
Expand Down Expand Up @@ -54,6 +56,18 @@ pub(super) async fn get_heartbeat(
.await
.map_err(HttpError::internal().err())?;

let recording_storage_is_writteable = {
let probe_file = conf.recording_path.join("probe");

let is_ok = std::fs::write(&probe_file, ".").is_ok();

if is_ok {
let _ = std::fs::remove_file(probe_file);
}

is_ok
};

let (recording_storage_total_space, recording_storage_available_space) = if sysinfo::IS_SUPPORTED_SYSTEM {
trace!("System is supporting listing storage disks");

Expand Down Expand Up @@ -98,6 +112,7 @@ pub(super) async fn get_heartbeat(
hostname: conf.hostname.clone(),
version: env!("CARGO_PKG_VERSION"),
running_session_count,
recording_storage_is_writteable,
recording_storage_total_space,
recording_storage_available_space,
}))
Expand Down