Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4.11] Backports for RHCOS CI (--transient option & test entrypoint) #2963

Merged
merged 15 commits into from
Jul 7, 2022
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions ci/prow-rhcos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ esac
export COSA_SKIP_OVERLAY=1
# Create a temporary cosa workdir
cd "$(mktemp -d)"
cosa init -b "${RHCOS_BRANCH}" https://github.com/openshift/os
exec src/config/ci/prow-build-test-qemu.sh
cosa init --transient -b "${RHCOS_BRANCH}" https://github.com/openshift/os
# Use a COSA specifc test entry point to focus on tests relevant for COSA
exec src/config/ci/prow-entrypoint.sh rhcos-cosa-prow-pr-ci
18 changes: 16 additions & 2 deletions src/cmd-init
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ dn=$(dirname "$0")
FORCE=0
BRANCH=""
COMMIT=""
TRANSIENT=0

print_help() {
cat 1>&2 <<'EOF'
Usage: coreos-assembler init --help
coreos-assembler init [--force] [--branch BRANCH]
coreos-assembler init [--force] [--transient] [--branch BRANCH]
[--commit COMMIT] GITCONFIG [SUBDIR]

For example, you can use https://github.com/coreos/fedora-coreos-config
Expand All @@ -24,12 +25,15 @@ Usage: coreos-assembler init --help

If specified, SUBDIR is a subdirectory of the git repository that should
contain manifest.yaml and image.yaml (or image.ks).

Use `--transient` for builds that will throw away all cached data on success/failure,
and should hence not invoke `fsync()` for example.
EOF
}

# Call getopt to validate the provided input.
rc=0
options=$(getopt --options hfb:c: --longoptions help,force,branch:,commit: -- "$@") || rc=$?
options=$(getopt --options hfb:c: --longoptions help,force,transient,branch:,commit: -- "$@") || rc=$?
[ $rc -eq 0 ] || {
print_help
exit 1
Expand All @@ -44,6 +48,9 @@ while true; do
-f | --force)
FORCE=1
;;
--transient)
TRANSIENT=1
;;
-b | --branch)
case "$2" in
"")
Expand Down Expand Up @@ -136,3 +143,10 @@ mkdir -p builds
mkdir -p tmp
mkdir -p overrides/rpm
mkdir -p overrides/rootfs

if test "${TRANSIENT}" = 1; then
touch tmp/cosa-transient
fi

set +x
echo "Initialized $PWD as coreos-assembler working directory."
17 changes: 16 additions & 1 deletion src/cmdlib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,12 @@ preflight_kvm() {
fi
}

# Use this for things like disabling fsync.
# For more information, see the docs of `cosa init --transient`.
is_transient() {
test -f "${workdir}"/tmp/cosa-transient
}

# Picks between yaml or json based on which version exists. Errors out if both
# exists. If neither exist, prefers the extension in ${2}, or otherwise YAML.
pick_yaml_or_else_json() {
Expand Down Expand Up @@ -207,6 +213,11 @@ prepare_build() {
else
ostree init --repo="${tmprepo}" --mode=archive
fi

# No need to fsync for transient flows
if test -f "${workdir}/tmp/cosa-transient"; then
ostree --repo="${tmprepo}" config set 'core.fsync' 'false'
fi
fi

configdir_gitrepo=${configdir}
Expand Down Expand Up @@ -507,7 +518,11 @@ impl_rpmostree_compose() {
fi
# And remove the old one
rm -vf "${workdir}"/cache/cache.qcow2
compose_qemu_args+=("-drive" "if=none,id=cache,discard=unmap,file=${workdir}/cache/cache2.qcow2" \
local cachedriveargs="discard=unmap"
if is_transient; then
cachedriveargs="cache=unsafe,discard=ignore"
fi
compose_qemu_args+=("-drive" "if=none,id=cache,$cachedriveargs,file=${workdir}/cache/cache2.qcow2" \
"-device" "virtio-blk,drive=cache")
runvm "${compose_qemu_args[@]}" -- "$@"
fi
Expand Down