Skip to content

Commit b2355e7

Browse files
jlebonopenshift-merge-robot
authored andcommitted
cmd-build: add --strict for building in strict mode
This makes use of rpm-ostree's new `--ex-lockfile-strict`. We really want this for FCOS CI and release builds. For more background, see: coreos/fedora-coreos-tracker#454 This also drops the printing of lockfiles and the `sleep 1` bit, since... I think by now people should be pretty familiar with lockfiles and rpm-ostree prints them already (and it's easily viewable while libsolv is loading its cache).
1 parent 15b9e3e commit b2355e7

File tree

3 files changed

+21
-16
lines changed

3 files changed

+21
-16
lines changed

.cci.jenkinsfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pod(image: 'registry.fedoraproject.org/fedora:31', runAsUser: 0, kvm: true, memo
2323
// just split into separate invocations to make it easier to see where it fails
2424
cosa_cmd("init https://github.com/coreos/fedora-coreos-config")
2525
cosa_cmd("fetch")
26-
cosa_cmd("build")
26+
cosa_cmd("build --strict")
2727
}
2828
parallel kola: {
2929
try {

src/cmd-build

+15-10
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ dn=$(dirname "$0")
88
print_help() {
99
cat 1>&2 <<'EOF'
1010
Usage: coreos-assembler build --help
11-
coreos-assembler build [--force] [--force-image] [--skip-prune] [--tag TAG] [--version VERSION] [TARGET...]
11+
coreos-assembler build [--force] [--force-image] [--skip-prune] [--strict] [--tag TAG] [--version VERSION] [TARGET...]
1212
1313
Build OSTree and image base artifacts from previously fetched packages.
1414
Accepted TARGET arguments:
@@ -30,8 +30,9 @@ SKIP_PRUNE=0
3030
VERSION=
3131
PARENT=
3232
TAG=
33+
STRICT=
3334
rc=0
34-
options=$(getopt --options hft: --longoptions tag:,help,force,version:,parent:,force-nocache,force-image,skip-prune -- "$@") || rc=$?
35+
options=$(getopt --options hft: --longoptions tag:,help,force,version:,parent:,force-nocache,force-image,skip-prune,strict -- "$@") || rc=$?
3536
[ $rc -eq 0 ] || {
3637
print_help
3738
exit 1
@@ -52,6 +53,9 @@ while true; do
5253
--skip-prune)
5354
SKIP_PRUNE=1
5455
;;
56+
--strict)
57+
STRICT=1
58+
;;
5559
--version)
5660
shift
5761
VERSION=$1
@@ -194,23 +198,23 @@ EOF
194198

195199
prepare_git_artifacts "${configdir_gitrepo}" "${PWD}/coreos-assembler-config.tar.gz" "${PWD}/coreos-assembler-config-git.json"
196200

197-
lock_arg=
201+
extra_compose_args=()
202+
198203
for lock in "${manifest_lock}" "${manifest_lock_overrides}"; do
199204
if [ -f "${lock}" ]; then
200-
lock_arg+=" --ex-lockfile=${lock}"
201-
echo "Building from lockfile: ${lock}"
205+
extra_compose_args+=("--ex-lockfile=${lock}")
202206
fi
203207
done
204-
if [ -n "${lock_arg}" ]; then
205-
sleep 1
208+
209+
if [ -n "${STRICT}" ]; then
210+
extra_compose_args+=("--ex-lockfile-strict")
206211
fi
207212

208213
# We'll pass this directly to rpm-ostree instead of through
209214
# commitmeta_input_json since that one also gets injected into meta.json, where
210215
# there's already ostree-version.
211-
version_arg=
212216
if [ -n "${VERSION}" ]; then
213-
version_arg="--add-metadata-string=version=${VERSION}"
217+
extra_compose_args+=("--add-metadata-string=version=${VERSION}")
214218
fi
215219

216220
# Builds are independent of each other. Higher-level pipelines may want to force
@@ -220,6 +224,7 @@ parent_arg=--no-parent
220224
if [ -n "${PARENT}" ]; then
221225
parent_arg="--parent=${PARENT}"
222226
fi
227+
extra_compose_args+=("$parent_arg")
223228

224229
# These need to be absolute paths right now for rpm-ostree
225230
composejson=${PWD}/tmp/compose.json
@@ -231,7 +236,7 @@ prepare_compose_overlays
231236
runcompose --cache-only ${FORCE} --add-metadata-from-json "${commitmeta_input_json}" \
232237
--write-composejson-to "${composejson}" \
233238
--ex-write-lockfile-to "${lockfile_out}".tmp \
234-
${lock_arg} ${version_arg} ${parent_arg}
239+
"${extra_compose_args[@]}"
235240
strip_out_lockfile_digests "$lockfile_out".tmp
236241
/usr/lib/coreos-assembler/finalize-artifact "${lockfile_out}"{.tmp,}
237242
# Very special handling for --write-composejson-to as rpm-ostree doesn't

tests/test_pruning.sh

+5-5
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ set -xeuo pipefail
99
# don't actually ask for a image rebuild since we use `ostree`.
1010
# FIXME: Add env COSA_BUILD_DUMMY=true or something instead of using this subtle
1111
# hack. Or better add `cosa build --shortcut=overrides` or so.
12-
cosa build ostree --force-image
13-
cosa build ostree --force-image
14-
cosa build ostree --force-image
12+
cosa build ostree --force-image --strict
13+
cosa build ostree --force-image --strict
14+
cosa build ostree --force-image --strict
1515
jq -e '.builds|length == 3' builds/builds.json
1616
jq -e '.builds[2].id | endswith("0-1")' builds/builds.json
1717

@@ -21,10 +21,10 @@ cosa prune --build="${latest}"
2121
# And validate it
2222
cosa meta --get ostree-version>/dev/null
2323
# Another build to get back to previous state
24-
cosa build ostree --force-image
24+
cosa build ostree --force-image --strict
2525

2626
# Test --skip-prune
27-
cosa build ostree --force-image --skip-prune
27+
cosa build ostree --force-image --skip-prune --strict
2828
jq -e '.builds|length == 4' builds/builds.json
2929
jq -e '.builds[3].id | endswith("0-1")' builds/builds.json
3030

0 commit comments

Comments
 (0)