Skip to content

Commit da6f4c2

Browse files
committed
address orion review feedback
1 parent c20283f commit da6f4c2

5 files changed

Lines changed: 45 additions & 30 deletions

File tree

.github/workflows/base.yml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,6 @@ jobs:
3535
with:
3636
submodules: recursive
3737

38-
- name: Checkout path dependencies
39-
run: |
40-
git clone --depth 1 --branch codex/antares-fuse-local-libfuse https://github.com/web3infra-foundation/scorpiofs.git ../scorpiofs
41-
git clone --depth 1 --branch codex/stabilize-libfuse-buck2-races https://github.com/rk8s-dev/rk8s.git ../rk8s
4238

4339
- name: Install nightly toolchain
4440
run: |
@@ -63,10 +59,6 @@ jobs:
6359
with:
6460
submodules: recursive
6561

66-
- name: Checkout path dependencies
67-
run: |
68-
git clone --depth 1 --branch codex/antares-fuse-local-libfuse https://github.com/web3infra-foundation/scorpiofs.git ../scorpiofs
69-
git clone --depth 1 --branch codex/stabilize-libfuse-buck2-races https://github.com/rk8s-dev/rk8s.git ../rk8s
7062

7163
- name: Install system dependencies
7264
uses: ./.github/install-dep
@@ -119,10 +111,6 @@ jobs:
119111
submodules: recursive
120112
lfs: true
121113

122-
- name: Checkout path dependencies
123-
run: |
124-
git clone --depth 1 --branch codex/antares-fuse-local-libfuse https://github.com/web3infra-foundation/scorpiofs.git ../scorpiofs
125-
git clone --depth 1 --branch codex/stabilize-libfuse-buck2-races https://github.com/rk8s-dev/rk8s.git ../rk8s
126114

127115
- name: Install system dependencies
128116
uses: ./.github/install-dep

.github/workflows/services.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,6 @@ jobs:
5151
with:
5252
submodules: recursive
5353

54-
- name: Checkout path dependencies
55-
run: |
56-
git clone --depth 1 --branch codex/antares-fuse-local-libfuse https://github.com/web3infra-foundation/scorpiofs.git ../scorpiofs
57-
git clone --depth 1 --branch codex/stabilize-libfuse-buck2-races https://github.com/rk8s-dev/rk8s.git ../rk8s
5854

5955
# Install system dependencies
6056
- name: Install system dependencies

Cargo.lock

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

orion-scheduler/src/vm_manager.rs

Lines changed: 41 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,36 +11,65 @@ use crate::{
1111
/// The target directory inside the VM guest OS where Orion is deployed
1212
const ORION_TARGET_DIR: &str = "/home/orion/orion-runner";
1313

14-
/// Swap file path and size for Orion build VMs (16 GB RAM by default).
14+
/// Swap file path and size bounds for Orion build VMs (16 GB RAM by default).
1515
const VM_SWAP_FILE: &str = "/swapfile";
16-
const VM_SWAP_SIZE_GB: u32 = 8;
16+
const VM_SWAP_TARGET_SIZE_GB: u32 = 8;
17+
const VM_SWAP_MIN_SIZE_GB: u32 = 1;
18+
const VM_SWAP_FREE_SPACE_RESERVE_GB: u32 = 1;
1719

1820
/// Create and enable a swap file if not already active.
1921
async fn setup_vm_swap(machine: &KeepAliveMachine) -> Result<()> {
2022
info!(
21-
"[orion-deploy] Configuring {} GB swap at {}",
22-
VM_SWAP_SIZE_GB, VM_SWAP_FILE
23+
"[orion-deploy] Configuring up to {} GB swap at {}",
24+
VM_SWAP_TARGET_SIZE_GB, VM_SWAP_FILE
2325
);
2426
let cmd = format!(
2527
r#"set -e
28+
swap_active=0
2629
if swapon --show --noheadings 2>/dev/null | grep -q '{swap_file}'; then
2730
echo 'swap already active'
31+
swap_active=1
2832
elif [ -f '{swap_file}' ]; then
2933
swapon '{swap_file}'
34+
swap_active=1
3035
else
31-
fallocate -l {size_g}G '{swap_file}' 2>/dev/null \
32-
|| dd if=/dev/zero of='{swap_file}' bs=1M count=$(( {size_g} * 1024 )) status=none
33-
chmod 600 '{swap_file}'
34-
mkswap '{swap_file}'
35-
swapon '{swap_file}'
36+
target_kb=$(( {target_gb} * 1024 * 1024 ))
37+
min_kb=$(( {min_gb} * 1024 * 1024 ))
38+
reserve_kb=$(( {reserve_gb} * 1024 * 1024 ))
39+
avail_kb=$(df -Pk "$(dirname '{swap_file}')" | awk 'NR == 2 {{ print $4 }}')
40+
if [ -z "$avail_kb" ]; then
41+
echo 'unable to determine available disk space for swap' >&2
42+
exit 1
43+
fi
44+
usable_kb=$(( avail_kb - reserve_kb ))
45+
if [ "$usable_kb" -lt "$min_kb" ]; then
46+
echo "skipping swap: only ${{avail_kb}} KiB available, reserving ${{reserve_kb}} KiB"
47+
else
48+
if [ "$usable_kb" -gt "$target_kb" ]; then
49+
swap_kb="$target_kb"
50+
else
51+
swap_kb="$usable_kb"
52+
fi
53+
echo "creating ${{swap_kb}} KiB swap file"
54+
fallocate -l "${{swap_kb}}K" '{swap_file}' 2>/dev/null \
55+
|| dd if=/dev/zero of='{swap_file}' bs=1024 count="$swap_kb" status=none
56+
chmod 600 '{swap_file}'
57+
mkswap '{swap_file}'
58+
swapon '{swap_file}'
59+
swap_active=1
60+
fi
61+
fi
62+
if [ "$swap_active" -eq 1 ]; then
63+
grep -qF '{swap_file}' /etc/fstab 2>/dev/null \
64+
|| echo '{swap_file} none swap sw 0 0' >> /etc/fstab
3665
fi
37-
grep -qF '{swap_file}' /etc/fstab 2>/dev/null \
38-
|| echo '{swap_file} none swap sw 0 0' >> /etc/fstab
3966
swapon --show
4067
free -h | head -2
4168
"#,
4269
swap_file = VM_SWAP_FILE,
43-
size_g = VM_SWAP_SIZE_GB,
70+
target_gb = VM_SWAP_TARGET_SIZE_GB,
71+
min_gb = VM_SWAP_MIN_SIZE_GB,
72+
reserve_gb = VM_SWAP_FREE_SPACE_RESERVE_GB,
4473
);
4574
let output = machine.exec(&cmd).await?;
4675
info!(

orion/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,4 @@ serial_test = { workspace = true }
3737
tempfile = { workspace = true }
3838

3939
[target.'cfg(target_os = "linux")'.dependencies]
40-
# scorpiofs = { git = "https://github.com/web3infra-foundation/scorpiofs.git" }
41-
scorpiofs = { path = "../../scorpiofs" }
40+
scorpiofs = { git = "https://github.com/web3infra-foundation/scorpiofs.git", branch = "codex/antares-fuse-local-libfuse" }

0 commit comments

Comments
 (0)