-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add bounded local capacity telemetry #73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
Nickfost
wants to merge
9
commits into
main
Choose a base branch
from
feat/issue-50-capacity-telemetry
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
f36cd29
feat: record bounded local capacity telemetry
1b5430d
Merge remote-tracking branch 'origin/main' into feat/issue-50-capacit…
d3ab11b
fix: harden capacity sampling and retention
e76754a
fix: preserve complete capacity observations
4a68764
fix: make capacity lifecycle bounded and optional
60b64ee
fix: stop capacity service on legacy downgrade
a9f3e1b
fix: preserve telemetry lifecycle guarantees
3df6cb4
test: restore current engine fixture after downgrade
71f56fb
fix: propagate capacity stop failures during rollback
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| # Local capacity telemetry | ||
|
|
||
| The dedicated capacity timer checks every 30 seconds and records a sample only while at least one managed runner is active. This interval captures normal jobs shorter than the five-minute health period without increasing heartbeat or status-report traffic. Samples remain on the controller host at `/var/lib/ci-fleet/capacity/samples.jsonl`; they are never added to status-reporting or heartbeat payloads. | ||
|
|
||
| Each sample contains only: | ||
|
|
||
| - timestamp and logical controller/pool ID; | ||
| - interval host CPU utilization plus memory, swap, disk-byte, and inode counters; | ||
| - anonymous per-runner CPU percentage and memory use/limit. | ||
|
|
||
| Container IDs, names, repositories, jobs, logs, environment variables, source, network counters, and credentials are not stored. The history directory must be a root-owned, non-symlink mode-`0700` directory and the file must be mode `0600`. Malformed records are ignored atomically, records older than eight days are discarded even while the pool is idle, and history is compacted from at most 26,000 records back to 24,000 (more than eight days at the scheduled 30-second interval). Normal samples append one record; compaction rewrites only when retention, malformed input, or the rotation threshold requires it. Uninstall removes this fleet-owned local history. Runner-stat failures fail the capacity service and appear in the normal health report instead of being recorded as zero observations. | ||
|
|
||
| ## Weekly report | ||
|
|
||
| Run on the controller host; reads local state only and changes nothing: | ||
|
|
||
| ```bash | ||
| sudo /opt/ci-fleet/current/scripts/health.py capacity-report | ||
| ``` | ||
|
|
||
| The JSON report groups the preceding seven days by logical pool and gives nearest-rank p50/p95 values for every observed host and runner metric, plus sample and anonymous runner-observation counts. An empty report means no managed runner was observed during the period. | ||
|
|
||
| Review the report before changing runner count, per-runner resources, or pool budget. A capacity change still requires its own reviewed private-configuration change; this public repository does not create or modify that external change. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| [Unit] | ||
| Description=Sample local ci-fleet capacity | ||
| After=docker.service | ||
| Requires=docker.service | ||
| ConditionPathExists=/etc/ci-fleet/ci-fleet.env | ||
|
|
||
| [Service] | ||
| Type=oneshot | ||
| ExecStart=/opt/ci-fleet/current/scripts/capacity-sample.sh | ||
| User=root | ||
| Group=root | ||
| NoNewPrivileges=yes | ||
| PrivateTmp=yes | ||
| ProtectHome=yes | ||
| ProtectSystem=strict | ||
| ReadWritePaths=/var/lib/ci-fleet | ||
| LockPersonality=yes | ||
| MemoryDenyWriteExecute=yes | ||
| RestrictAddressFamilies=AF_UNIX | ||
| SystemCallArchitectures=native | ||
| UMask=0077 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| [Unit] | ||
| Description=Sample active ci-fleet capacity every 30 seconds | ||
|
|
||
| [Timer] | ||
| OnActiveSec=15s | ||
| OnUnitActiveSec=30s | ||
| AccuracySec=1s | ||
| Unit=ci-fleet-capacity.service | ||
|
|
||
| [Install] | ||
| WantedBy=timers.target |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| #!/usr/bin/env bash | ||
| set -Eeuo pipefail | ||
|
|
||
| script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) | ||
| environment=/etc/ci-fleet/ci-fleet.env | ||
| args=(capacity-sample) | ||
| if [[ ${CI_FLEET_TESTING:-0} == 1 && -n ${CI_FLEET_ROOT_PREFIX:-} ]]; then | ||
| environment="$CI_FLEET_ROOT_PREFIX/etc/ci-fleet/ci-fleet.env" | ||
| args+=(--root "$CI_FLEET_ROOT_PREFIX" --history "$CI_FLEET_ROOT_PREFIX/var/lib/ci-fleet/capacity/samples.jsonl") | ||
| fi | ||
| [[ -r $environment ]] || { printf 'CRITICAL capacity_configuration_missing\n' >&2; exit 2; } | ||
| set -a | ||
| # shellcheck disable=SC1090 | ||
| . "$environment" | ||
| set +a | ||
| exec python3 "$script_dir/health.py" "${args[@]}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.