Skip to content

Commit aeba046

Browse files
committed
DEBUG pruning
1 parent 4de583b commit aeba046

File tree

4 files changed

+38
-8
lines changed

4 files changed

+38
-8
lines changed

.cci.jenkinsfile

+27-8
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,34 @@ coreos.pod([image: 'registry.fedoraproject.org/fedora:30', privileged: true, kvm
2424
cosa_cmd("init https://github.com/coreos/fedora-coreos-config")
2525
cosa_cmd("fetch")
2626
cosa_cmd("build")
27-
cosa_cmd("kola run")
27+
//cosa_cmd("kola run")
2828
// sanity check kola actually ran and dumped its output in tmp/
29-
coreos.shwrap("test -d /srv/tmp/kola")
30-
cosa_cmd("buildextend-metal")
31-
cosa_cmd("buildextend-installer")
32-
cosa_cmd("buildextend-openstack")
33-
cosa_cmd("buildextend-vmware")
34-
cosa_cmd("compress")
35-
cosa_cmd("buildupload --dry-run s3 --acl=public-read my-nonexistent-bucket/my/prefix")
29+
//coreos.shwrap("test -d /srv/tmp/kola")
30+
// cosa_cmd("buildextend-metal")
31+
// cosa_cmd("buildextend-installer")
32+
// cosa_cmd("buildextend-openstack")
33+
// cosa_cmd("buildextend-vmware")
34+
// cosa_cmd("compress")
35+
// cosa_cmd("buildupload --dry-run s3 --acl=public-read my-nonexistent-bucket/my/prefix")
36+
37+
// test pruning
38+
coreos.shwrap("cat /srv/builds/builds.json")
39+
cosa_cmd("build ostree --force-image")
40+
cosa_cmd("build ostree --force-image")
41+
cosa_cmd("build ostree --force-image")
42+
coreos.shwrap("cat /srv/builds/builds.json")
43+
cosa_cmd("build ostree --force-image --skip-prune")
44+
coreos.shwrap("cat /srv/builds/builds.json")
45+
cosa_cmd("build ostree --force-image")
46+
cosa_cmd("build ostree --force-image")
47+
coreos.shwrap("cat /srv/builds/builds.json")
48+
cosa_cmd("prune --workdir /srv --dry-run")
49+
coreos.shwrap("cat /srv/builds/builds.json")
50+
cosa_cmd("prune --workdir /srv --dry-run --keep-last-n=1")
51+
coreos.shwrap("cat /srv/builds/builds.json")
52+
cosa_cmd("prune --workdir /srv --dry-run --keep-last-n=0")
53+
cosa_cmd("prune --workdir /srv --dry-run --keep-last-days=5")
54+
coreos.shwrap("cat /srv/builds/builds.json")
3655
}
3756
}
3857
}

src/cmd-build

+2
Original file line numberDiff line numberDiff line change
@@ -406,8 +406,10 @@ mv -T "${tmp_builddir}" "${builddir}"
406406
ln -Tsf "${buildid}" builds/latest
407407

408408
if [ "${SKIP_PRUNE}" == 1 ]; then
409+
echo "Running bump_timestamp '${buildid}' '${workdir}'"
409410
bump_timestamp "${buildid}" "${workdir}"
410411
else
412+
echo "Running cmd-prune '${workdir}' '${workdir}'"
411413
"${dn}"/cmd-prune --workdir "${workdir}"
412414
fi
413415
rm builds/.build-commit

src/cmd-prune

+7
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ if args.keep_last_days != DEFAULT_KEEP_LAST_DAYS:
4141
keep_younger_than = (datetime.now(timezone.utc) -
4242
timedelta(days=args.keep_last_days))
4343

44+
print(f"prune: keep_younger_than: {keep_younger_than}")
45+
print(f"prune: keep_last_n: {args.keep_last_n}")
46+
print(f"prune: keep_last_days: {args.keep_last_days}")
47+
4448
skip_pruning = (not keep_younger_than and args.keep_last_n == 0)
4549
print(f"prune: skip_pruning: {skip_pruning}")
4650

@@ -64,6 +68,7 @@ if skip_pruning:
6468
new_builds = scanned_builds
6569
else:
6670
if keep_younger_than:
71+
print(f"prune: using keep_younger_than")
6772
for build in scanned_builds:
6873
if build.id in tagged_builds:
6974
print(f"Skipping tagged build {build.id}")
@@ -76,6 +81,7 @@ else:
7681
new_builds.append(build)
7782
else:
7883
n = args.keep_last_n
84+
print(f"prune: using keep_last_n")
7985
assert(n > 0)
8086
for build in scanned_builds:
8187
if n == 0:
@@ -85,6 +91,7 @@ else:
8591
n = n - 1
8692

8793
print(f"prune: new builds: {new_builds}")
94+
print(f"prune: builds to delete: {builds_to_delete}")
8895

8996
if len(builds_to_delete) == 0 or args.dry_run:
9097
print(f"prune: not removing any builds")

src/cmdlib.sh

+2
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,7 @@ get_latest_qemu() {
687687
}
688688

689689
bump_timestamp() {
690+
set -x
690691
local buildid=$1; shift
691692
local dir=$1; shift
692693
(python3 -c "
@@ -697,4 +698,5 @@ builds = Builds('${workdir:-$(pwd)}')
697698
builds.insert_build('${buildid}')
698699
builds.bump_timestamp()
699700
print('Build timestamp was updated')")
701+
set +x
700702
}

0 commit comments

Comments
 (0)