mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-06 19:01:54 +00:00
`INFINITO_PACKAGE_CACHE_MAX_AGE_MIN` was 129600 (90 days), 13× longer than the 7-day `Valid-Until` window Debian and Ubuntu generate by default in their apt `Release` files. Nexus held cached `Release` manifests for 90 days, so once the upstream `Valid-Until` elapsed the manifest stayed in the cache for another ~83 days and every Docker build that ran `apt-get update` against the package-cache aborted with E: Release file for http://deb.debian.org/debian/dists/.../InRelease is expired (invalid since 5h 30min 54s). Drop the default to 8640 minutes (6 days). Stays one day below the 7-day `Valid-Until` so Nexus always re-validates the cached `Release` against upstream before apt would see it expired. The single value still applies to every proxy repo (apt, yum, pypi, npm, gem, go, helm, raw-*), but the `Valid-Until` enforcement only exists in apt — for the other repos the change merely makes the cache 84 days fresher instead of staler, no regression. Update both docs sites that document the default: - docs/contributing/artefact/files/compose.yml.md (env-var table) - docs/contributing/environment/cache.md (operator narrative) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
77 lines
3.2 KiB
Bash
Executable File
77 lines
3.2 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# shellcheck shell=bash
|
|
# Package-cache env defaults. See docs/contributing/environment/cache.md.
|
|
|
|
set -euo pipefail
|
|
|
|
: "${INFINITO_PACKAGE_CACHE_HOST_PATH:=/var/cache/infinito/core/cache/package/data}"
|
|
export INFINITO_PACKAGE_CACHE_HOST_PATH
|
|
|
|
# JVM heap: half free RAM, capped at 2g, floor 1g (Nexus 3 OSS minimum).
|
|
if [[ -z "${INFINITO_PACKAGE_CACHE_HEAP:-}" ]]; then
|
|
_pc_avail_ram_mb="$(awk '/^MemAvailable:/ {print int($2/1024)}' /proc/meminfo 2>/dev/null || echo 0)"
|
|
if [[ "${_pc_avail_ram_mb}" -le 0 ]]; then
|
|
_pc_heap_gb=1
|
|
else
|
|
_pc_heap_gb=$((_pc_avail_ram_mb / 2048))
|
|
if [[ "${_pc_heap_gb}" -lt 1 ]]; then _pc_heap_gb=1; fi
|
|
if [[ "${_pc_heap_gb}" -gt 2 ]]; then _pc_heap_gb=2; fi
|
|
fi
|
|
INFINITO_PACKAGE_CACHE_HEAP="${_pc_heap_gb}g"
|
|
unset _pc_avail_ram_mb _pc_heap_gb
|
|
fi
|
|
export INFINITO_PACKAGE_CACHE_HEAP
|
|
|
|
if [[ -z "${INFINITO_PACKAGE_CACHE_DIRECT_MEM:-}" ]]; then
|
|
INFINITO_PACKAGE_CACHE_DIRECT_MEM="${INFINITO_PACKAGE_CACHE_HEAP}"
|
|
fi
|
|
export INFINITO_PACKAGE_CACHE_DIRECT_MEM
|
|
|
|
# Blobstore quota: half free disk at cache path, floor 2g.
|
|
if [[ -z "${INFINITO_PACKAGE_CACHE_BLOBSTORE_MAX:-}" ]]; then
|
|
_pc_path="${INFINITO_PACKAGE_CACHE_HOST_PATH}"
|
|
while [[ ! -d "${_pc_path}" && "${_pc_path}" != "/" && "${_pc_path}" != "." ]]; do
|
|
_pc_path="$(dirname "${_pc_path}")"
|
|
done
|
|
_pc_avail_gb="$(df --output=avail -B1G "${_pc_path}" 2>/dev/null | awk 'NR==2 {print $1+0}')"
|
|
if [[ -z "${_pc_avail_gb}" || "${_pc_avail_gb}" -le 0 ]]; then _pc_avail_gb=4; fi
|
|
_pc_half_gb=$((_pc_avail_gb / 2))
|
|
if [[ "${_pc_half_gb}" -lt 2 ]]; then _pc_half_gb=2; fi
|
|
INFINITO_PACKAGE_CACHE_BLOBSTORE_MAX="${_pc_half_gb}g"
|
|
unset _pc_path _pc_avail_gb _pc_half_gb
|
|
fi
|
|
export INFINITO_PACKAGE_CACHE_BLOBSTORE_MAX
|
|
|
|
# Use `hostname` command, not $HOSTNAME var, so subshells see the same value.
|
|
if [[ -z "${INFINITO_PACKAGE_CACHE_ADMIN_PASSWORD:-}" ]]; then
|
|
_pc_host="$(hostname 2>/dev/null || echo local)"
|
|
_pc_seed="${INFINITO_PACKAGE_CACHE_HOST_PATH}:${_pc_host}"
|
|
INFINITO_PACKAGE_CACHE_ADMIN_PASSWORD="$(printf '%s' "${_pc_seed}" | sha256sum | awk '{print substr($1,1,32)}')"
|
|
unset _pc_seed _pc_host
|
|
fi
|
|
export INFINITO_PACKAGE_CACHE_ADMIN_PASSWORD
|
|
|
|
: "${INFINITO_PACKAGE_CACHE_PORT:=8081}"
|
|
export INFINITO_PACKAGE_CACHE_PORT
|
|
|
|
: "${INFINITO_PACKAGE_CACHE_FRONTEND_CA_DIR:=/var/cache/infinito/core/cache/package/frontend/ca}"
|
|
: "${INFINITO_PACKAGE_CACHE_FRONTEND_CERTS_DIR:=/var/cache/infinito/core/cache/package/frontend/certs}"
|
|
export INFINITO_PACKAGE_CACHE_FRONTEND_CA_DIR
|
|
export INFINITO_PACKAGE_CACHE_FRONTEND_CERTS_DIR
|
|
|
|
: "${INFINITO_PACKAGE_CACHE_FRONTEND_IP:=172.30.0.4}"
|
|
export INFINITO_PACKAGE_CACHE_FRONTEND_IP
|
|
|
|
# Cache freshness in minutes. Default 6 days (= 6 * 24 * 60 = 8640).
|
|
#
|
|
# Stays strictly below the 7-day `Valid-Until` window that Debian /
|
|
# Ubuntu generate by default in their apt `Release` files — Nexus
|
|
# re-validates every cached `Release` against upstream after at most
|
|
# 6 days, so apt never sees an expired manifest and `apt-get update`
|
|
# never aborts with "Release file ... is expired".
|
|
#
|
|
# Override via `INFINITO_PACKAGE_CACHE_MAX_AGE_MIN=<minutes>` if a
|
|
# specific environment needs longer or shorter freshness.
|
|
: "${INFINITO_PACKAGE_CACHE_MAX_AGE_MIN:=8640}"
|
|
export INFINITO_PACKAGE_CACHE_MAX_AGE_MIN
|