Skip to content

Commit 0f0423d

Browse files
committed
Fixup host exec for collect
1 parent 33e3dc6 commit 0f0423d

13 files changed

Lines changed: 534 additions & 252 deletions

File tree

Cargo.lock

Lines changed: 306 additions & 181 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[package]
2-
name = "edera-preflight"
2+
name = "preflight"
33
version = "0.1.0"
44
edition = "2024"
55
description = "CLI to run pre-deployment checks before running workloads."
@@ -17,3 +17,5 @@ tokio = { version = "1", features = ["full"] }
1717
tokio-util = { version = "0.7" }
1818
tokio-stream = { version = "0.1", features = ["io-util", "net"] }
1919
nix = { version= "0.31", features = ["sched"] }
20+
futures = "0.3"
21+
async-trait = "0.1"

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ docker run \
1717
--env EDERA_PREFLIGHT_TARGET_DIR='/host' \
1818
--env EDERA_PREFLIGHT_SKIP_GROUPS='ScriptedChecks;SystemChecks' \
1919
--env EDERA_PREFLIGHT_SCRIPTS_DIR=/scripts \
20-
--volume /:/host \
2120
--pid host \
2221
--net host \
2322
--privileged \

hack/code/autofix.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ set -e
44
REAL_SCRIPT="$(realpath "${0}")"
55
cd "$(dirname "${REAL_SCRIPT}")/../.."
66

7-
cargo clippy --all --fix --allow-dirty --allow-staged
8-
cargo fmt --all
7+
./hack/build/cargo.sh clippy --all --fix --allow-dirty --allow-staged
8+
./hack/build/cargo.sh fmt --all

hack/debug/local.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env sh
2+
set -e
3+
4+
VER=$(date +%s)
5+
USERIMG=$(whoami)
6+
REGISTRY="localhost"
7+
8+
docker build . -f ./images/Dockerfile.preflight -t "${REGISTRY}/${USERIMG}-preflight-debug:${VER}"
9+
10+
docker run --privileged --pid="host" \
11+
-e RUST_LOG="debug" \
12+
-e EDERA_PREFLIGHT_VERBOSE=true \
13+
-e EDERA_PREFLIGHT_TARGET_DIR='/host' \
14+
-e EDERA_PREFLIGHT_SKIP_GROUPS='KernelChecks;ScriptedChecks;SystemChecks' \
15+
-e EDERA_PREFLIGHT_SCRIPTS_DIR=/scripts \
16+
"${REGISTRY}/${USERIMG}-preflight-debug:${VER}"

images/Dockerfile.preflight

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM ghcr.io/edera-dev/cross-base-linux-musl:latest@sha256:87ba899ea380bd85c22f194ab2f4f2cf791fc832d27ee20bb00d07ce23771975 AS build
1+
FROM ghcr.io/edera-dev/cross-base-linux-musl:latest@sha256:a591bb18a5ede06c6e814a4d263dddb172e0b9f998873841163585c286484983 AS build
22

33
ENV TARGET_LIBC=musl TARGET_VENDOR=unknown DISABLE_CROSS_RS=1
44

src/checkers/kernel.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use crate::helpers::{
44
};
55

66
use anyhow::{Result, bail};
7+
use async_trait::async_trait;
78
use log::debug;
89
use procfs::{Current, sys::kernel};
910
use std::fs;
@@ -136,6 +137,7 @@ impl KernelChecks {
136137
}
137138
}
138139

140+
#[async_trait]
139141
impl CheckGroup for KernelChecks {
140142
fn id(&self) -> &str {
141143
GROUP_IDENTIFIER
@@ -149,7 +151,7 @@ impl CheckGroup for KernelChecks {
149151
"Kernel requirement checks"
150152
}
151153

152-
fn run(&self) -> CheckGroupResult {
154+
async fn run(&self) -> CheckGroupResult {
153155
self.run_all()
154156
}
155157
}

src/checkers/script.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use crate::helpers::{
44
};
55

66
use anyhow::Result;
7+
use async_trait::async_trait;
78
use log::{debug, warn};
89
use std::env;
910
use std::fs;
@@ -249,6 +250,7 @@ impl ScriptChecks {
249250
}
250251
}
251252

253+
#[async_trait]
252254
impl CheckGroup for ScriptChecks {
253255
fn id(&self) -> &str {
254256
GROUP_IDENTIFIER
@@ -262,7 +264,7 @@ impl CheckGroup for ScriptChecks {
262264
"Checks composed through small shell scripts"
263265
}
264266

265-
fn run(&self) -> CheckGroupResult {
267+
async fn run(&self) -> CheckGroupResult {
266268
self.run_all()
267269
}
268270
}

src/checkers/system.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use crate::helpers::{
33
CheckResultValue::{Errored, Failed, Passed},
44
};
55

6+
use async_trait::async_trait;
67
use log::debug;
78
use sysinfo::{Disks, System};
89

@@ -76,6 +77,7 @@ impl SystemChecks {
7677
}
7778
}
7879

80+
#[async_trait]
7981
impl CheckGroup for SystemChecks {
8082
fn id(&self) -> &str {
8183
GROUP_IDENTIFIER
@@ -89,7 +91,7 @@ impl CheckGroup for SystemChecks {
8991
"System requirement checks"
9092
}
9193

92-
fn run(&self) -> CheckGroupResult {
94+
async fn run(&self) -> CheckGroupResult {
9395
self.run_all()
9496
}
9597
}

src/helpers/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
pub mod host_executor;
22

3+
use async_trait::async_trait;
34
use log::{error, info, warn};
45
use std::fmt;
56

@@ -115,6 +116,7 @@ impl CheckGroupResult {
115116
}
116117

117118
/// CheckGroup is a trait representing a group of checks.
119+
#[async_trait]
118120
pub trait CheckGroup {
119121
/// name is the name of the check group
120122
fn name(&self) -> &str;
@@ -127,5 +129,5 @@ pub trait CheckGroup {
127129
fn description(&self) -> &str;
128130

129131
/// run is the main entry point that runs the checks within the check group.
130-
fn run(&self) -> CheckGroupResult;
132+
async fn run(&self) -> CheckGroupResult;
131133
}

0 commit comments

Comments
 (0)