mirror of
https://github.com/coollabsio/coolify.git
synced 2026-11-06 13:10:37 -04:00
fix(scripts): delete the unreferenced images before the other indexes
- they came after every index, so the leftovers of earlier runs waited about 190 runs - delete the oldest first on both registries instead of the manifests that only docker.io has first
This commit is contained in:
@@ -157,15 +157,20 @@ write_list() {
|
||||
}
|
||||
!($1 in kept) && $4 < cutoff && !seen[$1]++ { print "yes", (($1 in on_docker_hub) ? "yes" : "no"), kind[$1], platform_of($1), $3, $4, size[$1], $2, $1 }' \
|
||||
"$WORK_DIR/kept.txt" "$WORK_DIR/kinds.tsv" "$WORK_DIR/bytes.tsv" "$WORK_DIR/blobs.tsv" "$WORK_DIR/children.tsv" "$WORK_DIR/dockerhub-manifests.tsv" "$WORK_DIR/ghcr-active.tsv" \
|
||||
| sort -t $'\t' -k3,3r -k1,1 -k6,6 > "$WORK_DIR/sorted.tsv"
|
||||
| sort -t $'\t' -k3,3r -k6,6 > "$WORK_DIR/sorted.tsv"
|
||||
: > "$WORK_DIR/grouped.txt"
|
||||
awk -F '\t' -v grouped="$WORK_DIR/grouped.txt" 'function emit(digest, list, n, i) { printed[digest]; print line[digest]; n = split(children[digest], list, " "); for (i = 1; i <= n; i++) if ((list[i] in line) && !(list[i] in printed)) { print list[i] > grouped; emit(list[i]) } }
|
||||
FILENAME == ARGV[1] || FILENAME == ARGV[2] { children[$1] = children[$1] " " $2; next }
|
||||
{ order[++rows] = $9; line[$9] = $0 }
|
||||
END { for (i = 1; i <= rows; i++) if (!(order[i] in printed)) emit(order[i]) }' "$WORK_DIR/children.tsv" "$WORK_DIR/dockerhub-images.tsv" "$WORK_DIR/sorted.tsv" > "$WORK_DIR/rows.tsv"
|
||||
{ order[++rows] = $9; line[$9] = $0; type[$9] = $3 }
|
||||
END {
|
||||
for (i = 1; i <= rows; i++) if (order[i] in children) { n = split(children[order[i]], list, " "); for (j = 1; j <= n; j++) referenced[list[j]] }
|
||||
for (i = 1; i <= rows; i++) if (type[order[i]] == "index" && !(order[i] in children)) emit(order[i])
|
||||
for (i = 1; i <= rows; i++) if (type[order[i]] == "image" && !(order[i] in referenced) && !(order[i] in printed)) emit(order[i])
|
||||
for (i = 1; i <= rows; i++) if (!(order[i] in printed)) emit(order[i])
|
||||
}' "$WORK_DIR/children.tsv" "$WORK_DIR/dockerhub-images.tsv" "$WORK_DIR/sorted.tsv" > "$WORK_DIR/rows.tsv"
|
||||
write_table "$WORK_DIR/rows.tsv" "$TO_DELETE_FILE"
|
||||
ok "$(awk -F '\t' 'END { print ($9 + 0 ? $9 " to delete (" $3 "), they free " $7 : "nothing to delete") }' "$TO_DELETE_FILE")"
|
||||
info "$TO_DELETE_FILE lists every manifest to delete with its type, platform, tags, date and size, indexes first, each followed by the manifests it references"
|
||||
info "$TO_DELETE_FILE lists every manifest to delete in the order it deletes them, with its type, platform, tags, date and size"
|
||||
}
|
||||
|
||||
delete_manifests() {
|
||||
|
||||
Reference in New Issue
Block a user