Skip to content

fix: give up on a collector that never answers #1

fix: give up on a collector that never answers

fix: give up on a collector that never answers #1

Workflow file for this run

name: ci
on: [push, pull_request]
# The token can read the repository and nothing else.
permissions:
contents: read
# A newer push makes the previous run pointless: stop it rather than pay for it.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
# Pinned so a green run stays reproducible, and so CI tests the toolchain the
# project declares in Cargo.toml rather than whatever is newest today.
RUST: 1.97.1
CARGO_AUDIT: 0.22.2
CARGO_DENY: 0.20.2
CARGO_TERM_COLOR: always
jobs:
# Dependencies first. A crate with a known CVE makes the lint and test results
# irrelevant, so there is no reason to spend the minutes computing them.
security:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
# Pinned to a commit, not a tag: a tag can be moved, a commit cannot.
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Install the auditors
run: |
set -euo pipefail
rustup toolchain install "$RUST" --profile minimal --no-self-update
rustup default "$RUST"
cargo install cargo-audit --version "$CARGO_AUDIT" --locked
cargo install cargo-deny --version "$CARGO_DENY" --locked
# Known vulnerabilities, from the RustSec database.
- run: cargo audit
# What audit does not cover: licences we may not ship, and crates pulled
# from anywhere other than crates.io.
- run: cargo deny check advisories licenses sources bans
lint:
needs: security
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Toolchain
run: |
set -euo pipefail
rustup toolchain install "$RUST" --profile minimal --component rustfmt,clippy --no-self-update
rustup default "$RUST"
- uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }}
- run: cargo fmt --check
- run: cargo clippy --all-targets -- -D warnings
test:
needs: security
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Toolchain
run: |
set -euo pipefail
rustup toolchain install "$RUST" --profile minimal --no-self-update
rustup default "$RUST"
- uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }}
- run: cargo test
# The unit tests never cross the transport, and that is exactly where this
# project has already been wrong once: gRPC's default 4 MiB ceiling sits
# below the 5 MiB flush threshold, so every batch was refused on arrival
# and no test noticed. This job runs the real binaries against each other.
- name: End to end, agent against collector
run: |
set -euo pipefail
cargo build --release
./target/release/collector > /tmp/collector.out 2>&1 &
collector=$!
trap 'kill $collector 2>/dev/null || true' EXIT
sleep 3
kill -0 $collector # a collector that died would let a stale one answer
for log in examples/logs/*.log; do
./target/release/small-agent "$log"
done
# A file whose only line is longer than the cap: the case that used to
# take 823 MB resident and die on the transport.
python3 -c "open('/tmp/noline.log','w').write('k'+'x'*(4*1024*1024)+': 1.0')"
./target/release/small-agent /tmp/noline.log
# A wrong path must be reported as a wrong path, not as a network fault.
if ./target/release/small-agent /tmp/absent.log; then
echo "a missing file should have failed the run" >&2
exit 1
fi
grep -q "records" /tmp/collector.out