Imagine this situation: You have a RHEL system booted from an image produced
by osbuild-composer. On this system, you want to use osbuild-composer to
create another image of RHEL.
However, there's currently something funny with partitions:
All RHEL images built by osbuild-composer contain a root xfs partition. The
interesting bit is that they all share the same xfs partition UUID. This might
sound like a good thing for reproducibility but it has a quirk.
The issue appears when osbuild runs the qemu assembler: it needs to mount all
partitions of the future image to copy the OS tree into it.
Imagine that osbuild-composer is running on a system booted from an imaged
produced by osbuild-composer. This means that its root xfs partition has this
uuid:
efe8afea-c0a8-45dc-8e6e-499279f6fa5d
When osbuild-composer builds an image on this system, it runs osbuild that
runs the qemu assembler at some point. As I said previously, it will mount
all partitions of the future image. That means that it will also try to
mount the root xfs partition with this uuid:
efe8afea-c0a8-45dc-8e6e-499279f6fa5d
Do you remember this one? Yeah, it's the same one as before. However, the xfs
kernel driver doesn't like that. It contains a global table[1] of all xfs
partitions that forbids to mount 2 xfs partitions with the same uuid.
I mean... uuids are meant to be unique, right?
This commit changes the way we build RHEL 8.4 images: Each one now has a
unique uuid. It's now literally a unique universally unique identifier. haha
[1]: a349e4c659/fs/xfs/xfs_mount.c (L51)
230 lines
5.9 KiB
Go
230 lines
5.9 KiB
Go
package store
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/google/uuid"
|
|
"github.com/osbuild/osbuild-composer/internal/blueprint"
|
|
"github.com/osbuild/osbuild-composer/internal/common"
|
|
"github.com/osbuild/osbuild-composer/internal/distro"
|
|
"github.com/osbuild/osbuild-composer/internal/distro/fedoratest"
|
|
"github.com/osbuild/osbuild-composer/internal/target"
|
|
)
|
|
|
|
func FixtureBase() *Store {
|
|
var bName = "test"
|
|
var b = blueprint.Blueprint{
|
|
Name: bName,
|
|
Version: "0.0.0",
|
|
Packages: []blueprint.Package{},
|
|
Modules: []blueprint.Package{},
|
|
Groups: []blueprint.Group{},
|
|
Customizations: nil,
|
|
}
|
|
|
|
var date = time.Date(2019, 11, 27, 13, 19, 0, 0, time.FixedZone("UTC+1", 60*60))
|
|
|
|
var localTarget = &target.Target{
|
|
Uuid: uuid.MustParse("20000000-0000-0000-0000-000000000000"),
|
|
Name: "org.osbuild.local",
|
|
ImageName: "localimage",
|
|
Created: date,
|
|
Status: common.IBWaiting,
|
|
Options: &target.LocalTargetOptions{},
|
|
}
|
|
|
|
var awsTarget = &target.Target{
|
|
Uuid: uuid.MustParse("10000000-0000-0000-0000-000000000000"),
|
|
Name: "org.osbuild.aws",
|
|
ImageName: "awsimage",
|
|
Created: date,
|
|
Status: common.IBWaiting,
|
|
Options: &target.AWSTargetOptions{
|
|
Region: "frankfurt",
|
|
AccessKeyID: "accesskey",
|
|
SecretAccessKey: "secretkey",
|
|
Bucket: "clay",
|
|
Key: "imagekey",
|
|
},
|
|
}
|
|
|
|
d := fedoratest.New()
|
|
arch, err := d.GetArch("x86_64")
|
|
if err != nil {
|
|
panic("invalid architecture x86_64 for fedoratest")
|
|
}
|
|
imgType, err := arch.GetImageType("qcow2")
|
|
if err != nil {
|
|
panic("invalid image type qcow2 for x86_64 @ fedoratest")
|
|
}
|
|
manifest, err := imgType.Manifest(nil, distro.ImageOptions{}, nil, nil, nil, 0)
|
|
if err != nil {
|
|
panic("could not create manifest")
|
|
}
|
|
s := New(nil, arch, nil)
|
|
|
|
s.blueprints[bName] = b
|
|
s.composes = map[uuid.UUID]Compose{
|
|
uuid.MustParse("30000000-0000-0000-0000-000000000000"): {
|
|
Blueprint: &b,
|
|
ImageBuild: ImageBuild{
|
|
QueueStatus: common.IBWaiting,
|
|
ImageType: imgType,
|
|
Manifest: manifest,
|
|
Targets: []*target.Target{localTarget, awsTarget},
|
|
JobCreated: date,
|
|
},
|
|
},
|
|
uuid.MustParse("30000000-0000-0000-0000-000000000001"): {
|
|
Blueprint: &b,
|
|
ImageBuild: ImageBuild{
|
|
QueueStatus: common.IBRunning,
|
|
ImageType: imgType,
|
|
Manifest: manifest,
|
|
Targets: []*target.Target{localTarget},
|
|
JobCreated: date,
|
|
JobStarted: date,
|
|
},
|
|
},
|
|
uuid.MustParse("30000000-0000-0000-0000-000000000002"): {
|
|
Blueprint: &b,
|
|
ImageBuild: ImageBuild{
|
|
QueueStatus: common.IBFinished,
|
|
ImageType: imgType,
|
|
Manifest: manifest,
|
|
Targets: []*target.Target{localTarget, awsTarget},
|
|
JobCreated: date,
|
|
JobStarted: date,
|
|
JobFinished: date,
|
|
},
|
|
},
|
|
uuid.MustParse("30000000-0000-0000-0000-000000000003"): {
|
|
Blueprint: &b,
|
|
ImageBuild: ImageBuild{
|
|
QueueStatus: common.IBFailed,
|
|
ImageType: imgType,
|
|
Manifest: manifest,
|
|
Targets: []*target.Target{localTarget, awsTarget},
|
|
JobCreated: date,
|
|
JobStarted: date,
|
|
JobFinished: date,
|
|
},
|
|
},
|
|
}
|
|
|
|
return s
|
|
}
|
|
func FixtureFinished() *Store {
|
|
var bName = "test"
|
|
var b = blueprint.Blueprint{
|
|
Name: bName,
|
|
Version: "0.0.0",
|
|
Packages: []blueprint.Package{},
|
|
Modules: []blueprint.Package{},
|
|
Groups: []blueprint.Group{},
|
|
Customizations: nil,
|
|
}
|
|
|
|
var date = time.Date(2019, 11, 27, 13, 19, 0, 0, time.FixedZone("UTC+1", 60*60))
|
|
|
|
var localTarget = &target.Target{
|
|
Uuid: uuid.MustParse("20000000-0000-0000-0000-000000000000"),
|
|
Name: "org.osbuild.local",
|
|
ImageName: "localimage",
|
|
Created: date,
|
|
Status: common.IBWaiting,
|
|
Options: &target.LocalTargetOptions{},
|
|
}
|
|
|
|
var awsTarget = &target.Target{
|
|
Uuid: uuid.MustParse("10000000-0000-0000-0000-000000000000"),
|
|
Name: "org.osbuild.aws",
|
|
ImageName: "awsimage",
|
|
Created: date,
|
|
Status: common.IBWaiting,
|
|
Options: &target.AWSTargetOptions{
|
|
Region: "frankfurt",
|
|
AccessKeyID: "accesskey",
|
|
SecretAccessKey: "secretkey",
|
|
Bucket: "clay",
|
|
Key: "imagekey",
|
|
},
|
|
}
|
|
|
|
d := fedoratest.New()
|
|
arch, err := d.GetArch("x86_64")
|
|
if err != nil {
|
|
panic("invalid architecture x86_64 for fedoratest")
|
|
}
|
|
imgType, err := arch.GetImageType("qcow2")
|
|
if err != nil {
|
|
panic("invalid image type qcow2 for x86_64 @ fedoratest")
|
|
}
|
|
manifest, err := imgType.Manifest(nil, distro.ImageOptions{}, nil, nil, nil, 0)
|
|
if err != nil {
|
|
panic("could not create manifest")
|
|
}
|
|
s := New(nil, arch, nil)
|
|
|
|
s.blueprints[bName] = b
|
|
s.composes = map[uuid.UUID]Compose{
|
|
uuid.MustParse("30000000-0000-0000-0000-000000000000"): {
|
|
Blueprint: &b,
|
|
ImageBuild: ImageBuild{
|
|
QueueStatus: common.IBFinished,
|
|
ImageType: imgType,
|
|
Manifest: manifest,
|
|
Targets: []*target.Target{localTarget, awsTarget},
|
|
JobCreated: date,
|
|
},
|
|
},
|
|
uuid.MustParse("30000000-0000-0000-0000-000000000001"): {
|
|
Blueprint: &b,
|
|
ImageBuild: ImageBuild{
|
|
QueueStatus: common.IBFinished,
|
|
ImageType: imgType,
|
|
Manifest: manifest,
|
|
Targets: []*target.Target{localTarget},
|
|
JobCreated: date,
|
|
JobStarted: date,
|
|
},
|
|
},
|
|
uuid.MustParse("30000000-0000-0000-0000-000000000003"): {
|
|
Blueprint: &b,
|
|
ImageBuild: ImageBuild{
|
|
QueueStatus: common.IBFailed,
|
|
ImageType: imgType,
|
|
Manifest: manifest,
|
|
Targets: []*target.Target{localTarget, awsTarget},
|
|
JobCreated: date,
|
|
JobStarted: date,
|
|
JobFinished: date,
|
|
},
|
|
},
|
|
}
|
|
|
|
return s
|
|
}
|
|
|
|
func FixtureEmpty() *Store {
|
|
var bName = "test"
|
|
var b = blueprint.Blueprint{
|
|
Name: bName,
|
|
Version: "0.0.0",
|
|
Packages: []blueprint.Package{},
|
|
Modules: []blueprint.Package{},
|
|
Groups: []blueprint.Group{},
|
|
Customizations: nil,
|
|
}
|
|
|
|
d := fedoratest.New()
|
|
arch, err := d.GetArch("x86_64")
|
|
if err != nil {
|
|
panic("invalid architecture x86_64 for fedoratest")
|
|
}
|
|
s := New(nil, arch, nil)
|
|
|
|
s.blueprints[bName] = b
|
|
|
|
return s
|
|
}
|