From 45aa990b511b3857048f9cbc1cb563ebac6aadf6 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 6 May 2024 11:26:19 +0200 Subject: [PATCH] gen-manifests: derrive seedArg from filename and env To ensure that manifests get random(ish) and stable UUIDs we set the rng seed arg based on the filename. This should fix the issue discovered in osbuild/manifest-db#124 that duplicated UUIDs for xfs/btrfs can trigger random(ish) and hard to diagnose errors. This is the same as https://github.com/osbuild/osbuild-composer/pull/4124 hopefully for the right place this time. --- cmd/gen-manifests/main.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cmd/gen-manifests/main.go b/cmd/gen-manifests/main.go index fede29450b..b27ce7e67e 100644 --- a/cmd/gen-manifests/main.go +++ b/cmd/gen-manifests/main.go @@ -10,6 +10,7 @@ import ( "encoding/json" "flag" "fmt" + "hash/fnv" "io" "os" "path/filepath" @@ -190,6 +191,14 @@ func makeManifestJob( filename := fmt.Sprintf("%s-%s-%s-%s.json", u(distroName), u(archName), u(imgType.Name()), u(name)) cacheDir := filepath.Join(cacheRoot, archName+distribution.Name()) + // ensure that each file has a unique seed based on filename + hash := func(s string) int64 { + h := fnv.New64() + h.Write([]byte(filename)) + return int64(h.Sum64()) + } + seedArg += hash(filename) + options := bc.Options var bp blueprint.Blueprint