Skip to content

Commit 1831290

Browse files
fix(procmgr): satisfy Windows CI rustfmt and clippy checks
Apply rustfmt to the manager split and remove Windows-only dead code that failed clippy with -D warnings.
1 parent e7445b4 commit 1831290

7 files changed

Lines changed: 31 additions & 30 deletions

File tree

pkg/procmgr/rust/src/config.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// This product includes software developed at Datadog (https://www.datadoghq.com/).
44
// Copyright 2026-present Datadog, Inc.
55

6-
76
use crate::platform;
87
use anyhow::{Context, Result};
98
use log::{debug, info, warn};

pkg/procmgr/rust/src/manager/mod.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,16 @@ mod supervisor;
1111

1212
use supervisor::RuntimeHandles;
1313

14-
use crate::config::ProcessDefinition;
1514
use crate::process::ManagedProcess;
1615
use anyhow::Result;
1716
use log::warn;
18-
use std::sync::Arc;
1917
use tokio::sync::mpsc;
2018
use tonic::Status;
2119

2220
pub use process_manager::ProcessManager;
2321
pub use supervisor::Supervisor;
2422

25-
#[cfg(test)]
23+
#[cfg(all(test, unix))]
2624
pub(crate) use supervisor::spawn_command_loop_for_tests;
2725

2826
pub(crate) struct ExitEvent {
@@ -125,10 +123,14 @@ fn spawn_watcher(proc: &mut ManagedProcess, tx: mpsc::Sender<ExitEvent>) {
125123
#[cfg(test)]
126124
mod tests {
127125
use super::*;
128-
use crate::config::{ConfigLoader, MutableConfigLoader, ProcessConfig, RestartPolicy, StaticConfigLoader};
126+
use crate::config::{
127+
ConfigLoader, MutableConfigLoader, ProcessConfig, ProcessDefinition, RestartPolicy,
128+
StaticConfigLoader,
129+
};
129130
use crate::state::ProcessState;
130131
use crate::test_helpers;
131132
use crate::uuid_gen::{SequentialUuidGenerator, UuidGenerator, V4UuidGenerator};
133+
use std::sync::Arc;
132134

133135
fn loader(defs: Vec<ProcessDefinition>) -> Arc<dyn ConfigLoader> {
134136
Arc::new(StaticConfigLoader::new(defs))
@@ -138,8 +140,7 @@ mod tests {
138140
Arc::new(V4UuidGenerator)
139141
}
140142

141-
fn test_runtime_handles(
142-
) -> (
143+
fn test_runtime_handles() -> (
143144
RuntimeHandles,
144145
mpsc::Receiver<ExitEvent>,
145146
mpsc::Receiver<PendingRestart>,
@@ -255,8 +256,7 @@ mod tests {
255256
"reload should start the process with fresh counters"
256257
);
257258

258-
mgr.complete_restart(stale_pending, &handles)
259-
.await;
259+
mgr.complete_restart(stale_pending, &handles).await;
260260
let pid = mgr.processes().await[0].pid().unwrap();
261261
test_helpers::cleanup_process(pid);
262262
Ok(())
@@ -310,8 +310,7 @@ mod tests {
310310
mgr.handle_reload_config(&handles).await?;
311311
assert!(!mgr.processes().await[0].is_running());
312312

313-
mgr.complete_restart(stale_pending, &handles)
314-
.await;
313+
mgr.complete_restart(stale_pending, &handles).await;
315314
assert!(
316315
!mgr.processes().await[0].is_running(),
317316
"config reload should discard pending crash retries for failed auto_start=false processes"

pkg/procmgr/rust/src/manager/process_manager.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,7 @@ impl ProcessManager {
7474
self.config_loader.location()
7575
}
7676

77-
pub(in crate::manager) async fn handle_exit(
78-
&self,
79-
event: ExitEvent,
80-
handles: &RuntimeHandles,
81-
) {
77+
pub(in crate::manager) async fn handle_exit(&self, event: ExitEvent, handles: &RuntimeHandles) {
8278
let mut procs = self.processes.write().await;
8379
let Some(proc) = procs.iter_mut().find(|p| p.name() == event.name) else {
8480
warn!("exit event for unknown process '{}'", event.name);

pkg/procmgr/rust/src/manager/reload.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1+
use super::supervisor::RuntimeHandles;
12
use super::{ProcessManager, queue_restart, try_spawn_and_watch};
23
use crate::command::ReloadResult;
34
use crate::config::ProcessDefinition;
45
use crate::process::{ManagedProcess, ProcessOrigin};
56
use crate::state::ProcessState;
67
use log::{info, warn};
7-
use super::supervisor::RuntimeHandles;
88
use tonic::Status;
99

1010
pub(super) struct ReloadConfigApplyResult {
@@ -133,8 +133,7 @@ impl ProcessManager {
133133
.apply_reloaded_config_processes(new_configs, handles)
134134
.await;
135135

136-
self.reconcile_processes_after_reload(&apply, handles)
137-
.await;
136+
self.reconcile_processes_after_reload(&apply, handles).await;
138137

139138
self.update_startup_order().await;
140139
Ok(ReloadResult {

pkg/procmgr/rust/src/manager/supervisor.rs

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ pub(crate) struct RuntimeHandles {
1616
}
1717

1818
impl RuntimeHandles {
19-
pub(super) fn new() -> (Self, mpsc::Receiver<ExitEvent>, mpsc::Receiver<PendingRestart>) {
19+
pub(super) fn new() -> (
20+
Self,
21+
mpsc::Receiver<ExitEvent>,
22+
mpsc::Receiver<PendingRestart>,
23+
) {
2024
let (exit_tx, exit_rx) = mpsc::channel(256);
2125
let (restart_tx, restart_rx) = mpsc::channel(256);
2226
(
@@ -40,13 +44,23 @@ impl RuntimeHandles {
4044

4145
async fn handle_command(manager: &ProcessManager, handles: &RuntimeHandles, cmd: Command) {
4246
match cmd {
43-
Command::Create { name, config, reply } => {
47+
Command::Create {
48+
name,
49+
config,
50+
reply,
51+
} => {
4452
let _ = reply.send(manager.handle_create(name, *config, handles).await);
4553
}
46-
Command::Start { name_or_uuid, reply } => {
54+
Command::Start {
55+
name_or_uuid,
56+
reply,
57+
} => {
4758
let _ = reply.send(manager.handle_start(&name_or_uuid, handles).await);
4859
}
49-
Command::Stop { name_or_uuid, reply } => {
60+
Command::Stop {
61+
name_or_uuid,
62+
reply,
63+
} => {
5064
let _ = reply.send(manager.handle_stop(&name_or_uuid).await);
5165
}
5266
Command::ReloadConfig { reply } => {
@@ -129,7 +143,7 @@ impl Supervisor {
129143
}
130144
}
131145

132-
#[cfg(test)]
146+
#[cfg(all(test, unix))]
133147
pub(crate) fn spawn_command_loop_for_tests(
134148
manager: ProcessManager,
135149
mut cmd_rx: mpsc::Receiver<Command>,

pkg/procmgr/rust/src/process.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -211,11 +211,6 @@ impl ManagedProcess {
211211
self.user_profile = Some(profile);
212212
}
213213

214-
#[cfg(windows)]
215-
pub(crate) fn clear_windows_job_object(&mut self) {
216-
self.job_object = None;
217-
}
218-
219214
#[cfg(windows)]
220215
pub(crate) fn clear_windows_spawn_resources(&mut self) {
221216
self.job_object = None;

pkg/procmgr/rust/src/transport/named_pipe.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ use windows_sys::Win32::Foundation::HANDLE;
1919

2020
use crate::platform::{create_pipe_server, pipe_client_may_mutate};
2121

22-
const DEFAULT_PIPE_PATH: &str = r"\\.\pipe\datadog-procmgrd";
2322
const DEFAULT_PIPE_INSTANCES: usize = 4;
2423

2524
pub fn ipc_path() -> PathBuf {

0 commit comments

Comments
 (0)