Skip to content

Commit

Permalink
gen-manifests: derrive seedArg from filename and env
Browse files Browse the repository at this point in the history
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
osbuild/osbuild-composer#4124
hopefully for the right place this time.
  • Loading branch information
mvo5 committed May 14, 2024
1 parent 9316652 commit 45aa990
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions cmd/gen-manifests/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"encoding/json"
"flag"
"fmt"
"hash/fnv"
"io"
"os"
"path/filepath"
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 45aa990

Please sign in to comment.