From 53f6f72917211903d2f068b48ed552a6e0e98734 Mon Sep 17 00:00:00 2001 From: Christian Goll Date: Wed, 26 Feb 2025 17:07:31 +0100 Subject: [PATCH] WWWORKER overwrites runtime.NumCPU runtime.NumCPU varies for different build hosts, so the environment variable WWWORKER can be set to keep this number constant as this number ends up in docs/man/man1/wwctl-overlay-build.1 and so in the packages Signed-off-by: Christian Goll --- CHANGELOG.md | 1 + Makefile | 2 +- internal/app/wwctl/overlay/build/root.go | 10 +++++++++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 93b7700a..3ea71b31 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -60,6 +60,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Fix timeout problem for wwclient. #1741 - Fixed default "true" state of NetDev.OnBoot. #1754 - Port NFS mounts during `wwctl upgrade nodes` before applying defaults. #1758 +- Set WWWORKER from commandline for reproducible builds ### Removed diff --git a/Makefile b/Makefile index 245bdc64..88bc7921 100644 --- a/Makefile +++ b/Makefile @@ -73,7 +73,7 @@ wwapird: $(config) $(apiconfig) $(call godeps,internal/app/api/wwapird/wwapird.g .PHONY: man_pages man_pages: wwctl $(wildcard docs/man/man5/*.5) mkdir -p docs/man/man1 - ./wwctl --emptyconf genconfig man docs/man/man1 + WWWORKER=8 ./wwctl --emptyconf genconfig man docs/man/man1 gzip --force docs/man/man1/*.1 for manpage in docs/man/man5/*.5; do gzip <$${manpage} >$${manpage}.gz; done diff --git a/internal/app/wwctl/overlay/build/root.go b/internal/app/wwctl/overlay/build/root.go index ba1fe163..f41e0132 100644 --- a/internal/app/wwctl/overlay/build/root.go +++ b/internal/app/wwctl/overlay/build/root.go @@ -1,7 +1,9 @@ package build import ( + "os" "runtime" + "strconv" "github.com/spf13/cobra" "github.com/warewulf/warewulf/internal/app/wwctl/completions" @@ -29,7 +31,13 @@ func init() { } baseCmd.PersistentFlags().StringVarP(&OverlayDir, "output", "o", "", `Do not create an overlay image for distribution but write to the given directory. An overlay must also be ge given to use this option.`) - baseCmd.PersistentFlags().IntVar(&Workers, "workers", runtime.NumCPU(), "The number of parallel workers building overlays") + workers := runtime.NumCPU() + numCPU := os.Getenv("WWWORKER") + wwWorker, err := strconv.Atoi(numCPU) + if err == nil { + workers = wwWorker + } + baseCmd.PersistentFlags().IntVar(&Workers, "workers", workers, "The number of parallel workers building overlays") } // GetRootCommand returns the root cobra.Command for the application. -- 2.43.0