Skip to content

Conversation

@dustymabe
Copy link
Member

@dustymabe dustymabe commented Nov 9, 2024

This is done by adding cosa osbuild qemu metal....

There is a lot of refactor/cleanup in this PR. Please review commits individually.

dustymabe added a commit to dustymabe/fedora-coreos-pipeline that referenced this pull request Nov 12, 2024
With coreos/coreos-assembler#3930 we can
now build multiple artifacts/platforms in a single OSBuild call.
Let's add support here for:

1. Detecting if an artifact supports building via OSBuild by
   looking to see if the buildextend-{artifact} API points
   to cmd-osbuild. i.e. is OSBuild the default for this artifact?
2. Allowing the pipecfg to specify additional artifacts to build
   using OSBuild. This is useful if OSBuild is not yet the default
   way to build this particular artifact.
jlebon
jlebon previously approved these changes Nov 12, 2024
Copy link
Member

@jlebon jlebon left a comment

Choose a reason for hiding this comment

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

Very nice! Overall LGTM.

@dustymabe
Copy link
Member Author

Pushed an update to address code review comments and also update a few missing things from the gcp/applehv/hyperv platforms.

@dustymabe
Copy link
Member Author

ideas on this shellcheck error?

./tests/check_one.sh src/cmd-osbuild src/.cmd-osbuild.shellchecked
if ${skip_compress}:
Possible unbracketed conditional in src/cmd-osbuild
make: *** [Makefile:39: src/.cmd-osbuild.shellchecked] Error 1

The code it's complaining about is embedded python.

@dustymabe
Copy link
Member Author

ideas on this shellcheck error?

./tests/check_one.sh src/cmd-osbuild src/.cmd-osbuild.shellchecked
if ${skip_compress}:
Possible unbracketed conditional in src/cmd-osbuild
make: *** [Makefile:39: src/.cmd-osbuild.shellchecked] Error 1

It's not actually shellcheck that is complaining. It's hitting this check that we added in #3155

if grep -E '(^|[[:space:]])if[[:space:]]+"?\$' "$f"; then
echo "Possible unbracketed conditional in $f"
exit 1
fi

The results of running this were never used and we stopped running
it in coreos/fedora-coreos-pipeline@81304c0
We never officially supported this and when we switched to OSBuild
in d37958a and dropped create_disk.sh this became dead code.
No longer used since we dropped create_disk.sh in d37958a.
This will enable us to generate the input config for runvm-osbuild
once and re-use it for all platforms. In other words, the input JSON
to runvm-osbuild shouldn't change between invocations.
- Add getconfig() helper functions to reduce boilerplate
- Rename variable for config passed to runvm-osbuild to make it more clear
- Create less files
    - Use variables and pipes instead of creating multiple files
- Limit the config for runvm-osbuild
    - Only pass in the variables that are used there and not the entire image.json
…results

Let's refactor the generation of the runvm-osbuild config into
a function and cache the results since we don't need to compute
these values every time we run OSBuild.
…nfig()

This only needs to happen when we're generating the config.
In this case we'll just copy out the entire exported tree for
a given pipeline (which we specify as --export=platform). For
individual artifacts we'll just name the file the same name as
the platform and then copy them into the right place in the
calling script.

The benefits of this can be seen immediately because now we don't
have to know about or copy around qemu-secex bootfs_hash and
rootfs_hash inside the supermin VM.
Allows for a little more reasoning on what is happening when.
From what I can tell this is only used in the case where we
are delaying meta.json merging until later. For example, when
parallel building and we want meta.json snippets (i.e. meta.aws.json)
to be what gets merged at the end.

Let's remove it from here to simplify.
This separates them. It adds a call to `cosa meta` but now the code
stands on its own and the ordering doesn't matter.
Reduces duplicate code by making a function to handle the meta.json
update and finalization of the artifact.
This script isn't set -x to begin with so this doesn't really
do anything right now.
It's unlikely to change. This is prep to make a future change easier.
And also refactor to drop the rc variable.
This is a direct copy of cmd-buildextend-metal for now. Will update
it to be functional in the next commit.
@dustymabe
Copy link
Member Author

It's not actually shellcheck that is complaining. It's hitting this check that we added in #3155

OK. I was able to figure out a workaround.. rebased the PR and added a commit with the workaround.

Now you can run `cosa osbuild qemu metal gcp...` it will
build them all. The following files are now symlinks to
`cmd-osbuild` and all backwards compatibility should be
preserved.

- cmd-buildextend-metal
- cmd-buildextend-metal4k
- cmd-buildextend-qemu
- cmd-buildextend-qemu-secex
- cmd-buildextend-secex
Turns out we can stencil in the name of the artifacts we want
to create and just have OSBuild go ahead and write files to the
right name.

Also dropped an extra copy that's not really necessary.
This leverages the featurework in upstream OSBuild [1]
and matches the compression level we use today for gzip compression.

[1] osbuild/osbuild@cfaabe6
In qemuvariants.py applehv is gzip compressed so let's do the same
here and tell postprocess_artifact to skip compression in meta.json.

While we are here also have gcp set to skip compression in meta.json.
This reverts commit 4155975.

The upstream fix [1] was released in OSBuild v132 that is in Fedora
40 now.

[1] osbuild/osbuild#1908
The artifact we create in the pipeline today is .vhdx.zip. Let's
build on the work upstream in [1] and use the new OSBuild zip stage
to encapsulate the artifact.

[1] osbuild/osbuild@ac8a2a4
The check is invalid for this code because it's embedded
python. Let's just workaround it for now by putting it
in a elif so it won't match the string being looked for in
https://github.com/coreos/coreos-assembler/blob/48fba72a62c739f6eaf4d7991052516fd574acc7/tests/check_one.sh#L30-L33
Copy link
Member

@jlebon jlebon left a comment

Choose a reason for hiding this comment

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

LGTM!

Comment on lines +64 to +69
# backwards conditional here because of a invalid (for this code) CI check
# https://github.com/coreos/coreos-assembler/pull/3930#issuecomment-2473714222
if False:
pass
elif ${skip_compress}:
j['images']['${artifact_name}']['skip-compression'] = True
Copy link
Member

Choose a reason for hiding this comment

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

Heh, that's actually kinda funny.

I think another way around this is:

if True == ${skip_compression}:
    ...

Not worth the respin

dustymabe added a commit to dustymabe/fedora-coreos-pipeline that referenced this pull request Nov 13, 2024
With coreos/coreos-assembler#3930 we can
now build multiple artifacts/platforms in a single OSBuild call.
Let's add support here for:

1. Detecting if an artifact supports building via OSBuild by
   looking to see if the buildextend-{artifact} API points
   to cmd-osbuild. i.e. is OSBuild the default for this artifact?
2. Allowing the pipecfg to specify additional artifacts to build
   using OSBuild. This is useful if OSBuild is not yet the default
   way to build this particular artifact.
dustymabe added a commit to dustymabe/fedora-coreos-pipeline that referenced this pull request Nov 13, 2024
With coreos/coreos-assembler#3930 we can
now build multiple artifacts/platforms in a single OSBuild call.
Let's add support here for:

1. Detecting if an artifact supports building via OSBuild by
   looking to see if the buildextend-{artifact} API points
   to cmd-osbuild. i.e. is OSBuild the default for this artifact?
2. Allowing the pipecfg to specify additional artifacts to build
   using OSBuild. This is useful if OSBuild is not yet the default
   way to build this particular artifact.
@dustymabe dustymabe merged commit 7496933 into coreos:main Nov 13, 2024
5 checks passed
@dustymabe dustymabe deleted the dusty-cmd-osbuild branch November 13, 2024 21:54
dustymabe added a commit to dustymabe/fedora-coreos-pipeline that referenced this pull request Nov 13, 2024
With coreos/coreos-assembler#3930 we can
now build multiple artifacts/platforms in a single OSBuild call.
Let's add support here for:

1. Detecting if an artifact supports building via OSBuild by
   looking to see if the buildextend-{artifact} API points
   to cmd-osbuild. i.e. is OSBuild the default for this artifact?
2. Allowing the pipecfg to specify additional artifacts to build
   using OSBuild. This is useful if OSBuild is not yet the default
   way to build this particular artifact.
dustymabe added a commit to dustymabe/fedora-coreos-pipeline that referenced this pull request Nov 13, 2024
With coreos/coreos-assembler#3930 we can
now build multiple artifacts/platforms in a single OSBuild call.
Let's add support here for detecting what artifacts are supported
to be built by OSBuild and build them using OSBuild.

We segregate here "experimental" versus "stable" OSbuild built
artifacts and add a pipecfg knob for opting into the "experimental"
ones being built by OSBuild.
dustymabe added a commit to dustymabe/fedora-coreos-pipeline that referenced this pull request Nov 14, 2024
foo
With coreos/coreos-assembler#3930 we can
now build multiple artifacts/platforms in a single OSBuild call.
Let's add support here for detecting what artifacts are supported
to be built by OSBuild and build them using OSBuild.

We segregate here "experimental" versus "stable" OSbuild built
artifacts and add a pipecfg knob for opting into the "experimental"
ones being built by OSBuild.
dustymabe added a commit to dustymabe/fedora-coreos-pipeline that referenced this pull request Nov 14, 2024
With coreos/coreos-assembler#3930 we can
now build multiple artifacts/platforms in a single OSBuild call.
Let's add support here for detecting what artifacts are supported
to be built by OSBuild and build them using OSBuild.

We segregate here "experimental" versus "stable" OSbuild built
artifacts and add a pipecfg knob for opting into the "experimental"
ones being built by OSBuild.
dustymabe added a commit to coreos/fedora-coreos-pipeline that referenced this pull request Nov 14, 2024
With coreos/coreos-assembler#3930 we can
now build multiple artifacts/platforms in a single OSBuild call.
Let's add support here for detecting what artifacts are supported
to be built by OSBuild and build them using OSBuild.

We segregate here "experimental" versus "stable" OSbuild built
artifacts and add a pipecfg knob for opting into the "experimental"
ones being built by OSBuild.
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.

3 participants