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

flatcar-update: Support Flatcar OEM and extension payloads #101

Merged
merged 2 commits into from
Sep 8, 2023

Conversation

pothos
Copy link
Member

@pothos pothos commented Jul 28, 2023

The OEMs are now getting ported over to systemd-sysext images and they are delivered as additional update payloads in the Omaha response. We also define optional Flatcar extensions that the user can enable. While update-engine's post-install action and the initrd have a fallback mechanism that use the release server in case flatcar-update does not provide the required payloads, this does not work for airgapped environments or updating to developer payloads.
Let flatcar-update download the required payloads for the running machine from the release server instead of relying on any fallback logic and also request the user to provide any required extension payloads.

How to use

Testing done

See flatcar/update_engine#24

@pothos pothos force-pushed the kai/flatcar-update-sysext branch 7 times, most recently from b1e480c to 4b9413c Compare July 28, 2023 20:16
@pothos pothos requested a review from a team July 28, 2023 20:26
@pothos pothos force-pushed the kai/flatcar-update-sysext branch from 4b9413c to 165d641 Compare July 31, 2023 11:43
bin/flatcar-update Outdated Show resolved Hide resolved
bin/flatcar-update Outdated Show resolved Hide resolved
bin/flatcar-update Outdated Show resolved Hide resolved
bin/flatcar-update Outdated Show resolved Hide resolved
@@ -89,6 +119,32 @@ if [ "${FORCE_DEV_KEY}" = "1" ] && [ "${FORCE_FLATCAR_KEY}" = "1" ]; then
echo "Error: must only specify one of --force-dev-key or --force-flatcar-key" > /dev/stderr ; exit 1
fi

# Use the old mount point for compatibility with old instances, where the script gets copied to
OEMID=$({ grep -m 1 -o "^ID=.*" /usr/share/oem/oem-release 2> /dev/null || true ; } | cut -d = -f 2)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
OEMID=$({ grep -m 1 -o "^ID=.*" /usr/share/oem/oem-release 2> /dev/null || true ; } | cut -d = -f 2)
OEMID=$({ grep -m 1 -o "^ID=.*" /usr/share/oem/oem-release 2> /dev/null || true ; } | cut -d = -f 2-)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The delimiter is = and not supposed to be part of the OEMID, or?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hope so. :) Another option here is (if you want):

Suggested change
OEMID=$({ grep -m 1 -o "^ID=.*" /usr/share/oem/oem-release 2> /dev/null || true ; } | cut -d = -f 2)
OEMID=$(source /usr/share/oem/oem-release || :; echo "${ID:-}")

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, since this is used at other places, I think we should change it everywhere in a follow-up

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested it and it breaks the main script execution if oem-release would have an invalid syntax.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What works is this here: $(sh -c "source /usr/share/oem/oem-release" || :; echo "${ID:-}")

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested it and it breaks the main script execution if oem-release would have an invalid syntax.

Alright, let's have a solution that works. I'll have a look at making sure that this file is valid for sourcing.

Copy link
Member Author

@pothos pothos Sep 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sure it's valid as we ship it but if it's broken due to invalid user changes I wanted the script not to crash, hence the sh -c workaround (since it's a subshell, || : won't be needed then).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, no, my example is broken because the echo should be part of the sh -c

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This here works ID=$(sh -c 'source /usr/share/oem/oem-release; echo "${ID:-}"' 2>/dev/null || true)

bin/flatcar-update Outdated Show resolved Hide resolved
bin/flatcar-update Outdated Show resolved Hide resolved
bin/flatcar-update Outdated Show resolved Hide resolved
bin/flatcar-update Outdated Show resolved Hide resolved
bin/flatcar-update Outdated Show resolved Hide resolved
The OEMs are now getting ported over to systemd-sysext images and they
are delivered as additional update payloads in the Omaha response. We
also define optional Flatcar extensions that the user can enable. While
update-engine's post-install action and the initrd have a fallback
mechanism that use the release server in case flatcar-update does not
provide the required payloads, this does not work for airgapped
environments or updating to developer payloads.
Let flatcar-update download the required payloads for the running
machine from the release server instead of relying on any fallback logic
and also request the user to provide any required extension payloads.
@pothos pothos force-pushed the kai/flatcar-update-sysext branch 2 times, most recently from df81001 to 98f6810 Compare September 4, 2023 19:39
The cleanup of all subprocesses through "kill 0" also ends up sending a
SIGTERM to the script itself, which prevents ending with a successful
return code.
Keep track of spawned subprocesses (at least the top ones) and only kill
them.
@@ -89,6 +119,32 @@ if [ "${FORCE_DEV_KEY}" = "1" ] && [ "${FORCE_FLATCAR_KEY}" = "1" ]; then
echo "Error: must only specify one of --force-dev-key or --force-flatcar-key" > /dev/stderr ; exit 1
fi

# Use the old mount point for compatibility with old instances, where the script gets copied to
OEMID=$({ grep -m 1 -o "^ID=.*" /usr/share/oem/oem-release 2> /dev/null || true ; } | cut -d = -f 2)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hope so. :) Another option here is (if you want):

Suggested change
OEMID=$({ grep -m 1 -o "^ID=.*" /usr/share/oem/oem-release 2> /dev/null || true ; } | cut -d = -f 2)
OEMID=$(source /usr/share/oem/oem-release || :; echo "${ID:-}")

@pothos pothos merged commit a7c8b0c into flatcar-master Sep 8, 2023
@pothos pothos deleted the kai/flatcar-update-sysext branch September 8, 2023 12:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants