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
4 changes: 2 additions & 2 deletions .github/workflows/core-build-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ jobs:
docker system prune -f

build-metrics-alpine:
runs-on : alpine-latest
runs-on : ubuntu-latest

steps:
- name: Checkout code
Expand All @@ -170,7 +170,7 @@ jobs:
cd core
chmod +x metrics-build-alpine.sh
echo "🚀 Starting CortexFlow Metrics build..."
./metrics-build-alpine.sh || { echo "❌ Metrics build failed"; exit 1; }4
./metrics-build-alpine.sh || { echo "❌ Metrics build failed"; exit 1; }
echo "✅ Metrics build completed"

- name: Cleanup artifacts
Expand Down
1 change: 1 addition & 0 deletions Examples/run-with-docker/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ services:
- OTEL_EXPORTER_OTLP_ENDPOINT=http://otel-collector:4317
- OTEL_EXPORTER_OTLP_PROTOCOL=grpc
- LIBSSL_PATH=/host/usr/lib/x86_64-linux-gnu/libssl.so.3
- DEFAULT_MAP_READING_TIME=100
volumes:
- type: bind
source: /sys/fs/bpf
Expand Down
1 change: 0 additions & 1 deletion core/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions core/common/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ pub const PIN_MAP_PATH: &str = "PIN_MAP_PATH";
/// When set, this path is used directly. When unset, the library is located
/// by searching the default system library directories.
pub const LIBSSL_PATH: &str = "LIBSSL_PATH";

pub const DEFAULT_MAP_READING_TIME : &str = "DEFAULT_MAP_READING_TIME";
3 changes: 2 additions & 1 deletion core/common/src/consumer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use crate::buffer_type::{
CpuFrequency, CpuIdle, MemAlloc, PacketLossMetrics, SchedStatRuntime, SchedStatWait,
TimeStampMetrics,
};
use crate::constants::DEFAULT_MAP_READING_TIME;
#[cfg(feature = "network-structs")]
use crate::buffer_type::{PacketLog, TcpPacketRegistry, VethLog};
#[cfg(feature = "monitoring-structs")]
Expand Down Expand Up @@ -899,6 +900,6 @@ pub async fn read_perf_buffer<T: std::borrow::BorrowMut<aya::maps::MapData>>(
}
}
}
tokio::time::sleep(std::time::Duration::from_millis(5000)).await;
tokio::time::sleep(std::time::Duration::from_millis(std::env::var(DEFAULT_MAP_READING_TIME).ok().and_then(|v| v.parse::<u64>().ok()).unwrap_or(5000))).await;
}
}
27 changes: 16 additions & 11 deletions core/common/src/map_handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ use kube::{Api, Client};
use std::net::Ipv4Addr;
use std::path::PathBuf;
use std::str::FromStr;
use std::sync::Arc;
use std::sync::Mutex;
use std::sync::{Arc, Mutex};
use tracing::warn;
use tracing::{error, info};

Expand All @@ -23,28 +22,33 @@ use tracing::{error, info};
pub struct BpfMapsData {
pub bpf_obj_names: Vec<String>,
pub bpf_obj_map: Vec<Map>,
pub bpf: Arc<Mutex<Ebpf>>,
}

#[cfg(feature = "map-handlers")]
pub fn init_bpf_maps(
bpf: Arc<Mutex<Ebpf>>,
map_names: Vec<String>,
) -> Result<BpfMapsData, anyhow::Error> {
let mut bpf_new = bpf
.lock()
.map_err(|e| anyhow::anyhow!("Cannot get value from lock. Reason: {}", e))?;

let mut maps = Vec::new(); // stores bpf_maps_objects

for name in &map_names {
let bpf_map_init = bpf_new
.take_map(&name)
.ok_or_else(|| anyhow::anyhow!("{} map not found", &name))?;
maps.push(bpf_map_init);
{
let mut bpf_new = bpf
.lock()
.map_err(|e| anyhow::anyhow!("Cannot get value from lock. Reason: {}", e))?;

for name in &map_names {
let bpf_map_init = bpf_new
.take_map(&name)
.ok_or_else(|| anyhow::anyhow!("{} map not found", &name))?;
maps.push(bpf_map_init);
}
}

Ok(BpfMapsData {
bpf_obj_names: map_names.clone(),
bpf_obj_map: maps,
bpf,
})
}

Expand All @@ -68,6 +72,7 @@ pub fn map_pinner(maps: BpfMapsData, path: &PathBuf) -> Result<BpfMapsData, Erro
let mut owned_bpf_maps_data = BpfMapsData {
bpf_obj_names: Vec::new(),
bpf_obj_map: Vec::new(),
bpf: maps.bpf,
};
// an iterator that iterates two iterators simultaneously
for (map_obj, name) in maps
Expand Down
Loading
Loading