mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-11-30 01:32:00 +01:00
CodeQL flags actions/cache-poisoning/poisonable-step (alerts #369, #370, and #371) on memory-regression.yml because all three comparison jobs pass needs.resolve-stable.outputs.sha directly into actions/checkout ref before running the comparison script. Check out only the workflow's own main commit with actions/checkout, run cache-free Go setup first, and then fetch the validated stable vX.Y.Z tag from rcourtman/Pulse into baseline after verifying that the peeled tag commit matches the pinned baseline SHA. Contract-Neutral: Hardens baseline checkout in the synthetic memory watch workflow only. Workloads, RSS thresholds, release, and product contracts are unchanged. Change-source: pulse-maintainer
373 lines
16 KiB
YAML
373 lines
16 KiB
YAML
name: Memory Regression Watch
|
|
|
|
# Pulse's resident memory rose release after release without anything noticing
|
|
# (#1803): a 256 MB LXC that ran v5 for a year needed 1 GB by v6.3. Nothing
|
|
# compared memory across versions, and part of the growth sat outside the Go
|
|
# heap, where heap-only tests cannot see it. This watch builds the latest stable
|
|
# release and main from source, runs both against the same small mock estate,
|
|
# and compares resident memory split into the Go heap, memory outside Go and
|
|
# file pages. Both heap profiles and their difference are uploaded, so a failure
|
|
# names what grew. SQLite page caches only fill on large databases, which a
|
|
# short mock run never builds; pkg/db's page cache tests guard those instead.
|
|
# The compare-agents job repeats the comparison on a real Pulse driven by
|
|
# synthetic agents, because mock mode never reaches the agent report path.
|
|
# The compare-proxmox job repeats it against synthetic Proxmox VE and PBS
|
|
# servers, because neither mock nor agents exercises PVE/PBS polling,
|
|
# recovery.db ingestion, protection posture refreshes, or PBS backup cloning.
|
|
on:
|
|
schedule:
|
|
- cron: '41 4 * * *'
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
concurrency:
|
|
group: memory-regression
|
|
cancel-in-progress: false
|
|
|
|
jobs:
|
|
resolve-stable:
|
|
name: Pin the stable comparison source
|
|
# A manual run is still the main-vs-stable watch. Do not send other refs
|
|
# or forks to jobs that build and run the checked-out source.
|
|
if: >-
|
|
github.repository == 'rcourtman/Pulse' && github.ref == 'refs/heads/main' &&
|
|
(github.event_name == 'schedule' || github.event_name == 'workflow_dispatch')
|
|
runs-on: ubuntu-24.04
|
|
timeout-minutes: 5
|
|
outputs:
|
|
tag: ${{ steps.stable.outputs.tag }}
|
|
sha: ${{ steps.stable.outputs.sha }}
|
|
steps:
|
|
- name: Resolve the exact stable release
|
|
id: stable
|
|
env:
|
|
GH_TOKEN: ${{ github.token }}
|
|
run: |
|
|
set -euo pipefail
|
|
release="$(gh api "repos/${GITHUB_REPOSITORY}/releases/latest")"
|
|
tag="$(jq -er '
|
|
select(.draft == false and .prerelease == false and .immutable == true)
|
|
| .tag_name | strings
|
|
' <<<"$release")" || {
|
|
echo "The latest release is not a published immutable stable release." >&2
|
|
exit 1
|
|
}
|
|
[[ "$tag" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]] || { echo "No stable release tag found." >&2; exit 1; }
|
|
|
|
ref="$(gh api "repos/${GITHUB_REPOSITORY}/git/ref/tags/$tag")"
|
|
test "$(jq -er '.ref' <<<"$ref")" = "refs/tags/$tag"
|
|
type="$(jq -er '.object.type' <<<"$ref")"
|
|
sha="$(jq -er '.object.sha' <<<"$ref")"
|
|
[[ "$sha" =~ ^[0-9a-f]{40}$ ]] || exit 1
|
|
if [[ "$type" == tag ]]; then
|
|
object="$(gh api "repos/${GITHUB_REPOSITORY}/git/tags/$sha")"
|
|
test "$(jq -er '.sha' <<<"$object")" = "$sha"
|
|
test "$(jq -er '.tag' <<<"$object")" = "$tag"
|
|
type="$(jq -er '.object.type' <<<"$object")"
|
|
sha="$(jq -er '.object.sha' <<<"$object")"
|
|
fi
|
|
[[ "$type" == commit && "$sha" =~ ^[0-9a-f]{40}$ ]] || {
|
|
echo "The stable tag did not resolve to a commit." >&2
|
|
exit 1
|
|
}
|
|
printf 'tag=%s\nsha=%s\n' "$tag" "$sha" >> "$GITHUB_OUTPUT"
|
|
printf 'Baseline: %s (%s)\n' "$tag" "$sha"
|
|
|
|
compare:
|
|
name: Compare memory with the latest stable release
|
|
needs: resolve-stable
|
|
runs-on: ubuntu-24.04
|
|
timeout-minutes: 45
|
|
steps:
|
|
- name: Checkout candidate
|
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
with:
|
|
ref: ${{ github.sha }}
|
|
path: candidate
|
|
persist-credentials: false
|
|
|
|
- name: Set up Go
|
|
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
|
|
with:
|
|
go-version-file: candidate/go.mod
|
|
cache: false
|
|
|
|
- name: Checkout verified stable baseline
|
|
env:
|
|
BASELINE_TAG: ${{ needs.resolve-stable.outputs.tag }}
|
|
BASELINE_SHA: ${{ needs.resolve-stable.outputs.sha }}
|
|
run: |
|
|
set -euo pipefail
|
|
[[ "${BASELINE_TAG}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]] || {
|
|
echo "Invalid stable release tag: ${BASELINE_TAG}" >&2
|
|
exit 1
|
|
}
|
|
[[ "${BASELINE_SHA}" =~ ^[0-9a-f]{40}$ ]] || {
|
|
echo "Invalid stable release commit: ${BASELINE_SHA}" >&2
|
|
exit 1
|
|
}
|
|
[[ ! -e baseline ]] || {
|
|
echo "Baseline checkout directory already exists." >&2
|
|
exit 1
|
|
}
|
|
git -c init.defaultBranch=main init baseline
|
|
git -C baseline fetch --no-tags --no-recurse-submodules --depth=1 \
|
|
https://github.com/rcourtman/Pulse.git \
|
|
"refs/tags/${BASELINE_TAG}:refs/remotes/baseline/${BASELINE_TAG}"
|
|
resolved="$(git -C baseline rev-parse --verify "refs/remotes/baseline/${BASELINE_TAG}^{commit}")"
|
|
if [[ "${resolved}" != "${BASELINE_SHA}" ]]; then
|
|
echo "Stable tag ${BASELINE_TAG} resolved to ${resolved}, expected ${BASELINE_SHA}." >&2
|
|
exit 1
|
|
fi
|
|
git -C baseline checkout --detach "${resolved}"
|
|
|
|
- name: Measure both builds
|
|
env:
|
|
# Each tree builds with the toolchain its own go.mod names.
|
|
GOTOOLCHAIN: auto
|
|
PULSE_MEMORY_DURATION: '900'
|
|
BASELINE_TAG: ${{ needs.resolve-stable.outputs.tag }}
|
|
BASELINE_SHA: ${{ needs.resolve-stable.outputs.sha }}
|
|
run: |
|
|
bash candidate/scripts/memory/compare_release_memory.sh baseline candidate "$RUNNER_TEMP/memory" \
|
|
"${BASELINE_TAG:?}" "${BASELINE_SHA:?}" "${GITHUB_SHA:?}"
|
|
|
|
- name: Publish the comparison
|
|
if: ${{ !cancelled() }}
|
|
run: |
|
|
if [[ -f "$RUNNER_TEMP/memory/summary.md" ]]; then
|
|
cat "$RUNNER_TEMP/memory/summary.md" >> "$GITHUB_STEP_SUMMARY"
|
|
else
|
|
echo "The measurement did not finish; see the run logs." >> "$GITHUB_STEP_SUMMARY"
|
|
fi
|
|
|
|
- name: Upload memory evidence
|
|
if: ${{ !cancelled() }}
|
|
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
|
|
with:
|
|
name: memory-regression
|
|
path: |
|
|
${{ runner.temp }}/memory/*.tsv
|
|
${{ runner.temp }}/memory/*.pb.gz
|
|
${{ runner.temp }}/memory/heap-growth.txt
|
|
${{ runner.temp }}/memory/summary.md
|
|
${{ runner.temp }}/memory/result.json
|
|
${{ runner.temp }}/memory/run-*.log
|
|
if-no-files-found: ignore
|
|
retention-days: 30
|
|
|
|
# The same comparison on a real Pulse fed by synthetic Unified Agents and one
|
|
# connected dashboard (scripts/memory/agent_load.py). Mock mode drops pushed
|
|
# agent reports, so only this estate reaches the per-report registry refresh
|
|
# and broadcast cost #2199 measured. It reports without gating until its noise
|
|
# is known, and the scheduled reporter below does not read it, so its result
|
|
# never opens or comments on the memory watch issue.
|
|
compare-agents:
|
|
name: Compare an agent estate with the latest stable release
|
|
needs: resolve-stable
|
|
runs-on: ubuntu-24.04
|
|
timeout-minutes: 45
|
|
steps:
|
|
- name: Checkout candidate
|
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
with:
|
|
ref: ${{ github.sha }}
|
|
path: candidate
|
|
persist-credentials: false
|
|
|
|
- name: Set up Go
|
|
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
|
|
with:
|
|
go-version-file: candidate/go.mod
|
|
cache: false
|
|
|
|
- name: Checkout verified stable baseline
|
|
env:
|
|
BASELINE_TAG: ${{ needs.resolve-stable.outputs.tag }}
|
|
BASELINE_SHA: ${{ needs.resolve-stable.outputs.sha }}
|
|
run: |
|
|
set -euo pipefail
|
|
[[ "${BASELINE_TAG}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]] || {
|
|
echo "Invalid stable release tag: ${BASELINE_TAG}" >&2
|
|
exit 1
|
|
}
|
|
[[ "${BASELINE_SHA}" =~ ^[0-9a-f]{40}$ ]] || {
|
|
echo "Invalid stable release commit: ${BASELINE_SHA}" >&2
|
|
exit 1
|
|
}
|
|
[[ ! -e baseline ]] || {
|
|
echo "Baseline checkout directory already exists." >&2
|
|
exit 1
|
|
}
|
|
git -c init.defaultBranch=main init baseline
|
|
git -C baseline fetch --no-tags --no-recurse-submodules --depth=1 \
|
|
https://github.com/rcourtman/Pulse.git \
|
|
"refs/tags/${BASELINE_TAG}:refs/remotes/baseline/${BASELINE_TAG}"
|
|
resolved="$(git -C baseline rev-parse --verify "refs/remotes/baseline/${BASELINE_TAG}^{commit}")"
|
|
if [[ "${resolved}" != "${BASELINE_SHA}" ]]; then
|
|
echo "Stable tag ${BASELINE_TAG} resolved to ${resolved}, expected ${BASELINE_SHA}." >&2
|
|
exit 1
|
|
fi
|
|
git -C baseline checkout --detach "${resolved}"
|
|
|
|
- name: Measure both builds under agent load
|
|
env:
|
|
GOTOOLCHAIN: auto
|
|
PULSE_MEMORY_DURATION: '900'
|
|
PULSE_FOOTPRINT_ESTATE: agents
|
|
PULSE_MEMORY_GATE: '0'
|
|
BASELINE_TAG: ${{ needs.resolve-stable.outputs.tag }}
|
|
BASELINE_SHA: ${{ needs.resolve-stable.outputs.sha }}
|
|
run: |
|
|
bash candidate/scripts/memory/compare_release_memory.sh baseline candidate "$RUNNER_TEMP/memory-agents" \
|
|
"${BASELINE_TAG:?}" "${BASELINE_SHA:?}" "${GITHUB_SHA:?}"
|
|
|
|
- name: Publish the comparison
|
|
if: ${{ !cancelled() }}
|
|
run: |
|
|
if [[ -f "$RUNNER_TEMP/memory-agents/summary.md" ]]; then
|
|
cat "$RUNNER_TEMP/memory-agents/summary.md" >> "$GITHUB_STEP_SUMMARY"
|
|
else
|
|
echo "The agent estate measurement did not finish; see the run logs." >> "$GITHUB_STEP_SUMMARY"
|
|
fi
|
|
|
|
- name: Upload agent estate evidence
|
|
if: ${{ !cancelled() }}
|
|
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
|
|
with:
|
|
name: memory-regression-agents
|
|
path: |
|
|
${{ runner.temp }}/memory-agents/*.tsv
|
|
${{ runner.temp }}/memory-agents/*.pb.gz
|
|
${{ runner.temp }}/memory-agents/heap-growth.txt
|
|
${{ runner.temp }}/memory-agents/summary.md
|
|
${{ runner.temp }}/memory-agents/result.json
|
|
${{ runner.temp }}/memory-agents/agents-*.json
|
|
${{ runner.temp }}/memory-agents/agents-*.log
|
|
${{ runner.temp }}/memory-agents/run-*.log
|
|
if-no-files-found: ignore
|
|
retention-days: 30
|
|
|
|
# The same comparison on a real Pulse polling a synthetic 3-node Proxmox VE
|
|
# cluster (35 guests), 2 PBS servers (~5,250 snapshots), and one connected
|
|
# dashboard (scripts/memory/proxmox_load.py). Mock mode and the agents estate
|
|
# never exercise PVE/PBS polling, recovery.db ingestion, protection posture
|
|
# refreshes, or PBS backup cloning (#1803). Reports without gating until its
|
|
# noise is known; the scheduled reporter below reads only the mock job.
|
|
compare-proxmox:
|
|
name: Compare a Proxmox + PBS estate with the latest stable release
|
|
needs: resolve-stable
|
|
runs-on: ubuntu-24.04
|
|
timeout-minutes: 45
|
|
steps:
|
|
- name: Checkout candidate
|
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
with:
|
|
ref: ${{ github.sha }}
|
|
path: candidate
|
|
persist-credentials: false
|
|
|
|
- name: Set up Go
|
|
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
|
|
with:
|
|
go-version-file: candidate/go.mod
|
|
cache: false
|
|
|
|
- name: Checkout verified stable baseline
|
|
env:
|
|
BASELINE_TAG: ${{ needs.resolve-stable.outputs.tag }}
|
|
BASELINE_SHA: ${{ needs.resolve-stable.outputs.sha }}
|
|
run: |
|
|
set -euo pipefail
|
|
[[ "${BASELINE_TAG}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]] || {
|
|
echo "Invalid stable release tag: ${BASELINE_TAG}" >&2
|
|
exit 1
|
|
}
|
|
[[ "${BASELINE_SHA}" =~ ^[0-9a-f]{40}$ ]] || {
|
|
echo "Invalid stable release commit: ${BASELINE_SHA}" >&2
|
|
exit 1
|
|
}
|
|
[[ ! -e baseline ]] || {
|
|
echo "Baseline checkout directory already exists." >&2
|
|
exit 1
|
|
}
|
|
git -c init.defaultBranch=main init baseline
|
|
git -C baseline fetch --no-tags --no-recurse-submodules --depth=1 \
|
|
https://github.com/rcourtman/Pulse.git \
|
|
"refs/tags/${BASELINE_TAG}:refs/remotes/baseline/${BASELINE_TAG}"
|
|
resolved="$(git -C baseline rev-parse --verify "refs/remotes/baseline/${BASELINE_TAG}^{commit}")"
|
|
if [[ "${resolved}" != "${BASELINE_SHA}" ]]; then
|
|
echo "Stable tag ${BASELINE_TAG} resolved to ${resolved}, expected ${BASELINE_SHA}." >&2
|
|
exit 1
|
|
fi
|
|
git -C baseline checkout --detach "${resolved}"
|
|
|
|
- name: Measure both builds under Proxmox + PBS load
|
|
env:
|
|
GOTOOLCHAIN: auto
|
|
PULSE_MEMORY_DURATION: '900'
|
|
PULSE_FOOTPRINT_ESTATE: proxmox
|
|
PULSE_MEMORY_GATE: '0'
|
|
BASELINE_TAG: ${{ needs.resolve-stable.outputs.tag }}
|
|
BASELINE_SHA: ${{ needs.resolve-stable.outputs.sha }}
|
|
run: |
|
|
bash candidate/scripts/memory/compare_release_memory.sh baseline candidate "$RUNNER_TEMP/memory-proxmox" \
|
|
"${BASELINE_TAG:?}" "${BASELINE_SHA:?}" "${GITHUB_SHA:?}"
|
|
|
|
- name: Publish the comparison
|
|
if: ${{ !cancelled() }}
|
|
run: |
|
|
if [[ -f "$RUNNER_TEMP/memory-proxmox/summary.md" ]]; then
|
|
cat "$RUNNER_TEMP/memory-proxmox/summary.md" >> "$GITHUB_STEP_SUMMARY"
|
|
else
|
|
echo "The Proxmox estate measurement did not finish; see the run logs." >> "$GITHUB_STEP_SUMMARY"
|
|
fi
|
|
|
|
- name: Upload Proxmox estate evidence
|
|
if: ${{ !cancelled() }}
|
|
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
|
|
with:
|
|
name: memory-regression-proxmox
|
|
path: |
|
|
${{ runner.temp }}/memory-proxmox/*.tsv
|
|
${{ runner.temp }}/memory-proxmox/*.pb.gz
|
|
${{ runner.temp }}/memory-proxmox/heap-growth.txt
|
|
${{ runner.temp }}/memory-proxmox/summary.md
|
|
${{ runner.temp }}/memory-proxmox/result.json
|
|
${{ runner.temp }}/memory-proxmox/proxmox-*.json
|
|
${{ runner.temp }}/memory-proxmox/proxmox-*.log
|
|
${{ runner.temp }}/memory-proxmox/run-*.log
|
|
if-no-files-found: ignore
|
|
retention-days: 30
|
|
|
|
# Report only marked, untouched watch issues. A passing check is not
|
|
# resolution of a human report; recovery comments never close issues.
|
|
report-scheduled-result:
|
|
name: Report scheduled result
|
|
needs: [resolve-stable, compare]
|
|
if: >-
|
|
${{ always() && github.repository == 'rcourtman/Pulse' &&
|
|
github.ref == 'refs/heads/main' && github.event_name == 'schedule' }}
|
|
runs-on: ubuntu-24.04
|
|
timeout-minutes: 5
|
|
permissions:
|
|
contents: read
|
|
issues: write
|
|
steps:
|
|
- name: Checkout exact reporter source
|
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
with:
|
|
ref: ${{ github.sha }}
|
|
persist-credentials: false
|
|
|
|
- name: Report the watch observation without resolving issues
|
|
shell: bash
|
|
env:
|
|
GH_TOKEN: ${{ github.token }}
|
|
GH_REPO: ${{ github.repository }}
|
|
# A failed shared lookup used to fail inside the mock comparison.
|
|
RESULT: ${{ needs.resolve-stable.result == 'success' && needs.compare.result || needs.resolve-stable.result }}
|
|
run: python3 .github/scripts/report-ci-watch.py memory "$RESULT"
|