🌳
pt0/deployF/k8sF/initialSetupF/regcacheF/regcacheGcAndRestartAI.mts
1import { spawnSync } from 'child_process'
7// zot only reclaims orphaned blobs at startup or its gcInterval tick (6h), so after sweeping
8// stale manifests we rollout-restart to trigger an immediate gc pass — otherwise a disk-full
9// retry push keeps failing for up to ~7h. Safe for sequential deploys; a concurrent deploy
10// (pushed-but-not-yet-rolled-out tag on another machine) could have its tag swept — see regcacheGc.
11export const regcacheGcAndRestart = async ({regcacheHost, regcacheLanHost, cluster_name}: {
12 regcacheHost: string, regcacheLanHost?: string, cluster_name?: string
13}) => {
14 const ctxCluster = cluster_name || getKlusterCtx().cluster_name
15 await regcacheGc({regcacheHost, regcacheLanHost})
16 const env = {...process.env, KUBECONFIG: getKubeConfigPath(ctxCluster)}
17 spawnSync('kubectl', ['rollout', 'restart', `deployment/${regcacheName}`], {stdio: 'inherit', env})
18 const status = spawnSync('kubectl', ['rollout', 'status', `deployment/${regcacheName}`, '--timeout=180s'], {stdio: 'inherit', env})
19 return status.status === 0