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

Build_sysext script to enable sysext builds in the OS image build process #920

Merged
merged 1 commit into from Jul 4, 2023

Conversation

krishjainx
Copy link
Contributor

@krishjainx krishjainx commented Jun 14, 2023

Build_sysext script to enable sysext builds in the OS image build process

Included a script to enable generating systemd-sysexts. Successfully tested sysext generation (manually; script refinement in progress) with a fresh Flatcar image (e.g., Python and Neofetch system extension). Part of my internship work.

Link to the related issue: Flatcar Issue #1052.

How to use

The current OS images we provide are not OK as base for flatcar specific sysext images: it lacks the package metadata and portage configuration, in order to keep end user OS image clean. This script retains this information and allows you to produce systemd-sysexts to extend the system. This script can be used to build a Flatcar sysext image. Recommended to run from image build folder.

sudo build_sysext --board=amd64-usr command-extras package_1 package_2 package_3 - builds sysext named python-sysext with package_1, package_2 and package_3 within it  for amd64 architecture.
sudo build_sysext --board=arm64-usr command-extras package_1 package_2 package_3 - builds sysext named python-sysext with package_1, package_2 and package_3 within it  for arm64 architecture.

Testing done

I have built multiple sysext images using the script and have been able to successfully extend a fresh upstream Flatcar image with packages such as Python, Neofetch, etc. I provided a Butane configuration similar to the one below, transpiled it to Ignition, and booted with it. I received a review and advice on how to make the script more robust and meet the demands of the Flatcar team.

variant: flatcar
version: 1.0.0
storage:
  files:
    - path: /etc/extensions/python.raw
      mode: 0644
      contents:
        source: https://0x0.st/HQpJ.raw

Notes:

A problem with installing regular packages is that in many cases the software won't correctly work because only /usr is added. Files on /etc will be missing and the approach in the Azure OEM was that we ship the needed files in the sysext and then set up symlinks before, e.g., a service starts (We could build a confext in the future but this doesn't work now). Also, files in /var will be missing. For some of these files there might be tmpfile directives but they won't get executed on load. Finally, the services that use .wants symlinks to be enabled would currently work because we have deployed a workaround but we plan to drop this because the recommended way is to use Upholds= instead of Wants= (currently through drop-ins for the multi-user target but in systemd 254 it should work to use .upholds symlinks). In summary, we need some postprocessing for some scenarios and call out what won't work for the rest.

"I think this should be addressed to some degree by the --manglefs_script option" - @krnowak

Edit: A great use case for this would be to build a Docker and containerd sysext to replace torcx.

@t-lo t-lo requested a review from pothos June 15, 2023 11:53
build_sysext Outdated Show resolved Hide resolved
build_sysext Outdated Show resolved Hide resolved
build_sysext Outdated Show resolved Hide resolved
@pothos
Copy link
Member

pothos commented Jun 15, 2023

A problem with installing regular packages is that in many cases the software won't correctly work because only /usr is added.
Files on /etc will be missing and the approach in the Azure OEM was that we ship the needed files in the sysext and then set up symlinks before, e.g., a service starts (We could build a confext in the future but this doesn't work now).
Also, files in /var will be missing. For some of these files there might be tmpfile directives but they won't get executed on load.
Finally, the services that use .wants symlinks to be enabled would currently work because we have deployed a workaround but we plan to drop this because the recommended way is to use Upholds= instead of Wants= (currently through drop-ins for the multi-user target but in systemd 254 it should work to use .upholds symlinks).
In summary, we need some postprocessing for some scenarios and call out what won't work for the rest.

Edit: A great use case for this would be to build a Docker and containerd sysext to replace torcx.

@github-actions
Copy link

github-actions bot commented Jun 15, 2023

Build action triggered: https://github.com/flatcar/scripts/actions/runs/5424483460

build_sysext Outdated Show resolved Hide resolved
build_sysext Outdated Show resolved Hide resolved
build_sysext Outdated Show resolved Hide resolved
build_sysext Outdated Show resolved Hide resolved
@krishjainx krishjainx marked this pull request as ready for review June 19, 2023 22:41
build_library/prod_image_util.sh Outdated Show resolved Hide resolved
build_sysext Show resolved Hide resolved
build_sysext Outdated Show resolved Hide resolved
build_sysext Outdated Show resolved Hide resolved
build_sysext Outdated Show resolved Hide resolved
build_sysext Outdated Show resolved Hide resolved
build_sysext Outdated Show resolved Hide resolved
build_sysext Outdated Show resolved Hide resolved
build_sysext Outdated Show resolved Hide resolved
build_library/prod_image_util.sh Outdated Show resolved Hide resolved
@jepio
Copy link
Member

jepio commented Jun 21, 2023

@krishjainx
can you paste a log showing the output you see when you execute ./build_sysext (with whatever package you're testing with)?

Please try running the build two times in a row to make sure things don't break when this is done.

build_sysext Outdated Show resolved Hide resolved
@jepio
Copy link
Member

jepio commented Jun 26, 2023

Could you also make the script executable with chmod?

@krishjainx krishjainx requested review from t-lo, jepio and pothos June 26, 2023 11:00
build_sysext Outdated Show resolved Hide resolved
build_sysext Outdated Show resolved Hide resolved
build_sysext Outdated Show resolved Hide resolved
build_sysext Outdated Show resolved Hide resolved
@krishjainx
Copy link
Contributor Author

This and squash the commits

@krnowak
Copy link
Member

krnowak commented Jun 29, 2023

I'd like to make a review before merging this, please.

@krishjainx krishjainx temporarily deployed to development June 29, 2023 12:29 — with GitHub Actions Inactive
build_library/prod_image_util.sh Outdated Show resolved Hide resolved
build_library/prod_image_util.sh Outdated Show resolved Hide resolved
build_library/prod_image_util.sh Outdated Show resolved Hide resolved
build_sysext Outdated Show resolved Hide resolved
build_sysext Show resolved Hide resolved
build_sysext Outdated Show resolved Hide resolved
build_sysext Outdated Show resolved Hide resolved
build_sysext Outdated Show resolved Hide resolved
build_sysext Outdated Show resolved Hide resolved
build_sysext Outdated Show resolved Hide resolved
@krnowak
Copy link
Member

krnowak commented Jun 29, 2023

A problem with installing regular packages is that in many cases the software won't correctly work because only /usr is added. Files on /etc will be missing and the approach in the Azure OEM was that we ship the needed files in the sysext and then set up symlinks before, e.g., a service starts (We could build a confext in the future but this doesn't work now). Also, files in /var will be missing. For some of these files there might be tmpfile directives but they won't get executed on load. Finally, the services that use .wants symlinks to be enabled would currently work because we have deployed a workaround but we plan to drop this because the recommended way is to use Upholds= instead of Wants= (currently through drop-ins for the multi-user target but in systemd 254 it should work to use .upholds symlinks). In summary, we need some postprocessing for some scenarios and call out what won't work for the rest.

Edit: A great use case for this would be to build a Docker and containerd sysext to replace torcx.

I think this should be addressed to some degree by the --manglefs_script option.

@krishjainx
Copy link
Contributor Author

Squashed 🐛 s and squashed commits

build_sysext Outdated Show resolved Hide resolved
@krishjainx krishjainx temporarily deployed to development June 29, 2023 19:00 — with GitHub Actions Inactive
@krnowak
Copy link
Member

krnowak commented Jun 30, 2023

I'm currently trying to use this script to build OEM sysexts, just to see if we can do it. I think I'll want more changes, mostly related to the BUILD_DIR stuff. You can see my branch here: https://github.com/flatcar/scripts/commits/krnowak/test-new-oem-script (ignore the fact that the commits are made by Flatcar Buildbot, apparently I messed up my git config :) ). The changes in the script that I have made are here: 72d2b62

@krishjainx
Copy link
Contributor Author

krishjainx commented Jun 30, 2023 via email

@krnowak
Copy link
Member

krnowak commented Jun 30, 2023

Ok cool. Just these changes?

I think I'll let you know on Monday - the build is currently running on our Jenkins instance.

@krishjainx
Copy link
Contributor Author

krishjainx commented Jun 30, 2023 via email

@krishjainx krishjainx requested a review from krnowak July 3, 2023 09:42
build_sysext Outdated Show resolved Hide resolved
build_sysext Outdated Show resolved Hide resolved
build_sysext Outdated Show resolved Hide resolved
build_sysext Outdated Show resolved Hide resolved
build_sysext Outdated Show resolved Hide resolved
build_sysext Outdated Show resolved Hide resolved
build_sysext Show resolved Hide resolved
build_sysext Outdated Show resolved Hide resolved
build_sysext Outdated Show resolved Hide resolved
Included a script to enable generating systemd-sysexts. Successfully
tested sysext generation with a fresh Flatcar image (e.g., Python and
Neofetch system extension). Part of my internship work.

The current OS images we provide are not OK as base for flatcar specific
sysext images: it lacks the package metadata and portage configuration,
in order to keep end user OS image clean. This script retains this
information and allows you to produce systemd-sysexts to extend the
system. This script can be used to build a Flatcar sysext image.
Recommended to run from image build folder.

Signed-off-by: Krish Jain <kjain7@u.rochester.edu>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants