Skip to content

feat(bug-finding): warn users if resource config conflicts with machi…#159

Open
tkqdldk wants to merge 8 commits into
ossf:mainfrom
tkqdldk:feat/resource-config-warn
Open

feat(bug-finding): warn users if resource config conflicts with machi…#159
tkqdldk wants to merge 8 commits into
ossf:mainfrom
tkqdldk:feat/resource-config-warn

Conversation

@tkqdldk

@tkqdldk tkqdldk commented Mar 28, 2026

Copy link
Copy Markdown

Closes #49

Description

Adds resources check and a warning when the compose file resource configurations (max CPU and total memory) exceed machine resources. The check runs in "Validate Configuration for Running" phase, before Docker attempts to start containers.

The function emits a warning but does not stop the execution.

Changes

  • Added get_host_total_memory() in utils.py
  • Added _validate_machine_resources() in crs_compose.py
  • Added validation task in __validate_before_run
  • Added changelog entry

Validation

All existing tests pass.

P.S. : Can't assign a reviewer directly, cc @azchin for review

@azchin azchin self-requested a review March 30, 2026 14:38

@azchin azchin left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR and sorry for the late response! I have a few requests detailed below. We also use a few linters and formatters in our CI workflow, so I recommend running them manually before pushing.

Comment thread oss_crs/src/utils.py Outdated
except(OSError):
pass

memeinfo = Path("/proc/meminfo")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

meminfo typo (caught by ruff)

Comment thread oss_crs/src/crs_compose.py Outdated
machine_cpu_count = os.cpu_count()
machine_memory = get_host_memory()

if machine_cpu_count is None or machine_memory == 0:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(C1) Let's get machine_memory to return None on failure

Comment thread oss_crs/src/utils.py Outdated
except subprocess.CalledProcessError as e:
raise RuntimeError(f"Error removing {path} with Docker: {e}")

def get_host_memory() -> int:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Return val as int | None, see (C1)

Comment thread oss_crs/src/utils.py Outdated
for line in meminfo.read_text().splitlines():
if line.startswith("MemTotal:"):
return int(line.split()[1])*1024
return 0

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return None see (C1)

Comment thread oss_crs/src/crs_compose.py Outdated
except ValueError as e:
log_warning(f"Failed to parse memory for {name}: {e}")

cpu_check = max_cpus_required <= machine_cpu_count

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is an off-by-one, since os.cpu_count() returns number of CPUs but cpuset is indexed by zero, so we'd get range of 0-3 on 4-core machine. max([0, 1, 2, 3]) == 3 < 4

max_cpus_required < machine_cpu_count would be the correct check. But please check/test for this edge case dynamically.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're absolutely right ^^'... I will also add dynamic testing.

@tkqdldk tkqdldk force-pushed the feat/resource-config-warn branch 2 times, most recently from 867fac0 to c55125d Compare April 1, 2026 11:49
@tkqdldk tkqdldk requested a review from azchin April 1, 2026 15:06
@azchin

azchin commented Apr 2, 2026

Copy link
Copy Markdown
Collaborator

Hm I'm not seeing the error messages implemented in your PR in my output. The build does indeed abort, but that's because of Docker's error handling and happens after docker compose gets run.

I can take a deeper look at what we're missing after the weekend, if needed.

% uv run oss-crs build-target --compose-file example/crs-libfuzzer/compose.yaml --fuzz-proj-path ~/post/CRSBench/benchmarks/sanity-mock-c-delta-01
╭─────────────────────────────────────────── Init CRS: crs-libfuzzer ────────────────────────────────────────────╮
│          Task         Status                                                                                   │
│   ✓      Git Fetch    Success                                                                                  │
│   ✓      Git Reset    Success                                                                                  │
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭─────────────────────────────────────────── CRS Compose Build Target ───────────────────────────────────────────╮
│          Task                                                           Status                                 │
│   ✗      crs-libfuzzer                                                  Failed                                 │
│            └─ build                                                     Failed                                 │
│              └─ Prepare docker compose file                             Success                                │
│              └─ Prepare docker images defined in docker compose file    Success                                │
│              └─ Build target by executing the docker compose            Failed                                 │
│              └─ Check outputs                                           Pending                                │
│              └─ 🧹 Cleanup Docker Compose                               Success                                │
│ ╭─────────────────────────────────────────── Error: crs-libfuzzer ───────────────────────────────────────────╮ │
│ │ Command failed with exit code 1:                                                                           │ │
│ │ docker compose -p crs_582rjhwn5c -f /tmp/da3y01n0ad/docker-compose.yaml run --rm target_builder            │ │
│ │                                                                                                            │ │
│ │  Network crs_582rjhwn5c_default Creating                                                                   │ │
│ │  Network crs_582rjhwn5c_default Created                                                                    │ │
│ │  Container crs_582rjhwn5c-target_builder-run-5f9d03e48a25 Creating                                         │ │
│ │  Container crs_582rjhwn5c-target_builder-run-5f9d03e48a25 Error response from daemon: Requested CPUs are   │ │
│ │ not available - requested 4-129, available: 0-127                                                          │ │
│ │ Error response from daemon: Requested CPUs are not available - requested 4-129, available: 0-127           │ │
│ │ 📝 Docker compose output:                                                                                  │ │
│ │ ---                                                                                                        │ │
│ │ Command failed with exit code 1:                                                                           │ │
│ │ docker compose -p crs_582rjhwn5c -f /tmp/da3y01n0ad/docker-compose.yaml run --rm target_builder            │ │
│ │                                                                                                            │ │
│ │  Network crs_582rjhwn5c_default Creating                                                                   │ │
│ │  Network crs_582rjhwn5c_default Created                                                                    │ │
│ │  Container crs_582rjhwn5c-target_builder-run-5f9d03e48a25 Creating                                         │ │
│ │  Container crs_582rjhwn5c-target_builder-run-5f9d03e48a25 Error response from daemon: Requested CPUs are   │ │
│ │ not available - requested 4-129, available: 0-127                                                          │ │
│ │ Error response from daemon: Requested CPUs are not available - requested 4-129, available: 0-127           │ │
│ │ ---                                                                                                        │ │
│ │ 📝 Docker compose file contents:                                                                           │ │
│ │ ---                                                                                                        │ │
│ │ services:                                                                                                  │ │
│ │   target_builder:                                                                                          │ │
│ │     privileged: true                                                                                       │ │
│ │     shm_size: 2g                                                                                           │ │
│ │     environment:                                                                                           │ │
│ │       - HELPER=True                                                                                        │ │
│ │       - RUN_FUZZER_MODE=interactive                                                                        │ │
│ │       - FUZZING_ENGINE=libfuzzer                                                                           │ │
│ │       - SANITIZER=address                                                                                  │ │
│ │       - ARCHITECTURE=x86_64                                                                                │ │
│ │       - PROJECT_NAME=sanity-mock-c-delta-01                                                                │ │
│ │       - FUZZING_LANGUAGE=c                                                                                 │ │
│ │       - OSS_CRS_RUN_ENV_TYPE=local                                                                         │ │
│ │       - OSS_CRS_BUILD_ID=1775158626g9                                                                      │ │
│ │       - OSS_CRS_BUILD_OUT_DIR=/OSS_CRS_BUILD_OUT_DIR                                                       │ │
│ │       - OSS_CRS_TARGET=sanity-mock-c-delta-01                                                              │ │
│ │       - OSS_CRS_PROJ_PATH=/OSS_CRS_PROJ_PATH                                                               │ │
│ │       - OSS_CRS_TARGET_PROJ_DIR=/OSS_CRS_PROJ_PATH                                                         │ │
│ │       - OSS_CRS_REPO_PATH=/src/mock-c                                                                      │ │
│ │     build:                                                                                                 │ │
│ │       context: /home/andrew/post/oss-crs-tkqdldk/.oss-crs-workdir/crs_compose/crs_src/crs-libfuzzer        │ │
│ │       dockerfile:                                                                                          │ │
│ │ /home/andrew/post/oss-crs-tkqdldk/.oss-crs-workdir/crs_compose/crs_src/crs-libfuzzer/oss-crs/dockerfiles/b │ │
│ │ uilder.Dockerfile                                                                                          │ │
│ │       args:                                                                                                │ │
│ │         - target_base_image=sanity-mock-c-delta-01:4c6d77cdc8f0                                            │ │
│ │         - crs_version=1.0.0                                                                                │ │
│ │       additional_contexts:                                                                                 │ │
│ │         libcrs: /home/andrew/post/oss-crs-tkqdldk/libCRS                                                   │ │
│ │     cpuset: "4-129"                                                                                        │ │
│ │     mem_limit: "16G"                                                                                       │ │
│ │     volumes:                                                                                               │ │
│ │       -                                                                                                    │ │
│ │ /home/andrew/post/oss-crs-tkqdldk/.oss-crs-workdir/crs_compose/43e5a06b0d32/address/builds/1775158626g9/cr │ │
│ │ s/crs-libfuzzer/sanity-mock-c-delta-01_4c6d77cdc8f0/BUILD_OUT_DIR:/OSS_CRS_BUILD_OUT_DIR                   │ │
│ │ ---                                                                                                        │ │
│ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ ╭─────────────────────────────────────────────── Error: build ───────────────────────────────────────────────╮ │
│ │ Command failed with exit code 1:                                                                           │ │
│ │ docker compose -p crs_582rjhwn5c -f /tmp/da3y01n0ad/docker-compose.yaml run --rm target_builder            │ │
│ │                                                                                                            │ │
│ │  Network crs_582rjhwn5c_default Creating                                                                   │ │
│ │  Network crs_582rjhwn5c_default Created                                                                    │ │
│ │  Container crs_582rjhwn5c-target_builder-run-5f9d03e48a25 Creating                                         │ │
│ │  Container crs_582rjhwn5c-target_builder-run-5f9d03e48a25 Error response from daemon: Requested CPUs are   │ │
│ │ not available - requested 4-129, available: 0-127                                                          │ │
│ │ Error response from daemon: Requested CPUs are not available - requested 4-129, available: 0-127           │ │
│ │ 📝 Docker compose output:                                                                                  │ │
│ │ ---                                                                                                        │ │
│ │ Command failed with exit code 1:                                                                           │ │
│ │ docker compose -p crs_582rjhwn5c -f /tmp/da3y01n0ad/docker-compose.yaml run --rm target_builder            │ │
│ │                                                                                                            │ │
│ │  Network crs_582rjhwn5c_default Creating                                                                   │ │
│ │  Network crs_582rjhwn5c_default Created                                                                    │ │
│ │  Container crs_582rjhwn5c-target_builder-run-5f9d03e48a25 Creating                                         │ │
│ │  Container crs_582rjhwn5c-target_builder-run-5f9d03e48a25 Error response from daemon: Requested CPUs are   │ │
│ │ not available - requested 4-129, available: 0-127                                                          │ │
│ │ Error response from daemon: Requested CPUs are not available - requested 4-129, available: 0-127           │ │
│ │ ---                                                                                                        │ │
│ │ 📝 Docker compose file contents:                                                                           │ │
│ │ ---                                                                                                        │ │
│ │ services:                                                                                                  │ │
│ │   target_builder:                                                                                          │ │
│ │     privileged: true                                                                                       │ │
│ │     shm_size: 2g                                                                                           │ │
│ │     environment:                                                                                           │ │
│ │       - HELPER=True                                                                                        │ │
│ │       - RUN_FUZZER_MODE=interactive                                                                        │ │
│ │       - FUZZING_ENGINE=libfuzzer                                                                           │ │
│ │       - SANITIZER=address                                                                                  │ │
│ │       - ARCHITECTURE=x86_64                                                                                │ │
│ │       - PROJECT_NAME=sanity-mock-c-delta-01                                                                │ │
│ │       - FUZZING_LANGUAGE=c                                                                                 │ │
│ │       - OSS_CRS_RUN_ENV_TYPE=local                                                                         │ │
│ │       - OSS_CRS_BUILD_ID=1775158626g9                                                                      │ │
│ │       - OSS_CRS_BUILD_OUT_DIR=/OSS_CRS_BUILD_OUT_DIR                                                       │ │
│ │       - OSS_CRS_TARGET=sanity-mock-c-delta-01                                                              │ │
│ │       - OSS_CRS_PROJ_PATH=/OSS_CRS_PROJ_PATH                                                               │ │
│ │       - OSS_CRS_TARGET_PROJ_DIR=/OSS_CRS_PROJ_PATH                                                         │ │
│ │       - OSS_CRS_REPO_PATH=/src/mock-c                                                                      │ │
│ │     build:                                                                                                 │ │
│ │       context: /home/andrew/post/oss-crs-tkqdldk/.oss-crs-workdir/crs_compose/crs_src/crs-libfuzzer        │ │
│ │       dockerfile:                                                                                          │ │
│ │ /home/andrew/post/oss-crs-tkqdldk/.oss-crs-workdir/crs_compose/crs_src/crs-libfuzzer/oss-crs/dockerfiles/b │ │
│ │ uilder.Dockerfile                                                                                          │ │
│ │       args:                                                                                                │ │
│ │         - target_base_image=sanity-mock-c-delta-01:4c6d77cdc8f0                                            │ │
│ │         - crs_version=1.0.0                                                                                │ │
│ │       additional_contexts:                                                                                 │ │
│ │         libcrs: /home/andrew/post/oss-crs-tkqdldk/libCRS                                                   │ │
│ │     cpuset: "4-129"                                                                                        │ │
│ │     mem_limit: "16G"                                                                                       │ │
│ │     volumes:                                                                                               │ │
│ │       -                                                                                                    │ │
│ │ /home/andrew/post/oss-crs-tkqdldk/.oss-crs-workdir/crs_compose/43e5a06b0d32/address/builds/1775158626g9/cr │ │
│ │ s/crs-libfuzzer/sanity-mock-c-delta-01_4c6d77cdc8f0/BUILD_OUT_DIR:/OSS_CRS_BUILD_OUT_DIR                   │ │
│ │ ---                                                                                                        │ │
│ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ ╭─────────────────────────── Error: Build target by executing the docker compose ────────────────────────────╮ │
│ │ Command failed with exit code 1:                                                                           │ │
│ │ docker compose -p crs_582rjhwn5c -f /tmp/da3y01n0ad/docker-compose.yaml run --rm target_builder            │ │
│ │                                                                                                            │ │
│ │  Network crs_582rjhwn5c_default Creating                                                                   │ │
│ │  Network crs_582rjhwn5c_default Created                                                                    │ │
│ │  Container crs_582rjhwn5c-target_builder-run-5f9d03e48a25 Creating                                         │ │
│ │  Container crs_582rjhwn5c-target_builder-run-5f9d03e48a25 Error response from daemon: Requested CPUs are   │ │
│ │ not available - requested 4-129, available: 0-127                                                          │ │
│ │ Error response from daemon: Requested CPUs are not available - requested 4-129, available: 0-127           │ │
│ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ │
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

@tkqdldk

tkqdldk commented Apr 8, 2026

Copy link
Copy Markdown
Author

Hm I'm not seeing the error messages implemented in your PR in my output. The build does indeed abort, but that's because of Docker's error handling and happens after docker compose gets run.

I can take a deeper look at what we're missing after the weekend, if needed.

% uv run oss-crs build-target --compose-file example/crs-libfuzzer/compose.yaml --fuzz-proj-path ~/post/CRSBench/benchmarks/sanity-mock-c-delta-01
╭─────────────────────────────────────────── Init CRS: crs-libfuzzer ────────────────────────────────────────────╮
│          Task         Status                                                                                   │
│   ✓      Git Fetch    Success                                                                                  │
│   ✓      Git Reset    Success                                                                                  │
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭─────────────────────────────────────────── CRS Compose Build Target ───────────────────────────────────────────╮
│          Task                                                           Status                                 │
│   ✗      crs-libfuzzer                                                  Failed                                 │
│            └─ build                                                     Failed                                 │
│              └─ Prepare docker compose file                             Success                                │
│              └─ Prepare docker images defined in docker compose file    Success                                │
│              └─ Build target by executing the docker compose            Failed                                 │
│              └─ Check outputs                                           Pending                                │
│              └─ 🧹 Cleanup Docker Compose                               Success                                │
│ ╭─────────────────────────────────────────── Error: crs-libfuzzer ───────────────────────────────────────────╮ │
│ │ Command failed with exit code 1:                                                                           │ │
│ │ docker compose -p crs_582rjhwn5c -f /tmp/da3y01n0ad/docker-compose.yaml run --rm target_builder            │ │
│ │                                                                                                            │ │
│ │  Network crs_582rjhwn5c_default Creating                                                                   │ │
│ │  Network crs_582rjhwn5c_default Created                                                                    │ │
│ │  Container crs_582rjhwn5c-target_builder-run-5f9d03e48a25 Creating                                         │ │
│ │  Container crs_582rjhwn5c-target_builder-run-5f9d03e48a25 Error response from daemon: Requested CPUs are   │ │
│ │ not available - requested 4-129, available: 0-127                                                          │ │
│ │ Error response from daemon: Requested CPUs are not available - requested 4-129, available: 0-127           │ │
│ │ 📝 Docker compose output:                                                                                  │ │
│ │ ---                                                                                                        │ │
│ │ Command failed with exit code 1:                                                                           │ │
│ │ docker compose -p crs_582rjhwn5c -f /tmp/da3y01n0ad/docker-compose.yaml run --rm target_builder            │ │
│ │                                                                                                            │ │
│ │  Network crs_582rjhwn5c_default Creating                                                                   │ │
│ │  Network crs_582rjhwn5c_default Created                                                                    │ │
│ │  Container crs_582rjhwn5c-target_builder-run-5f9d03e48a25 Creating                                         │ │
│ │  Container crs_582rjhwn5c-target_builder-run-5f9d03e48a25 Error response from daemon: Requested CPUs are   │ │
│ │ not available - requested 4-129, available: 0-127                                                          │ │
│ │ Error response from daemon: Requested CPUs are not available - requested 4-129, available: 0-127           │ │
│ │ ---                                                                                                        │ │
│ │ 📝 Docker compose file contents:                                                                           │ │
│ │ ---                                                                                                        │ │
│ │ services:                                                                                                  │ │
│ │   target_builder:                                                                                          │ │
│ │     privileged: true                                                                                       │ │
│ │     shm_size: 2g                                                                                           │ │
│ │     environment:                                                                                           │ │
│ │       - HELPER=True                                                                                        │ │
│ │       - RUN_FUZZER_MODE=interactive                                                                        │ │
│ │       - FUZZING_ENGINE=libfuzzer                                                                           │ │
│ │       - SANITIZER=address                                                                                  │ │
│ │       - ARCHITECTURE=x86_64                                                                                │ │
│ │       - PROJECT_NAME=sanity-mock-c-delta-01                                                                │ │
│ │       - FUZZING_LANGUAGE=c                                                                                 │ │
│ │       - OSS_CRS_RUN_ENV_TYPE=local                                                                         │ │
│ │       - OSS_CRS_BUILD_ID=1775158626g9                                                                      │ │
│ │       - OSS_CRS_BUILD_OUT_DIR=/OSS_CRS_BUILD_OUT_DIR                                                       │ │
│ │       - OSS_CRS_TARGET=sanity-mock-c-delta-01                                                              │ │
│ │       - OSS_CRS_PROJ_PATH=/OSS_CRS_PROJ_PATH                                                               │ │
│ │       - OSS_CRS_TARGET_PROJ_DIR=/OSS_CRS_PROJ_PATH                                                         │ │
│ │       - OSS_CRS_REPO_PATH=/src/mock-c                                                                      │ │
│ │     build:                                                                                                 │ │
│ │       context: /home/andrew/post/oss-crs-tkqdldk/.oss-crs-workdir/crs_compose/crs_src/crs-libfuzzer        │ │
│ │       dockerfile:                                                                                          │ │
│ │ /home/andrew/post/oss-crs-tkqdldk/.oss-crs-workdir/crs_compose/crs_src/crs-libfuzzer/oss-crs/dockerfiles/b │ │
│ │ uilder.Dockerfile                                                                                          │ │
│ │       args:                                                                                                │ │
│ │         - target_base_image=sanity-mock-c-delta-01:4c6d77cdc8f0                                            │ │
│ │         - crs_version=1.0.0                                                                                │ │
│ │       additional_contexts:                                                                                 │ │
│ │         libcrs: /home/andrew/post/oss-crs-tkqdldk/libCRS                                                   │ │
│ │     cpuset: "4-129"                                                                                        │ │
│ │     mem_limit: "16G"                                                                                       │ │
│ │     volumes:                                                                                               │ │
│ │       -                                                                                                    │ │
│ │ /home/andrew/post/oss-crs-tkqdldk/.oss-crs-workdir/crs_compose/43e5a06b0d32/address/builds/1775158626g9/cr │ │
│ │ s/crs-libfuzzer/sanity-mock-c-delta-01_4c6d77cdc8f0/BUILD_OUT_DIR:/OSS_CRS_BUILD_OUT_DIR                   │ │
│ │ ---                                                                                                        │ │
│ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ ╭─────────────────────────────────────────────── Error: build ───────────────────────────────────────────────╮ │
│ │ Command failed with exit code 1:                                                                           │ │
│ │ docker compose -p crs_582rjhwn5c -f /tmp/da3y01n0ad/docker-compose.yaml run --rm target_builder            │ │
│ │                                                                                                            │ │
│ │  Network crs_582rjhwn5c_default Creating                                                                   │ │
│ │  Network crs_582rjhwn5c_default Created                                                                    │ │
│ │  Container crs_582rjhwn5c-target_builder-run-5f9d03e48a25 Creating                                         │ │
│ │  Container crs_582rjhwn5c-target_builder-run-5f9d03e48a25 Error response from daemon: Requested CPUs are   │ │
│ │ not available - requested 4-129, available: 0-127                                                          │ │
│ │ Error response from daemon: Requested CPUs are not available - requested 4-129, available: 0-127           │ │
│ │ 📝 Docker compose output:                                                                                  │ │
│ │ ---                                                                                                        │ │
│ │ Command failed with exit code 1:                                                                           │ │
│ │ docker compose -p crs_582rjhwn5c -f /tmp/da3y01n0ad/docker-compose.yaml run --rm target_builder            │ │
│ │                                                                                                            │ │
│ │  Network crs_582rjhwn5c_default Creating                                                                   │ │
│ │  Network crs_582rjhwn5c_default Created                                                                    │ │
│ │  Container crs_582rjhwn5c-target_builder-run-5f9d03e48a25 Creating                                         │ │
│ │  Container crs_582rjhwn5c-target_builder-run-5f9d03e48a25 Error response from daemon: Requested CPUs are   │ │
│ │ not available - requested 4-129, available: 0-127                                                          │ │
│ │ Error response from daemon: Requested CPUs are not available - requested 4-129, available: 0-127           │ │
│ │ ---                                                                                                        │ │
│ │ 📝 Docker compose file contents:                                                                           │ │
│ │ ---                                                                                                        │ │
│ │ services:                                                                                                  │ │
│ │   target_builder:                                                                                          │ │
│ │     privileged: true                                                                                       │ │
│ │     shm_size: 2g                                                                                           │ │
│ │     environment:                                                                                           │ │
│ │       - HELPER=True                                                                                        │ │
│ │       - RUN_FUZZER_MODE=interactive                                                                        │ │
│ │       - FUZZING_ENGINE=libfuzzer                                                                           │ │
│ │       - SANITIZER=address                                                                                  │ │
│ │       - ARCHITECTURE=x86_64                                                                                │ │
│ │       - PROJECT_NAME=sanity-mock-c-delta-01                                                                │ │
│ │       - FUZZING_LANGUAGE=c                                                                                 │ │
│ │       - OSS_CRS_RUN_ENV_TYPE=local                                                                         │ │
│ │       - OSS_CRS_BUILD_ID=1775158626g9                                                                      │ │
│ │       - OSS_CRS_BUILD_OUT_DIR=/OSS_CRS_BUILD_OUT_DIR                                                       │ │
│ │       - OSS_CRS_TARGET=sanity-mock-c-delta-01                                                              │ │
│ │       - OSS_CRS_PROJ_PATH=/OSS_CRS_PROJ_PATH                                                               │ │
│ │       - OSS_CRS_TARGET_PROJ_DIR=/OSS_CRS_PROJ_PATH                                                         │ │
│ │       - OSS_CRS_REPO_PATH=/src/mock-c                                                                      │ │
│ │     build:                                                                                                 │ │
│ │       context: /home/andrew/post/oss-crs-tkqdldk/.oss-crs-workdir/crs_compose/crs_src/crs-libfuzzer        │ │
│ │       dockerfile:                                                                                          │ │
│ │ /home/andrew/post/oss-crs-tkqdldk/.oss-crs-workdir/crs_compose/crs_src/crs-libfuzzer/oss-crs/dockerfiles/b │ │
│ │ uilder.Dockerfile                                                                                          │ │
│ │       args:                                                                                                │ │
│ │         - target_base_image=sanity-mock-c-delta-01:4c6d77cdc8f0                                            │ │
│ │         - crs_version=1.0.0                                                                                │ │
│ │       additional_contexts:                                                                                 │ │
│ │         libcrs: /home/andrew/post/oss-crs-tkqdldk/libCRS                                                   │ │
│ │     cpuset: "4-129"                                                                                        │ │
│ │     mem_limit: "16G"                                                                                       │ │
│ │     volumes:                                                                                               │ │
│ │       -                                                                                                    │ │
│ │ /home/andrew/post/oss-crs-tkqdldk/.oss-crs-workdir/crs_compose/43e5a06b0d32/address/builds/1775158626g9/cr │ │
│ │ s/crs-libfuzzer/sanity-mock-c-delta-01_4c6d77cdc8f0/BUILD_OUT_DIR:/OSS_CRS_BUILD_OUT_DIR                   │ │
│ │ ---                                                                                                        │ │
│ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ ╭─────────────────────────── Error: Build target by executing the docker compose ────────────────────────────╮ │
│ │ Command failed with exit code 1:                                                                           │ │
│ │ docker compose -p crs_582rjhwn5c -f /tmp/da3y01n0ad/docker-compose.yaml run --rm target_builder            │ │
│ │                                                                                                            │ │
│ │  Network crs_582rjhwn5c_default Creating                                                                   │ │
│ │  Network crs_582rjhwn5c_default Created                                                                    │ │
│ │  Container crs_582rjhwn5c-target_builder-run-5f9d03e48a25 Creating                                         │ │
│ │  Container crs_582rjhwn5c-target_builder-run-5f9d03e48a25 Error response from daemon: Requested CPUs are   │ │
│ │ not available - requested 4-129, available: 0-127                                                          │ │
│ │ Error response from daemon: Requested CPUs are not available - requested 4-129, available: 0-127           │ │
│ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ │
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

Hi, sorry for the late response, so the validation only runs before run currently, as I understood that would be the only need. I'll extend the check to build-target so the warning shows here too.

@azchin

azchin commented Apr 16, 2026

Copy link
Copy Markdown
Collaborator

Hi, sorry for the delayed feedback as we were working on a big internal refactor. I'll take a proper look this weekend, in the meanwhile could you check the CI failure? In main branch we also now have a uv run verify command (which calls https://github.com/ossf/oss-crs/blob/main/scripts/verify.py) that mimics the "CI / Verify" workflow, so you can verify locally.

@tkqdldk tkqdldk force-pushed the feat/resource-config-warn branch from c55125d to dca9899 Compare April 16, 2026 11:02
@tkqdldk

tkqdldk commented Apr 16, 2026

Copy link
Copy Markdown
Author

No worries ^^ Resolved the CI failure on my part and added the check in the build-target step. Let me know if I need to add or adjust anything once you take a look.

@azchin azchin left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like the check to be placed earlier, and error + terminate.

Comment thread oss_crs/src/crs_compose.py Outdated
resolved_source_path = source_dir

tasks = []
tasks: list[tuple[str, Callable[[MultiTaskProgress], TaskResult]]] = [

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you call _validate_machine_resources near the start of build(), before the target.build_docker_image() gets run? Don't need to adhere to the tasks loop if calling it directly makes it easier.

Comment thread oss_crs/src/crs_compose.py Outdated
memory_check = total_memory_required <= machine_memory

if not cpu_check or not memory_check:
log_warning(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's produce an error instead of warning, and terminate early. Current behavior is I see the warning message, but the docker compose still tries to run.

@azchin

azchin commented Apr 20, 2026

Copy link
Copy Markdown
Collaborator

CI failed b/c of LLM API key not being passed correctly, I'll look into that.

@tkqdldk tkqdldk force-pushed the feat/resource-config-warn branch from 5aa53b2 to 38db6c4 Compare May 6, 2026 15:47
@tkqdldk

tkqdldk commented May 6, 2026

Copy link
Copy Markdown
Author

Hi, sorry for the delay, I was very busy lately. Added the changes according to your comments.

@tkqdldk tkqdldk requested a review from azchin May 6, 2026 16:05
@azchin

azchin commented May 8, 2026

Copy link
Copy Markdown
Collaborator

Looks good to me! There's an integration test failure because it looks like we're overallocating memory somehow.

  • Please double check whether the memory parsing is correct, since I thought we allocated 16GB for the CI machine but the warning in the integration test says "15G"
  • If it's a simple rounding error, then I think it's fine to underestimate our available memory. In which case just apply the following patch to decrease the memory allocated for the builder sidecar integration test CRSs
+++ b/oss_crs/tests/integration/test_builder_sidecar_full.py
@@ -33,11 +33,11 @@ def sidecar_full_compose(tmp_dir):
     content = {
         "run_env": "local",
         "docker_registry": "local",
-        "oss_crs_infra": {"cpuset": "0-3", "memory": "8G"},
+        "oss_crs_infra": {"cpuset": "0-3", "memory": "7G"},
         "builder-sidecar-full": {
             "source": {"local_path": str(CRS_FIXTURE)},
             "cpuset": "0-3",
-            "memory": "8G",
+            "memory": "7G",
         },
     }
     path = tmp_dir / "compose.yaml"
diff --git a/oss_crs/tests/integration/test_builder_sidecar_lite.py b/oss_crs/tests/integration/test_builder_sidecar_lite.py
index 9c71c17..237923b 100644
--- a/oss_crs/tests/integration/test_builder_sidecar_lite.py
+++ b/oss_crs/tests/integration/test_builder_sidecar_lite.py
@@ -36,11 +36,11 @@ def sidecar_lite_compose(tmp_dir):
     content = {
         "run_env": "local",
         "docker_registry": "local",
-        "oss_crs_infra": {"cpuset": "0-3", "memory": "8G"},
+        "oss_crs_infra": {"cpuset": "0-3", "memory": "7G"},
         "builder-sidecar-lite": {
             "source": {"local_path": str(CRS_FIXTURE)},
             "cpuset": "0-3",
-            "memory": "8G",
+            "memory": "7G",
         },
     }
     path = tmp_dir / "compose.yaml"

@azchin

azchin commented May 26, 2026

Copy link
Copy Markdown
Collaborator

Hello @tkqdldk , are you going to continue working on this PR? If you no longer have interest or bandwidth, I'll close the PR and integrate your contributions in another branch + PR so that I can make some modifications.

@tkqdldk

tkqdldk commented May 26, 2026

Copy link
Copy Markdown
Author

Hello @tkqdldk , are you going to continue working on this PR? If you no longer have interest or bandwidth, I'll close the PR and integrate your contributions in another branch + PR so that I can make some modifications.

Hi, sorry again for the delay. It seemed to be a rounding error from integer division the last time I checked. I can still fix it if necessary or if you choose so.

@azchin

azchin commented May 26, 2026

Copy link
Copy Markdown
Collaborator

You can go ahead and fix it. Just wanted to check up on this

@tkqdldk tkqdldk requested a review from azchin June 1, 2026 09:01
@azchin

azchin commented Jun 1, 2026

Copy link
Copy Markdown
Collaborator

Could you check the pyright error? I'll merge as soon as the CI passes, your code looks good.

@tkqdldk

tkqdldk commented Jun 2, 2026

Copy link
Copy Markdown
Author

Hi, I looked through the pyright error outputs and none seem related to the resource check nor the error/termination which follow the failing of the check.

@azchin

azchin commented Jun 2, 2026

Copy link
Copy Markdown
Collaborator

Weird, upstream doesn't have pyright errors. I'll merge main into your branch

for name, crs_cfg in self.config.crs_entries.items()
]

builder_count = sum(1 for crs in self.crs_list if crs.config.is_builder)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think pyright is complaining about this line? is_builder

tkqdldk added 5 commits June 2, 2026 20:40
…ne resources

Signed-off-by: tkqdldk <samia.20.bouchaal@gmail.com>
… memory output

Signed-off-by: tkqdldk <samia.20.bouchaal@gmail.com>
Signed-off-by: tkqdldk <samia.20.bouchaal@gmail.com>
Signed-off-by: tkqdldk <samia.20.bouchaal@gmail.com>
Signed-off-by: tkqdldk <samia.20.bouchaal@gmail.com>
tkqdldk added 3 commits June 2, 2026 20:40
Signed-off-by: tkqdldk <samia.20.bouchaal@gmail.com>
Signed-off-by: tkqdldk <samia.20.bouchaal@gmail.com>
… to integer division

Signed-off-by: tkqdldk <samia.20.bouchaal@gmail.com>
@tkqdldk tkqdldk force-pushed the feat/resource-config-warn branch from 76aa1e2 to 44f6826 Compare June 2, 2026 18:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(bug-finding): warn users if resource config conflicts with actual machine resources

2 participants