Skip to content

Commit

Permalink
Configuration and logging improvements to logrotate_fs
Browse files Browse the repository at this point in the history
This commit involves minor tweaks to the logrotate_fs to improve logging
and the configuration of said generator. Also I include an example
config.

Signed-off-by: Brian L. Troutwine <brian.troutwine@datadoghq.com>
  • Loading branch information
blt committed Oct 29, 2024
1 parent d92f425 commit db79a58
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
17 changes: 17 additions & 0 deletions examples/lading-logrotatefs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
generator:
- file_gen:
logrotate_fs:
seed: [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53,
59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131]
concurrent_logs: 8
maximum_bytes_per_log: 100MB
total_rotations: 4
max_depth: 0
variant: "ascii"
bytes_per_second: 10MB
maximum_prebuild_cache_size_bytes: 1GB
mount_point: /tmp/logrotate

blackhole:
- tcp:
binding_addr: "0.0.0.0:8080"
8 changes: 6 additions & 2 deletions lading/src/generator/file_gen/logrotate_fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use std::{
time::Duration,
};
use tokio::task::{self, JoinError};
use tracing::{error, info};
use tracing::{debug, error, info};

mod model;

Expand Down Expand Up @@ -123,6 +123,10 @@ impl Server {
config.concurrent_logs,
);

info!(
"Creating logrotate filesystem with mount point {mount}",
mount = config.mount_point.display(),
);
// Initialize the FUSE filesystem
let fs = LogrotateFS {
state: Arc::new(Mutex::new(state)),
Expand Down Expand Up @@ -243,7 +247,7 @@ impl Filesystem for LogrotateFS {
let name_str = name.to_str().unwrap_or("");
if let Some(ino) = state.lookup(tick, parent as usize, name_str) {
if let Some(attr) = getattr_helper(&mut state, self.start_time_system, tick, ino) {
info!("lookup: returning attr for inode {}: {:?}", ino, attr);
debug!("lookup: returning attr for inode {}: {:?}", ino, attr);
reply.entry(&TTL, &attr, 0);
return;
}
Expand Down
6 changes: 5 additions & 1 deletion lading/src/generator/file_gen/logrotate_fs/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,11 @@ impl State {

for group_id in 0..num_groups {
let mut current_inode = state.root_inode;
let depth = rng.gen_range(1..=max_depth as usize);
let depth = if max_depth == 0 {
0
} else {
rng.gen_range(1..=max_depth as usize)
};

// Build the directory path
for _ in 0..depth {
Expand Down

0 comments on commit db79a58

Please sign in to comment.