From 969cc56914f0ff74de0fd1ef9b752ab2e6c89f50 Mon Sep 17 00:00:00 2001 From: "benjamin.747" Date: Tue, 23 Jun 2026 19:37:56 +0800 Subject: [PATCH 1/8] fix ui scroll --- .../ClView/components/Checks/cpns/Task.tsx | 9 +----- .../Checks/hooks/useLeftPanelScroll.ts | 31 ++++++++++++++++--- .../ClView/components/Checks/index.tsx | 10 ++++-- 3 files changed, 35 insertions(+), 15 deletions(-) diff --git a/moon/apps/web/components/ClView/components/Checks/cpns/Task.tsx b/moon/apps/web/components/ClView/components/Checks/cpns/Task.tsx index 6f6a680fb..8142628b3 100644 --- a/moon/apps/web/components/ClView/components/Checks/cpns/Task.tsx +++ b/moon/apps/web/components/ClView/components/Checks/cpns/Task.tsx @@ -288,15 +288,8 @@ const TaskItem = memo(function TaskItem({ const showQueued = Boolean(isQueued) && build.status === 'Building' - const handleClick = (e: React.MouseEvent) => { - const scrollParent = e.currentTarget.closest('[data-build-list-scroll]') as HTMLElement | null - const scrollTop = scrollParent?.scrollTop ?? 0 - + const handleClick = () => { onSelectBuild(build.id) - - requestAnimationFrame(() => { - if (scrollParent) scrollParent.scrollTop = scrollTop - }) } const handleRetry = (e: React.MouseEvent) => { diff --git a/moon/apps/web/components/ClView/components/Checks/hooks/useLeftPanelScroll.ts b/moon/apps/web/components/ClView/components/Checks/hooks/useLeftPanelScroll.ts index 5c1b27f6a..3d4177540 100644 --- a/moon/apps/web/components/ClView/components/Checks/hooks/useLeftPanelScroll.ts +++ b/moon/apps/web/components/ClView/components/Checks/hooks/useLeftPanelScroll.ts @@ -1,22 +1,35 @@ -import { RefObject, useEffect, useRef } from 'react' +import { RefObject, useCallback, useEffect, useLayoutEffect, useRef } from 'react' export function useLeftPanelScroll(cl: string, buildId: string, leftPanelRef: RefObject) { const leftPanelScrollRef = useRef(0) + const pendingRestoreRef = useRef(null) + const isRestoringRef = useRef(false) const prevClRef = useRef(cl) useEffect(() => { if (prevClRef.current !== cl) { prevClRef.current = cl leftPanelScrollRef.current = 0 + pendingRestoreRef.current = null } }, [cl]) + const preserveScroll = useCallback(() => { + const panel = leftPanelRef.current + + if (panel) { + pendingRestoreRef.current = panel.scrollTop + } + }, [leftPanelRef]) + useEffect(() => { const panel = leftPanelRef.current if (!panel) return const onScroll = () => { + if (isRestoringRef.current) return + leftPanelScrollRef.current = panel.scrollTop } @@ -25,17 +38,25 @@ export function useLeftPanelScroll(cl: string, buildId: string, leftPanelRef: Re return () => panel.removeEventListener('scroll', onScroll) }, [leftPanelRef]) - useEffect(() => { + // Restore before paint so a re-render cannot reset scroll to 0 and clobber the + // saved position via the scroll listener. + useLayoutEffect(() => { const panel = leftPanelRef.current if (!panel) return - const saved = leftPanelScrollRef.current + const saved = pendingRestoreRef.current ?? leftPanelScrollRef.current + + pendingRestoreRef.current = null + + isRestoringRef.current = true + panel.scrollTop = saved + leftPanelScrollRef.current = saved requestAnimationFrame(() => { - panel.scrollTop = saved + isRestoringRef.current = false }) }, [buildId, leftPanelRef]) - return {} + return { preserveScroll } } diff --git a/moon/apps/web/components/ClView/components/Checks/index.tsx b/moon/apps/web/components/ClView/components/Checks/index.tsx index 7d9520d71..024bac72a 100644 --- a/moon/apps/web/components/ClView/components/Checks/index.tsx +++ b/moon/apps/web/components/ClView/components/Checks/index.tsx @@ -40,7 +40,12 @@ const Checks = ({ cl, path, prName }: { cl: string; path?: string; prName?: stri defaultLeftWidthPercent } = useResizablePanels() - useLeftPanelScroll(cl, buildId, leftPanelRef) + const { preserveScroll } = useLeftPanelScroll(cl, buildId, leftPanelRef) + + const handleSelectBuild = (nextBuildId: string, taskId?: string) => { + preserveScroll() + selectBuild(nextBuildId, taskId) + } const [isDropdownOpen, setIsDropdownOpen] = useState(false) @@ -278,6 +283,7 @@ const Checks = ({ cl, path, prName }: { cl: string; path?: string; prName?: stri key={task.task_id} onClick={(e) => { e.stopPropagation() + preserveScroll() selectTask(task.task_id) setIsDropdownOpen(false) }} @@ -326,7 +332,7 @@ const Checks = ({ cl, path, prName }: { cl: string; path?: string; prName?: stri tasks={tasksToDisplay} logsAvailableIds={logsAvailableIds} selectedBuildId={buildId} - onSelectBuild={selectBuild} + onSelectBuild={handleSelectBuild} totalTasksCount={validTasks.length} cl={cl} /> From 6d5523931b7206e1fd9bc23368b67587943d23b5 Mon Sep 17 00:00:00 2001 From: Xiaoyang Han Date: Wed, 24 Jun 2026 00:28:25 +0800 Subject: [PATCH 2/8] fix(orion): improve vm build stability --- Cargo.lock | 5 -- .../ClView/components/Checks/cpns/Task.tsx | 9 +++- .../Checks/hooks/useLeftPanelScroll.ts | 31 ++---------- .../ClView/components/Checks/index.tsx | 10 +--- orion-scheduler/TESTING.md | 2 + orion-scheduler/src/vm_manager.rs | 47 +++++++++++++++++++ orion/Cargo.toml | 3 +- 7 files changed, 66 insertions(+), 41 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 97bbd2159..a244ef5e6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4440,8 +4440,6 @@ dependencies = [ [[package]] name = "libfuse-fs" version = "0.1.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d61be2a0235d6a5ba30064c172f12d5465da0f013281a0e6675604d0781496e9" dependencies = [ "async-trait", "bitflags 2.13.0", @@ -7051,8 +7049,6 @@ dependencies = [ [[package]] name = "rfuse3" version = "0.0.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5d7bea55817b58bd3a706ac0671f9aedc06d2d91e2f68272bd4fbe62f817d2b" dependencies = [ "aligned_box", "async-notify", @@ -7699,7 +7695,6 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "scorpiofs" version = "0.2.2" -source = "git+https://github.com/web3infra-foundation/scorpiofs.git#230f62a28598100b2bb94379de20bdec9d4566c5" dependencies = [ "async-recursion", "async-trait", diff --git a/moon/apps/web/components/ClView/components/Checks/cpns/Task.tsx b/moon/apps/web/components/ClView/components/Checks/cpns/Task.tsx index 8142628b3..6f6a680fb 100644 --- a/moon/apps/web/components/ClView/components/Checks/cpns/Task.tsx +++ b/moon/apps/web/components/ClView/components/Checks/cpns/Task.tsx @@ -288,8 +288,15 @@ const TaskItem = memo(function TaskItem({ const showQueued = Boolean(isQueued) && build.status === 'Building' - const handleClick = () => { + const handleClick = (e: React.MouseEvent) => { + const scrollParent = e.currentTarget.closest('[data-build-list-scroll]') as HTMLElement | null + const scrollTop = scrollParent?.scrollTop ?? 0 + onSelectBuild(build.id) + + requestAnimationFrame(() => { + if (scrollParent) scrollParent.scrollTop = scrollTop + }) } const handleRetry = (e: React.MouseEvent) => { diff --git a/moon/apps/web/components/ClView/components/Checks/hooks/useLeftPanelScroll.ts b/moon/apps/web/components/ClView/components/Checks/hooks/useLeftPanelScroll.ts index 3d4177540..5c1b27f6a 100644 --- a/moon/apps/web/components/ClView/components/Checks/hooks/useLeftPanelScroll.ts +++ b/moon/apps/web/components/ClView/components/Checks/hooks/useLeftPanelScroll.ts @@ -1,35 +1,22 @@ -import { RefObject, useCallback, useEffect, useLayoutEffect, useRef } from 'react' +import { RefObject, useEffect, useRef } from 'react' export function useLeftPanelScroll(cl: string, buildId: string, leftPanelRef: RefObject) { const leftPanelScrollRef = useRef(0) - const pendingRestoreRef = useRef(null) - const isRestoringRef = useRef(false) const prevClRef = useRef(cl) useEffect(() => { if (prevClRef.current !== cl) { prevClRef.current = cl leftPanelScrollRef.current = 0 - pendingRestoreRef.current = null } }, [cl]) - const preserveScroll = useCallback(() => { - const panel = leftPanelRef.current - - if (panel) { - pendingRestoreRef.current = panel.scrollTop - } - }, [leftPanelRef]) - useEffect(() => { const panel = leftPanelRef.current if (!panel) return const onScroll = () => { - if (isRestoringRef.current) return - leftPanelScrollRef.current = panel.scrollTop } @@ -38,25 +25,17 @@ export function useLeftPanelScroll(cl: string, buildId: string, leftPanelRef: Re return () => panel.removeEventListener('scroll', onScroll) }, [leftPanelRef]) - // Restore before paint so a re-render cannot reset scroll to 0 and clobber the - // saved position via the scroll listener. - useLayoutEffect(() => { + useEffect(() => { const panel = leftPanelRef.current if (!panel) return - const saved = pendingRestoreRef.current ?? leftPanelScrollRef.current - - pendingRestoreRef.current = null - - isRestoringRef.current = true - panel.scrollTop = saved - leftPanelScrollRef.current = saved + const saved = leftPanelScrollRef.current requestAnimationFrame(() => { - isRestoringRef.current = false + panel.scrollTop = saved }) }, [buildId, leftPanelRef]) - return { preserveScroll } + return {} } diff --git a/moon/apps/web/components/ClView/components/Checks/index.tsx b/moon/apps/web/components/ClView/components/Checks/index.tsx index 024bac72a..7d9520d71 100644 --- a/moon/apps/web/components/ClView/components/Checks/index.tsx +++ b/moon/apps/web/components/ClView/components/Checks/index.tsx @@ -40,12 +40,7 @@ const Checks = ({ cl, path, prName }: { cl: string; path?: string; prName?: stri defaultLeftWidthPercent } = useResizablePanels() - const { preserveScroll } = useLeftPanelScroll(cl, buildId, leftPanelRef) - - const handleSelectBuild = (nextBuildId: string, taskId?: string) => { - preserveScroll() - selectBuild(nextBuildId, taskId) - } + useLeftPanelScroll(cl, buildId, leftPanelRef) const [isDropdownOpen, setIsDropdownOpen] = useState(false) @@ -283,7 +278,6 @@ const Checks = ({ cl, path, prName }: { cl: string; path?: string; prName?: stri key={task.task_id} onClick={(e) => { e.stopPropagation() - preserveScroll() selectTask(task.task_id) setIsDropdownOpen(false) }} @@ -332,7 +326,7 @@ const Checks = ({ cl, path, prName }: { cl: string; path?: string; prName?: stri tasks={tasksToDisplay} logsAvailableIds={logsAvailableIds} selectedBuildId={buildId} - onSelectBuild={handleSelectBuild} + onSelectBuild={selectBuild} totalTasksCount={validTasks.length} cl={cl} /> diff --git a/orion-scheduler/TESTING.md b/orion-scheduler/TESTING.md index 0c96a2001..5f7b95b48 100644 --- a/orion-scheduler/TESTING.md +++ b/orion-scheduler/TESTING.md @@ -91,6 +91,8 @@ VM_IP=$(curl -s http://localhost:8080/status | jq -r .vm_ip) ssh -i ~/.ssh/orion_vm_access root@$VM_IP ``` +部署时 scheduler 会在 guest 内创建 **8 GB** swap 文件(`/swapfile`,写入 `/etc/fstab`),减轻全量 buck2 编译时的内存压力。可用 `swapon --show` / `free -h` 确认。 + ### 日志 | 端点 | 格式 | 说明 | diff --git a/orion-scheduler/src/vm_manager.rs b/orion-scheduler/src/vm_manager.rs index 984210836..ec0fd07ee 100644 --- a/orion-scheduler/src/vm_manager.rs +++ b/orion-scheduler/src/vm_manager.rs @@ -11,6 +11,51 @@ use crate::{ /// The target directory inside the VM guest OS where Orion is deployed const ORION_TARGET_DIR: &str = "/home/orion/orion-runner"; +/// Swap file path and size for Orion build VMs (16 GB RAM by default). +const VM_SWAP_FILE: &str = "/swapfile"; +const VM_SWAP_SIZE_GB: u32 = 8; + +/// Create and enable a swap file if not already active. +async fn setup_vm_swap(machine: &KeepAliveMachine) -> Result<()> { + info!( + "[orion-deploy] Configuring {} GB swap at {}", + VM_SWAP_SIZE_GB, VM_SWAP_FILE + ); + let cmd = format!( + r#"set -e +if swapon --show --noheadings 2>/dev/null | grep -q '{swap_file}'; then + echo 'swap already active' +elif [ -f '{swap_file}' ]; then + swapon '{swap_file}' +else + fallocate -l {size_g}G '{swap_file}' 2>/dev/null \ + || dd if=/dev/zero of='{swap_file}' bs=1M count=$(( {size_g} * 1024 )) status=none + chmod 600 '{swap_file}' + mkswap '{swap_file}' + swapon '{swap_file}' +fi +grep -qF '{swap_file}' /etc/fstab 2>/dev/null \ + || echo '{swap_file} none swap sw 0 0' >> /etc/fstab +swapon --show +free -h | head -2 +"#, + swap_file = VM_SWAP_FILE, + size_g = VM_SWAP_SIZE_GB, + ); + let output = machine.exec(&cmd).await?; + info!( + "[orion-deploy] Swap setup output:\n{}", + String::from_utf8_lossy(&output.stdout).trim() + ); + if !output.status.success() { + anyhow::bail!( + "swap setup failed: {}", + String::from_utf8_lossy(&output.stderr).trim() + ); + } + Ok(()) +} + /// Upload a single file to the VM via SFTP async fn upload_file( machine: &KeepAliveMachine, @@ -143,6 +188,8 @@ pub async fn deploy_orion_in_vm( pub async fn start_orion_in_vm(machine: &KeepAliveMachine) -> Result { info!("[orion-deploy] Starting Orion service"); + setup_vm_swap(machine).await?; + // Step 1: Create Scorpio directories info!("[orion-deploy] Creating Scorpio directories"); machine.exec("mkdir -p /data/scorpio/store").await?; diff --git a/orion/Cargo.toml b/orion/Cargo.toml index 4f7b7f356..b6b5b7ceb 100644 --- a/orion/Cargo.toml +++ b/orion/Cargo.toml @@ -37,4 +37,5 @@ serial_test = { workspace = true } tempfile = { workspace = true } [target.'cfg(target_os = "linux")'.dependencies] -scorpiofs = { git = "https://github.com/web3infra-foundation/scorpiofs.git" } +# scorpiofs = { git = "https://github.com/web3infra-foundation/scorpiofs.git" } +scorpiofs = { path = "../../scorpiofs" } From 0d7353fffe7b2178f6515342d93bd37d68942974 Mon Sep 17 00:00:00 2001 From: Xiaoyang Han Date: Wed, 24 Jun 2026 00:37:30 +0800 Subject: [PATCH 3/8] chore: trigger ci From c20283f4ff5b0dc96d760dce84c25791978e25be Mon Sep 17 00:00:00 2001 From: Xiaoyang Han Date: Wed, 24 Jun 2026 01:07:20 +0800 Subject: [PATCH 4/8] ci: checkout orion path dependencies --- .github/workflows/base.yml | 15 +++++++++++++++ .github/workflows/services.yml | 5 +++++ 2 files changed, 20 insertions(+) diff --git a/.github/workflows/base.yml b/.github/workflows/base.yml index 6afee9c54..871970515 100644 --- a/.github/workflows/base.yml +++ b/.github/workflows/base.yml @@ -35,6 +35,11 @@ jobs: with: submodules: recursive + - name: Checkout path dependencies + run: | + git clone --depth 1 --branch codex/antares-fuse-local-libfuse https://github.com/web3infra-foundation/scorpiofs.git ../scorpiofs + git clone --depth 1 --branch codex/stabilize-libfuse-buck2-races https://github.com/rk8s-dev/rk8s.git ../rk8s + - name: Install nightly toolchain run: | rustup toolchain install nightly --profile minimal @@ -58,6 +63,11 @@ jobs: with: submodules: recursive + - name: Checkout path dependencies + run: | + git clone --depth 1 --branch codex/antares-fuse-local-libfuse https://github.com/web3infra-foundation/scorpiofs.git ../scorpiofs + git clone --depth 1 --branch codex/stabilize-libfuse-buck2-races https://github.com/rk8s-dev/rk8s.git ../rk8s + - name: Install system dependencies uses: ./.github/install-dep with: @@ -109,6 +119,11 @@ jobs: submodules: recursive lfs: true + - name: Checkout path dependencies + run: | + git clone --depth 1 --branch codex/antares-fuse-local-libfuse https://github.com/web3infra-foundation/scorpiofs.git ../scorpiofs + git clone --depth 1 --branch codex/stabilize-libfuse-buck2-races https://github.com/rk8s-dev/rk8s.git ../rk8s + - name: Install system dependencies uses: ./.github/install-dep with: diff --git a/.github/workflows/services.yml b/.github/workflows/services.yml index a6d3adda6..0aa4f1bd9 100644 --- a/.github/workflows/services.yml +++ b/.github/workflows/services.yml @@ -51,6 +51,11 @@ jobs: with: submodules: recursive + - name: Checkout path dependencies + run: | + git clone --depth 1 --branch codex/antares-fuse-local-libfuse https://github.com/web3infra-foundation/scorpiofs.git ../scorpiofs + git clone --depth 1 --branch codex/stabilize-libfuse-buck2-races https://github.com/rk8s-dev/rk8s.git ../rk8s + # Install system dependencies - name: Install system dependencies uses: ./.github/install-dep From da6f4c27dbcefbb843c3f21761f8fce3126fc77d Mon Sep 17 00:00:00 2001 From: Xiaoyang Han Date: Wed, 24 Jun 2026 02:06:04 +0800 Subject: [PATCH 5/8] address orion review feedback --- .github/workflows/base.yml | 12 ------- .github/workflows/services.yml | 4 --- Cargo.lock | 3 ++ orion-scheduler/src/vm_manager.rs | 53 ++++++++++++++++++++++++------- orion/Cargo.toml | 3 +- 5 files changed, 45 insertions(+), 30 deletions(-) diff --git a/.github/workflows/base.yml b/.github/workflows/base.yml index 871970515..a6912cd79 100644 --- a/.github/workflows/base.yml +++ b/.github/workflows/base.yml @@ -35,10 +35,6 @@ jobs: with: submodules: recursive - - name: Checkout path dependencies - run: | - git clone --depth 1 --branch codex/antares-fuse-local-libfuse https://github.com/web3infra-foundation/scorpiofs.git ../scorpiofs - git clone --depth 1 --branch codex/stabilize-libfuse-buck2-races https://github.com/rk8s-dev/rk8s.git ../rk8s - name: Install nightly toolchain run: | @@ -63,10 +59,6 @@ jobs: with: submodules: recursive - - name: Checkout path dependencies - run: | - git clone --depth 1 --branch codex/antares-fuse-local-libfuse https://github.com/web3infra-foundation/scorpiofs.git ../scorpiofs - git clone --depth 1 --branch codex/stabilize-libfuse-buck2-races https://github.com/rk8s-dev/rk8s.git ../rk8s - name: Install system dependencies uses: ./.github/install-dep @@ -119,10 +111,6 @@ jobs: submodules: recursive lfs: true - - name: Checkout path dependencies - run: | - git clone --depth 1 --branch codex/antares-fuse-local-libfuse https://github.com/web3infra-foundation/scorpiofs.git ../scorpiofs - git clone --depth 1 --branch codex/stabilize-libfuse-buck2-races https://github.com/rk8s-dev/rk8s.git ../rk8s - name: Install system dependencies uses: ./.github/install-dep diff --git a/.github/workflows/services.yml b/.github/workflows/services.yml index 0aa4f1bd9..434a1c5a3 100644 --- a/.github/workflows/services.yml +++ b/.github/workflows/services.yml @@ -51,10 +51,6 @@ jobs: with: submodules: recursive - - name: Checkout path dependencies - run: | - git clone --depth 1 --branch codex/antares-fuse-local-libfuse https://github.com/web3infra-foundation/scorpiofs.git ../scorpiofs - git clone --depth 1 --branch codex/stabilize-libfuse-buck2-races https://github.com/rk8s-dev/rk8s.git ../rk8s # Install system dependencies - name: Install system dependencies diff --git a/Cargo.lock b/Cargo.lock index a244ef5e6..be911fa35 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4440,6 +4440,7 @@ dependencies = [ [[package]] name = "libfuse-fs" version = "0.1.13" +source = "git+https://github.com/rk8s-dev/rk8s.git?branch=codex%2Fstabilize-libfuse-buck2-races#b91e018b86d649cd6cb9aeb482ed15f1850d5121" dependencies = [ "async-trait", "bitflags 2.13.0", @@ -7049,6 +7050,7 @@ dependencies = [ [[package]] name = "rfuse3" version = "0.0.8" +source = "git+https://github.com/rk8s-dev/rk8s.git?branch=codex%2Fstabilize-libfuse-buck2-races#b91e018b86d649cd6cb9aeb482ed15f1850d5121" dependencies = [ "aligned_box", "async-notify", @@ -7695,6 +7697,7 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "scorpiofs" version = "0.2.2" +source = "git+https://github.com/web3infra-foundation/scorpiofs.git?branch=codex%2Fantares-fuse-local-libfuse#c4424423a6e7f19d0566a008ea762c3992d5ed9b" dependencies = [ "async-recursion", "async-trait", diff --git a/orion-scheduler/src/vm_manager.rs b/orion-scheduler/src/vm_manager.rs index ec0fd07ee..7330b358e 100644 --- a/orion-scheduler/src/vm_manager.rs +++ b/orion-scheduler/src/vm_manager.rs @@ -11,36 +11,65 @@ use crate::{ /// The target directory inside the VM guest OS where Orion is deployed const ORION_TARGET_DIR: &str = "/home/orion/orion-runner"; -/// Swap file path and size for Orion build VMs (16 GB RAM by default). +/// Swap file path and size bounds for Orion build VMs (16 GB RAM by default). const VM_SWAP_FILE: &str = "/swapfile"; -const VM_SWAP_SIZE_GB: u32 = 8; +const VM_SWAP_TARGET_SIZE_GB: u32 = 8; +const VM_SWAP_MIN_SIZE_GB: u32 = 1; +const VM_SWAP_FREE_SPACE_RESERVE_GB: u32 = 1; /// Create and enable a swap file if not already active. async fn setup_vm_swap(machine: &KeepAliveMachine) -> Result<()> { info!( - "[orion-deploy] Configuring {} GB swap at {}", - VM_SWAP_SIZE_GB, VM_SWAP_FILE + "[orion-deploy] Configuring up to {} GB swap at {}", + VM_SWAP_TARGET_SIZE_GB, VM_SWAP_FILE ); let cmd = format!( r#"set -e +swap_active=0 if swapon --show --noheadings 2>/dev/null | grep -q '{swap_file}'; then echo 'swap already active' + swap_active=1 elif [ -f '{swap_file}' ]; then swapon '{swap_file}' + swap_active=1 else - fallocate -l {size_g}G '{swap_file}' 2>/dev/null \ - || dd if=/dev/zero of='{swap_file}' bs=1M count=$(( {size_g} * 1024 )) status=none - chmod 600 '{swap_file}' - mkswap '{swap_file}' - swapon '{swap_file}' + target_kb=$(( {target_gb} * 1024 * 1024 )) + min_kb=$(( {min_gb} * 1024 * 1024 )) + reserve_kb=$(( {reserve_gb} * 1024 * 1024 )) + avail_kb=$(df -Pk "$(dirname '{swap_file}')" | awk 'NR == 2 {{ print $4 }}') + if [ -z "$avail_kb" ]; then + echo 'unable to determine available disk space for swap' >&2 + exit 1 + fi + usable_kb=$(( avail_kb - reserve_kb )) + if [ "$usable_kb" -lt "$min_kb" ]; then + echo "skipping swap: only ${{avail_kb}} KiB available, reserving ${{reserve_kb}} KiB" + else + if [ "$usable_kb" -gt "$target_kb" ]; then + swap_kb="$target_kb" + else + swap_kb="$usable_kb" + fi + echo "creating ${{swap_kb}} KiB swap file" + fallocate -l "${{swap_kb}}K" '{swap_file}' 2>/dev/null \ + || dd if=/dev/zero of='{swap_file}' bs=1024 count="$swap_kb" status=none + chmod 600 '{swap_file}' + mkswap '{swap_file}' + swapon '{swap_file}' + swap_active=1 + fi +fi +if [ "$swap_active" -eq 1 ]; then + grep -qF '{swap_file}' /etc/fstab 2>/dev/null \ + || echo '{swap_file} none swap sw 0 0' >> /etc/fstab fi -grep -qF '{swap_file}' /etc/fstab 2>/dev/null \ - || echo '{swap_file} none swap sw 0 0' >> /etc/fstab swapon --show free -h | head -2 "#, swap_file = VM_SWAP_FILE, - size_g = VM_SWAP_SIZE_GB, + target_gb = VM_SWAP_TARGET_SIZE_GB, + min_gb = VM_SWAP_MIN_SIZE_GB, + reserve_gb = VM_SWAP_FREE_SPACE_RESERVE_GB, ); let output = machine.exec(&cmd).await?; info!( diff --git a/orion/Cargo.toml b/orion/Cargo.toml index b6b5b7ceb..671dfa16b 100644 --- a/orion/Cargo.toml +++ b/orion/Cargo.toml @@ -37,5 +37,4 @@ serial_test = { workspace = true } tempfile = { workspace = true } [target.'cfg(target_os = "linux")'.dependencies] -# scorpiofs = { git = "https://github.com/web3infra-foundation/scorpiofs.git" } -scorpiofs = { path = "../../scorpiofs" } +scorpiofs = { git = "https://github.com/web3infra-foundation/scorpiofs.git", branch = "codex/antares-fuse-local-libfuse" } From 51748c1a46a0503d351dc2744b3c2eb29c09642d Mon Sep 17 00:00:00 2001 From: Xiaoyang Han Date: Wed, 24 Jun 2026 02:09:51 +0800 Subject: [PATCH 6/8] update scorpiofs dependency revision --- Cargo.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index be911fa35..635e35ad9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4440,7 +4440,7 @@ dependencies = [ [[package]] name = "libfuse-fs" version = "0.1.13" -source = "git+https://github.com/rk8s-dev/rk8s.git?branch=codex%2Fstabilize-libfuse-buck2-races#b91e018b86d649cd6cb9aeb482ed15f1850d5121" +source = "git+https://github.com/rk8s-dev/rk8s.git?branch=codex%2Fstabilize-libfuse-buck2-races#babb85b837907578144366982368c38c4ee4ba32" dependencies = [ "async-trait", "bitflags 2.13.0", @@ -7050,7 +7050,7 @@ dependencies = [ [[package]] name = "rfuse3" version = "0.0.8" -source = "git+https://github.com/rk8s-dev/rk8s.git?branch=codex%2Fstabilize-libfuse-buck2-races#b91e018b86d649cd6cb9aeb482ed15f1850d5121" +source = "git+https://github.com/rk8s-dev/rk8s.git?branch=codex%2Fstabilize-libfuse-buck2-races#babb85b837907578144366982368c38c4ee4ba32" dependencies = [ "aligned_box", "async-notify", @@ -7697,7 +7697,7 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "scorpiofs" version = "0.2.2" -source = "git+https://github.com/web3infra-foundation/scorpiofs.git?branch=codex%2Fantares-fuse-local-libfuse#c4424423a6e7f19d0566a008ea762c3992d5ed9b" +source = "git+https://github.com/web3infra-foundation/scorpiofs.git?branch=codex%2Fantares-fuse-local-libfuse#5728f4935ae80b0c03563db99a894e12b94b649f" dependencies = [ "async-recursion", "async-trait", From 2077d35b2236a306bf07ea76cc4b75e67c9aaf75 Mon Sep 17 00:00:00 2001 From: Xiaoyang Han Date: Wed, 24 Jun 2026 02:31:51 +0800 Subject: [PATCH 7/8] update reviewed fuse dependency revisions --- Cargo.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 635e35ad9..69bfa21bb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4440,7 +4440,7 @@ dependencies = [ [[package]] name = "libfuse-fs" version = "0.1.13" -source = "git+https://github.com/rk8s-dev/rk8s.git?branch=codex%2Fstabilize-libfuse-buck2-races#babb85b837907578144366982368c38c4ee4ba32" +source = "git+https://github.com/rk8s-dev/rk8s.git?branch=codex%2Fstabilize-libfuse-buck2-races#d3e055a7a3abaf2a8d49e1ff46e110fa76365287" dependencies = [ "async-trait", "bitflags 2.13.0", @@ -7050,7 +7050,7 @@ dependencies = [ [[package]] name = "rfuse3" version = "0.0.8" -source = "git+https://github.com/rk8s-dev/rk8s.git?branch=codex%2Fstabilize-libfuse-buck2-races#babb85b837907578144366982368c38c4ee4ba32" +source = "git+https://github.com/rk8s-dev/rk8s.git?branch=codex%2Fstabilize-libfuse-buck2-races#d3e055a7a3abaf2a8d49e1ff46e110fa76365287" dependencies = [ "aligned_box", "async-notify", @@ -7697,7 +7697,7 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "scorpiofs" version = "0.2.2" -source = "git+https://github.com/web3infra-foundation/scorpiofs.git?branch=codex%2Fantares-fuse-local-libfuse#5728f4935ae80b0c03563db99a894e12b94b649f" +source = "git+https://github.com/web3infra-foundation/scorpiofs.git?branch=codex%2Fantares-fuse-local-libfuse#fa60cbd6aa9ce5fb75ae1c479309700452db71ea" dependencies = [ "async-recursion", "async-trait", From ad52e7516733b1c814fe86c5aa640e3cef4f1af3 Mon Sep 17 00:00:00 2001 From: Xiaoyang Han Date: Wed, 24 Jun 2026 03:13:01 +0800 Subject: [PATCH 8/8] update fuse whiteout dependency revisions --- Cargo.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 69bfa21bb..ef6ed9918 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4440,7 +4440,7 @@ dependencies = [ [[package]] name = "libfuse-fs" version = "0.1.13" -source = "git+https://github.com/rk8s-dev/rk8s.git?branch=codex%2Fstabilize-libfuse-buck2-races#d3e055a7a3abaf2a8d49e1ff46e110fa76365287" +source = "git+https://github.com/rk8s-dev/rk8s.git?branch=codex%2Fstabilize-libfuse-buck2-races#66ce9a6c95e27bb7b06bfec0a6f12bdd74a3565f" dependencies = [ "async-trait", "bitflags 2.13.0", @@ -7050,7 +7050,7 @@ dependencies = [ [[package]] name = "rfuse3" version = "0.0.8" -source = "git+https://github.com/rk8s-dev/rk8s.git?branch=codex%2Fstabilize-libfuse-buck2-races#d3e055a7a3abaf2a8d49e1ff46e110fa76365287" +source = "git+https://github.com/rk8s-dev/rk8s.git?branch=codex%2Fstabilize-libfuse-buck2-races#66ce9a6c95e27bb7b06bfec0a6f12bdd74a3565f" dependencies = [ "aligned_box", "async-notify", @@ -7697,7 +7697,7 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "scorpiofs" version = "0.2.2" -source = "git+https://github.com/web3infra-foundation/scorpiofs.git?branch=codex%2Fantares-fuse-local-libfuse#fa60cbd6aa9ce5fb75ae1c479309700452db71ea" +source = "git+https://github.com/web3infra-foundation/scorpiofs.git?branch=codex%2Fantares-fuse-local-libfuse#286147cd9295f68b1fad56994fc59adaca6ff50d" dependencies = [ "async-recursion", "async-trait",