-
Notifications
You must be signed in to change notification settings - Fork 159
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
overlay.d/15fcos: add a migration script to move to OCI images #3355
base: testing-devel
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
#!/bin/bash | ||
|
||
# This is a migration script to move FCOS to OCI transport | ||
# | ||
# Users that have disabled Zincati or use a non default ostree remote | ||
# won't be migrated, but a MOTD will be displayed. | ||
# This should be shipped as a barrier-release. | ||
# | ||
# see https://fedoraproject.org/wiki/Changes/CoreOSOstree2OCIUpdates | ||
# and https://github.com/coreos/fedora-coreos-tracker/issues/1823 | ||
|
||
|
||
# Maybe the machine is already on an OCI deployment | ||
booted_imgref=$(rpm-ostree status --json --booted | jq -r '.deployments[0]."container-image-reference"') | ||
|
||
if [ "$booted_imgref" != "null" ]; then | ||
echo "The booted deployement is already an OCI container." | ||
exit 0 | ||
fi | ||
|
||
# check if the origin was changed | ||
origin=$(rpm-ostree status --json --booted | jq -r '.deployments[0].origin' | cut -d ':' -f 1) | ||
origin_url=$(ostree remote show-url "$origin") | ||
if [ "$origin_url" != "https://ostree.fedoraproject.org" ]; then | ||
write_motd | ||
exit 0 | ||
fi | ||
|
||
# If Zincati is disabled, do nothing | ||
if ! systemctl is-enabled --quiet zincati; then | ||
write_motd | ||
exit 0 | ||
fi | ||
|
||
# Proceed with the migration by faking the origin file, | ||
# so at the next update, Zincati will pull the OCI image | ||
|
||
# get the currently booted ostree checksum | ||
checksum=$(rpm-ostree status --booted --json | jq -r '.deployments[0].checksum') | ||
# fetch the SHA checksum of the matching OCI image for the booted deployment | ||
version=$(rpm-ostree status --booted --json | jq -r '.deployments[0].version') | ||
stream=$(rpm-ostree status --booted --json | jq -r '.deployments[0]."base-commit-meta"."fedora-coreos.stream"') | ||
arch=$(arch) | ||
cincinnati_url="https://raw-updates.coreos.fedoraproject.org/v1/graph?basearch=$arch&stream=$stream&oci=true" | ||
imgref=$(curl "$cincinnati_url" -s | jq --arg VERSION "$version" -r '.nodes[] | select(.version==$VERSION) | .payload') | ||
Comment on lines
+44
to
+45
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should make a failure here nonfatal. IIUC the reason for the curl is more cosmetic than anything else (so Things that could cause this to fail could be complicated network environments like proxies, or maybe wifi where the NIC hasn't come up fully yet or something. |
||
|
||
|
||
# Empty the current origin | ||
tmpfile=$(mktemp) | ||
sed -e '/^refspec=/d' \ | ||
-e '/^baserefspec=/d' /ostree/deploy/fedora-coreos/deploy/"$checksum".0.origin > "$tmpfile" | ||
|
||
{ | ||
echo "container-image-reference=ostree-remote-image:fedora:registry:$imgref" | ||
echo "custom-url=ostree-remote-image:fedora:registry:$imgref" | ||
echo "custom-description=Fedora CoreOS testing stream" | ||
} >> "$tmpfile" | ||
|
||
mount -o remount,rw /sysroot | ||
|
||
# Replace the origin with our crafted one | ||
cp "$tmpfile" /ostree/deploy/fedora-coreos/deploy/"$checksum".0.origin | ||
|
||
|
||
# Restart Zincati | ||
systemctl restart zincati | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this happening here leads to temporary problems.. basically if there is an update available
Maybe we should restart There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Interesting scenario, I didn't thought of that. |
||
|
||
write_motd () { | ||
|
||
# Change the output color to yellow | ||
warn=$(echo -e '\033[0;33m') | ||
# No color | ||
nc=$(echo -e '\033[0m') | ||
|
||
motd_path=/run/motd.d/40-fcos-oci-rebase.motd | ||
|
||
cat << EOF > "${motd_path}" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should have a separate script that writes out the MOTD and it should run on every boot unless the user has neutered it by touching a stamp file. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. basically we can roll out the MOTD script later (i.e. like a month in to F42 or something). |
||
${warn} | ||
########################################################################## | ||
WARNING: Fedora CoreOS will be distributed through OCI images, to better | ||
align with the bootable containers initiative. | ||
The OSTree repository is expected to be retired after the Fedora 43 | ||
release. | ||
|
||
The migration service detected this system either have automatic updates | ||
disabled or is using a non-default ostree origin URL. | ||
|
||
The following command will rebase your system to the latest $stream release: | ||
sudo rpm-ostree rebase <insert image> | ||
|
||
See more details at <link to documentation page> | ||
|
||
To disable this warning, use: | ||
sudo systemctl disable coreos-oci-migration.service | ||
########################################################################## | ||
${nc} | ||
EOF | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.