Skip to content
Draft
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
3 changes: 3 additions & 0 deletions agent/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use std::collections::HashMap;
use uuid::Uuid;

#[derive(Debug, Deserialize, Clone)]
#[allow(dead_code)]
pub struct AssignedVolume {
pub id: String,
pub name: String,
Expand Down Expand Up @@ -57,6 +58,7 @@ pub struct ContainerStatus {
}

#[derive(Debug, Deserialize)]
#[allow(dead_code)]
pub struct AssignedWorkload {
pub id: String,
pub name: String,
Expand Down Expand Up @@ -95,6 +97,7 @@ impl ApiClient {
self
}

#[allow(clippy::too_many_arguments)]
pub async fn register(
&self,
token: &str,
Expand Down
16 changes: 2 additions & 14 deletions agent/src/docker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pub struct PortMapping {
}

#[derive(Debug, Clone)]
#[allow(dead_code)]
pub struct WorkloadSpec {
pub workload_id: String,
pub name: String,
Expand Down Expand Up @@ -130,22 +131,9 @@ impl DockerManager {
Ok(container.id)
}

pub async fn stop_container(&self, container_id: &str) -> Result<()> {
self.docker
.stop_container(container_id, None)
.await
.context("Failed to stop container")?;

self.docker
.remove_container(container_id, None)
.await
.context("Failed to remove container")?;

info!(container_id = %container_id, "Container stopped and removed");
Ok(())
}
}

#[allow(clippy::type_complexity)]
fn build_port_config(
ports: Option<&[PortMapping]>,
) -> (
Expand Down
18 changes: 2 additions & 16 deletions agent/src/pki.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,17 @@ const CERT_FILE: &str = "/var/lib/csf-daemon/agent.crt";
const CA_FILE: &str = "/var/lib/csf-daemon/ca.crt";

pub struct AgentPki {
key_pem: String,
csr_pem: String,
}

impl AgentPki {
pub fn load_or_generate() -> Result<Self> {
if Path::new(KEY_FILE).exists() && Path::new(CSR_FILE).exists() {
let key_pem = std::fs::read_to_string(KEY_FILE)
.context("Failed to read agent key")?;
let csr_pem = std::fs::read_to_string(CSR_FILE)
.context("Failed to read agent CSR")?;

tracing::info!("PKI: loaded existing keypair and CSR");
return Ok(Self { key_pem, csr_pem });
return Ok(Self { csr_pem });
}

Self::generate()
Expand All @@ -47,17 +44,13 @@ impl AgentPki {

tracing::info!("PKI: generated new ECDSA keypair and CSR");

Ok(Self { key_pem, csr_pem })
Ok(Self { csr_pem })
}

pub fn csr_pem(&self) -> &str {
&self.csr_pem
}

pub fn key_pem(&self) -> &str {
&self.key_pem
}

pub fn has_certificate() -> bool {
Path::new(CERT_FILE).exists() && Path::new(CA_FILE).exists()
}
Expand All @@ -73,13 +66,6 @@ impl AgentPki {
std::fs::read_to_string(CERT_FILE).context("Failed to read agent certificate")
}

pub fn load_ca_pem() -> Result<String> {
std::fs::read_to_string(CA_FILE).context("Failed to read CA certificate")
}

pub fn load_key_pem() -> Result<String> {
std::fs::read_to_string(KEY_FILE).context("Failed to read agent key")
}
}

#[cfg(unix)]
Expand Down
18 changes: 0 additions & 18 deletions agent/src/rbd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,24 +67,6 @@ pub async fn mount(device: &str, mount_point: &str) -> Result<()> {
Ok(())
}

pub async fn umount(mount_point: &str) -> Result<()> {
info!(mount_point = %mount_point, "Unmounting device");

let output = Command::new("umount")
.arg(mount_point)
.output()
.await
.context("Failed to execute umount")?;

if !output.status.success() {
let stderr = String::from_utf8_lossy(&output.stderr);
warn!(mount_point = %mount_point, error = %stderr, "umount failed");
return Err(anyhow!("umount failed: {}", stderr));
}

info!(mount_point = %mount_point, "Device unmounted");
Ok(())
}

pub fn mount_point_for(volume_id: &str) -> String {
format!("/mnt/csf-volumes/{}", volume_id)
Expand Down
2 changes: 0 additions & 2 deletions control-plane/api-gateway/src/routes/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,6 @@ pub async fn delete_pending_agent(
}
}

/// Create token (Admin only) - DEPRECATED
#[deprecated(note = "Use pre_register_agent instead")]
#[utoipa::path(
post,
path = "/registry/admin/tokens",
Expand Down
12 changes: 0 additions & 12 deletions control-plane/failover-controller/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,6 @@ pub fn init() {
});
}

pub fn record_request(method: &str, path: &str, status: u16, duration_secs: f64) {
if let Some(counter) = HTTP_REQUESTS_TOTAL.get() {
counter
.with_label_values(&[method, path, &status.to_string()])
.inc();
}
if let Some(histogram) = HTTP_REQUEST_DURATION_SECONDS.get() {
histogram
.with_label_values(&[method, path])
.observe(duration_secs);
}
}

pub async fn metrics_handler() -> impl IntoResponse {
let encoder = TextEncoder::new();
Expand Down
1 change: 1 addition & 0 deletions control-plane/registry/src/db/agents.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use sea_orm::{
};
use uuid::Uuid;

#[allow(clippy::too_many_arguments)]
pub async fn create(
db: &DatabaseConnection,
id: Uuid,
Expand Down
13 changes: 0 additions & 13 deletions control-plane/registry/src/db/certificates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,6 @@ pub async fn get_active_certificate(
.await?)
}

pub async fn deactivate_certificates(db: &DatabaseConnection, agent_id: Uuid) -> Result<u64> {
let result = agent_certificates::Entity::update_many()
.col_expr(
agent_certificates::Column::IsActive,
sea_orm::sea_query::Expr::value(false),
)
.filter(agent_certificates::Column::AgentId.eq(agent_id))
.filter(agent_certificates::Column::IsActive.eq(true))
.exec(db)
.await?;

Ok(result.rows_affected)
}

pub async fn revoke_certificate(
db: &DatabaseConnection,
Expand Down
1 change: 1 addition & 0 deletions control-plane/registry/src/db/tokens.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use sea_orm::{
};
use uuid::Uuid;

#[allow(clippy::too_many_arguments)]
pub async fn create(
db: &DatabaseConnection,
agent_id: Uuid,
Expand Down
12 changes: 0 additions & 12 deletions control-plane/registry/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,6 @@ pub fn init() {
});
}

pub fn record_request(method: &str, path: &str, status: u16, duration_secs: f64) {
if let Some(counter) = HTTP_REQUESTS_TOTAL.get() {
counter
.with_label_values(&[method, path, &status.to_string()])
.inc();
}
if let Some(histogram) = HTTP_REQUEST_DURATION_SECONDS.get() {
histogram
.with_label_values(&[method, path])
.observe(duration_secs);
}
}

pub async fn metrics_handler() -> impl IntoResponse {
let encoder = TextEncoder::new();
Expand Down
1 change: 1 addition & 0 deletions control-plane/scheduler/src/db/workloads.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ pub async fn create(
assigned_agent_id: Set(None),
container_id: Set(None),
created_by: Set(None),
organization_id: Set(None),
created_at: Set(Utc::now().naive_utc()),
updated_at: Set(None),
};
Expand Down
1 change: 1 addition & 0 deletions control-plane/sdn-controller/src/db/networks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pub async fn create_network(
cidr: Set(req.cidr),
overlay_type: Set(req.overlay_type),
status: Set("active".to_string()),
organization_id: Set(None),
created_at: Set(Utc::now().naive_utc()),
updated_at: Set(None),
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ enum Organization {
}

#[derive(DeriveIden)]
#[allow(clippy::enum_variant_names)]
enum Role {
Table,
Id,
Expand Down
7 changes: 1 addition & 6 deletions control-plane/shared/shared/src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,6 @@ pub async fn establish_connection() -> Result<DbConn, DbErr> {

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn test_db_url_required() {
// This would panic if DATABASE_URL is not set
// In real tests, you'd mock the environment
}
fn test_db_url_required() {}
}
1 change: 0 additions & 1 deletion control-plane/volume-manager/src/ceph/core/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ pub mod error;

pub use client::CephClient;
pub use config::CephConfig;
pub use error::{CephError, Result};
2 changes: 1 addition & 1 deletion control-plane/volume-manager/src/ceph/ops/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
pub mod init;

pub use init::{create_postgres_volumes, init_ceph, CephManager};
pub use init::{init_ceph, CephManager};
1 change: 1 addition & 0 deletions control-plane/volume-manager/src/db/volumes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ pub async fn create(
attached_to_agent: Set(None),
attached_to_workload: Set(None),
mapped_device: Set(None),
organization_id: Set(None),
created_at: Set(Utc::now().naive_utc()),
updated_at: Set(None),
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ impl LeaderElection {
}

/// Wartet auf Leadership Changes (Watch)
pub async fn watch_leadership<F>(&self, callback: F) -> Result<(), EtcdError>
pub async fn watch_leadership<F>(&self, _callback: F) -> Result<(), EtcdError>
where
F: FnMut(Option<String>) + Send + 'static,
{
Expand Down
2 changes: 1 addition & 1 deletion control-plane/volume-manager/src/etcd/ha/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
pub mod health;
pub mod leader_election;

pub use health::{HealthChecker, NodeHealthStatus};
pub use health::HealthChecker;
pub use leader_election::LeaderElection;
4 changes: 2 additions & 2 deletions control-plane/volume-manager/src/etcd/sync/watcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ impl StateWatcher {
}

/// Beobachtet einen Key-Prefix für Änderungen
pub async fn watch_prefix<F>(&self, prefix: &str, callback: F) -> Result<(), EtcdError>
pub async fn watch_prefix<F>(&self, prefix: &str, _callback: F) -> Result<(), EtcdError>
where
F: FnMut(WatchEvent) + Send + 'static,
{
Expand All @@ -31,7 +31,7 @@ impl StateWatcher {
}

/// Beobachtet einen spezifischen Key
pub async fn watch_key<F>(&self, key: &str, callback: F) -> Result<(), EtcdError>
pub async fn watch_key<F>(&self, key: &str, _callback: F) -> Result<(), EtcdError>
where
F: FnMut(WatchEvent) + Send + 'static,
{
Expand Down
2 changes: 0 additions & 2 deletions control-plane/volume-manager/src/patroni/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,3 @@ pub mod client;
pub mod monitor;
pub mod types;

pub use client::PatroniClient;
pub use monitor::PatroniMonitor;
Loading