Expire our own keep refs so retired deployments release objects
This commit is contained in:
parent
35b6ef50d1
commit
4faddb1cb3
2 changed files with 16 additions and 8 deletions
|
|
@ -28,9 +28,11 @@ and, paradoxically, could keep old objects pinned forever.
|
|||
them **retained** until a history/readiness policy exists.
|
||||
- `archipelago cleanup apply` takes the shared host mutation lock, refuses live/no-booted/
|
||||
pending states, establishes keep refs for the complete protected commit graph and
|
||||
invokes only `ostree prune --refs-only`. It does **not** run `admin cleanup`, delete
|
||||
deployments or remove any old keep/service/history refs. The record stores protected
|
||||
commit identities and the before/after repo size in `/var/lib/archipelago/cleanup/`.
|
||||
invokes only `ostree prune --refs-only`. It does **not** run `admin cleanup` or delete
|
||||
deployments; it removes only its own `archipelago/keep/*` refs for commits no longer
|
||||
named by a deployment, active plan or retained intent (those deployments were already
|
||||
retired by OSTree finalize-staged retention). Service/history refs stay untouched.
|
||||
The record stores protected commit identities and the before/after repo size.
|
||||
This safely removes objects already unreachable from every ref; it cannot yet
|
||||
reclaim commits kept alive by obsolete deployment/history refs.
|
||||
- The `archipelago-ostree-gc.timer` unit (30 minutes after boot, then weekly) runs the
|
||||
|
|
|
|||
16
src/gc.rs
16
src/gc.rs
|
|
@ -335,9 +335,13 @@ pub fn apply() -> Result<(), String> {
|
|||
for (name, commit) in keep_ref_sync(&ref_names(&refs), &protected) {
|
||||
repository(&["refs", "--force", &format!("--create={name}"), &commit])?;
|
||||
}
|
||||
// Never expire old keep/service/history refs here. An extra ref is a leak;
|
||||
// removing a recovery root is destructive. D-047 readiness-bound retention
|
||||
// must own that step.
|
||||
// Remove only our own keep refs for commits that are no longer a deployment or
|
||||
// a plan/intent input. Those deployments were already retired by OSTree's own
|
||||
// finalize-staged retention; keeping the artificial ref would pin their objects
|
||||
// forever and defeat the collection. Service/history refs remain untouched.
|
||||
for (name, _) in stale_keep_refs(&refs, &protected) {
|
||||
repository(&["refs", "--delete", &name])?;
|
||||
}
|
||||
for commit in &protected {
|
||||
repository(&["ls", commit, "/"])?;
|
||||
}
|
||||
|
|
@ -473,7 +477,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn keep_refs_add_protected_roots_but_do_not_retire_old_roots() {
|
||||
fn keep_refs_add_protected_roots_and_expire_only_their_own_stale_refs() {
|
||||
let deployments = parse_deployments(&status()).unwrap();
|
||||
let protected: BTreeSet<String> = deployments.iter().map(|deployment| deployment.checksum.clone()).collect();
|
||||
let existing = vec![
|
||||
|
|
@ -488,7 +492,9 @@ mod tests {
|
|||
let all_refs = ["a".repeat(64), "b".repeat(64), "c".repeat(64)].into_iter()
|
||||
.map(|sum| format!("{KEEP}/{sum}")).collect::<Vec<_>>();
|
||||
assert!(keep_ref_sync(&all_refs, &with_old_root).is_empty());
|
||||
assert_eq!(stale_keep_refs(&[(format!("{KEEP}/{}", "c".repeat(64)), "c".repeat(64))], &protected).len(), 1);
|
||||
let stale = stale_keep_refs(&[(format!("{KEEP}/{}", "c".repeat(64)), "c".repeat(64)),
|
||||
("service/bases/old".to_owned(), "d".repeat(64))], &protected);
|
||||
assert_eq!(stale, vec![(format!("{KEEP}/{}", "c".repeat(64)), "c".repeat(64))]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue