distro/fedora: fix iot-installer package set generation

8fdd158799 modified the Cloud API to resolve
ostree commits using a separate job. This change caused the API handler
to call PackageSets without any ostree options (because they are not resolved
yet).

Unfortunately, the new implementation of PackageSets initializes the manifest.
The initialization checks the options and if the type is iot-installer and
it doesn't have the fetch checksum for IoT, it just returns an error.

To work around this (we need an initialized manifest to create the chains),
this commit just gives the initialization method a dummy checksum. The ostree
options currently don't have any effect on the package sets, so this should
be fine.

In order to make this workaround at least slightly sane, a warning is printed,
there's a new test just for this behaviour and a long comment to remember to
delete these lines.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
This commit is contained in:
Ondřej Budai 2022-11-11 14:15:46 +01:00 committed by Ondřej Budai
parent 4e7b021514
commit 194351e681
2 changed files with 41 additions and 0 deletions

View file

@ -8,6 +8,8 @@ import (
"strconv"
"strings"
"github.com/sirupsen/logrus"
"github.com/osbuild/osbuild-composer/internal/blueprint"
"github.com/osbuild/osbuild-composer/internal/common"
"github.com/osbuild/osbuild-composer/internal/container"
@ -536,6 +538,24 @@ func (t *imageType) PackageSets(bp blueprint.Blueprint, options distro.ImageOpti
}
}
// In case of Cloud API, this method is called before the ostree commit
// is resolved. Unfortunately, initializeManifest when called for
// an ostree installer returns an error.
//
// Work around this by providing a dummy FetchChecksum to convince the
// method that it's fine to initialize the manifest. Note that the ostree
// content has no effect on the package sets, so this is fine.
//
// See: https://github.com/osbuild/osbuild-composer/issues/3125
//
// TODO: Remove me when it's possible the get the package set chain without
// resolving the ostree reference before. Also remove the test for
// this workaround
if t.rpmOstree && t.bootISO && options.OSTree.FetchChecksum == "" {
options.OSTree.FetchChecksum = "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
logrus.Warn("FIXME: Requesting package sets for iot-installer without a resolved ostree ref. Faking one.")
}
// create a manifest object and instantiate it with the computed packageSetChains
manifest, err := t.initializeManifest(&bp, options, globalRepos, packageSets, nil, 0)
if err != nil {

View file

@ -730,3 +730,24 @@ func TestDistro_CustomUsrPartitionNotLargeEnough(t *testing.T) {
}
}
}
func TestIotInstallerWithoutOStreeRefs(t *testing.T) {
// Regression test for https://github.com/osbuild/osbuild-composer/issues/3125
// TODO: Remove when the ugly workaround is gone
d := fedora.NewF38()
arch, err := d.GetArch("x86_64")
require.NoError(t, err)
imgType, err := arch.GetImageType("iot-installer")
require.NoError(t, err)
bp := blueprint.Blueprint{
Name: "fish",
}
err = bp.Initialize()
require.NoError(t, err)
sets := imgType.PackageSets(bp, distro.ImageOptions{}, nil)
require.NotZero(t, len(sets))
}