Skip to content

Commit

Permalink
Merge pull request #596 from flavio/reduce-memory-usage
Browse files Browse the repository at this point in the history
refactor: reduce memory usage
  • Loading branch information
flavio authored Dec 14, 2023
2 parents c37672f + ad951ab commit fee9dd7
Show file tree
Hide file tree
Showing 13 changed files with 1,369 additions and 933 deletions.
358 changes: 227 additions & 131 deletions Cargo.lock

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@ opentelemetry = { version = "0.21", default-features = false, features = [
] }
opentelemetry_sdk = { version = "0.21", features = ["rt-tokio"] }
procfs = "0.16"
policy-evaluator = { git = "https://github.com/kubewarden/policy-evaluator", tag = "v0.12.2" }
policy-evaluator = { git = "https://github.com/kubewarden/policy-evaluator", tag = "v0.13.0" }
rayon = "1.8"
serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] }
serde_yaml = "0.9.27"
sha2 = "0.10"
thiserror = "1.0"
tokio = { version = "^1", features = ["full"] }
tracing = "0.1"
tracing-futures = "0.2"
Expand All @@ -43,8 +45,10 @@ warp = { version = "0.3.6", default_features = false, features = [
"tls",
] }
semver = { version = "1.0.20", features = ["serde"] }
mockall_double = "0.3"

[dev-dependencies]
mockall = "0.12"
rstest = "0.18"
tempfile = "3.8.1"
reqwest = { version = "0.11", default_features = false, features = [
Expand Down
23 changes: 23 additions & 0 deletions e2e-tests/test_data/policies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,26 @@ raw-mutation-wasi:
- "banana"
- "carrot"
defaultResource: "hay"

apparmor:
url: ghcr.io/kubewarden/tests/apparmor-psp:v0.1.13
allowedToMutate: false
settings:
allowed_profiles:
- runtime/default

psp-user-group:
url: ghcr.io/kubewarden/tests/user-group-psp:v0.4.9
allowedToMutate: true
settings:
run_as_user:
rule: MustRunAs
ranges:
- min: 1000
max: 2000
run_as_group:
rule: RunAsAny
overwrite: false
supplemental_groups:
rule: RunAsAny
overwrite: false
3 changes: 2 additions & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use anyhow::{anyhow, Result};

use clap::ArgMatches;
use lazy_static::lazy_static;
use policy_evaluator::policy_evaluator::PolicySettings;
use policy_evaluator::policy_fetcher::sources::{read_sources_file, Sources};
use policy_evaluator::policy_fetcher::verify::config::{
read_verification_file, LatestVerificationConfig, VerificationConfigV1,
Expand Down Expand Up @@ -231,7 +232,7 @@ pub struct Policy {
}

impl Policy {
pub fn settings_to_json(&self) -> Result<Option<serde_json::Map<String, serde_json::Value>>> {
pub fn settings_to_json(&self) -> Result<Option<PolicySettings>> {
match self.settings.as_ref() {
None => Ok(None),
Some(settings) => {
Expand Down
5 changes: 2 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ mod communication;
mod metrics;
mod policy_downloader;
mod server;
mod worker;
mod worker_pool;
mod workers;

pub mod admission_review;
pub mod config;
Expand All @@ -26,7 +25,7 @@ use tracing_subscriber::{fmt, EnvFilter};
use communication::{EvalRequest, WorkerPoolBootRequest};
use config::Config;
use policy_downloader::Downloader;
use worker_pool::WorkerPool;
use workers::pool::WorkerPool;

lazy_static! {
static ref TRACE_SYSTEM_INITIALIZED: RwLock<bool> = RwLock::new(false);
Expand Down
Loading

0 comments on commit fee9dd7

Please sign in to comment.