From f8493f8c7478d2131b781b81627505dae8f7d506 Mon Sep 17 00:00:00 2001 From: Zane Bitter Date: Tue, 31 Mar 2026 10:08:13 +1300 Subject: [PATCH 1/3] Add --preserve-temp-dirs flag for debugging ISO builds Add a new --preserve-temp-dirs command-line flag to optionally preserve temporary work directories after ISO creation. This helps developers debug build issues by inspecting intermediate artifacts like CoreOS ISO contents, split data chunks, and registry images. The flag: - Is a persistent flag available to all build subcommands - Defaults to false (cleanup enabled by default) - Controls cleanup in two locations: - Live ISO work directory (/temp/live-iso-*) - Data staging directory (/temp/data/) - Logs informational messages when directories are preserved When the flag is set, the build process logs which directories are preserved instead of cleaning them up. Assisted-by: Claude Code --- cmd/build.go | 3 +++ pkg/asset/config/env_config.go | 1 + 2 files changed, 4 insertions(+) diff --git a/cmd/build.go b/cmd/build.go index f5531686..2b47c46c 100644 --- a/cmd/build.go +++ b/cmd/build.go @@ -24,6 +24,7 @@ var ( debugBootstrap bool debugBaseIgnition bool isLiveISO bool + preserveTempDirs bool } envConfig config.EnvConfig @@ -42,6 +43,7 @@ func NewBuildCmd() *cobra.Command { cmd.AddCommand(getBuildLiveISOCmd()) cmd.PersistentFlags().BoolVar(&buildOpts.debugBootstrap, "debug-bootstrap", false, "") cmd.PersistentFlags().BoolVar(&buildOpts.debugBaseIgnition, "debug-base-ignition", false, "") + cmd.PersistentFlags().BoolVar(&buildOpts.preserveTempDirs, "preserve-temp-dirs", false, "Preserve temporary directories for debugging") if err := cmd.PersistentFlags().MarkHidden("debug-bootstrap"); err != nil { logrus.Fatal(err) } @@ -233,6 +235,7 @@ func preRunBuild(cmd *cobra.Command, args []string) { DebugBootstrap: buildOpts.debugBootstrap, DebugBaseIgnition: buildOpts.debugBaseIgnition, IsLiveISO: buildOpts.isLiveISO, + PreserveTempDirs: buildOpts.preserveTempDirs, } // Generate EnvConfig asset diff --git a/pkg/asset/config/env_config.go b/pkg/asset/config/env_config.go index 16e69f4e..3fe29ff2 100644 --- a/pkg/asset/config/env_config.go +++ b/pkg/asset/config/env_config.go @@ -26,6 +26,7 @@ type EnvConfig struct { DebugBootstrap bool DebugBaseIgnition bool + PreserveTempDirs bool } var _ asset.Asset = (*EnvConfig)(nil) From 90904d25189c6e28a9e405b4af4b15b21b33600e Mon Sep 17 00:00:00 2001 From: Zane Bitter Date: Mon, 30 Mar 2026 12:29:53 +1300 Subject: [PATCH 2/3] Clean up live ISO work directory after build The work directory (/temp/live-iso-*/) contains the extracted CoreOS ISO files and split data.iso chunks. Once appliance.iso is successfully created from these files, the work directory serves no further purpose. Remove the work directory immediately after appliance.iso creation to reduce disk usage during builds. This eliminates another large temporary copy of data. Assisted-by: Claude Code --- pkg/asset/appliance/appliance_liveiso.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pkg/asset/appliance/appliance_liveiso.go b/pkg/asset/appliance/appliance_liveiso.go index d6e8bd33..c931d1bb 100644 --- a/pkg/asset/appliance/appliance_liveiso.go +++ b/pkg/asset/appliance/appliance_liveiso.go @@ -216,6 +216,15 @@ func (a *ApplianceLiveISO) buildLiveISO( logrus.Errorf("Error creating isohybrid: %s", err) } + // Clean up work directory now that appliance.iso has been created + if envConfig.PreserveTempDirs { + logrus.Infof("Preserving work directory for debugging: %s", workDir) + } else { + if err = os.RemoveAll(workDir); err != nil { + logrus.Warnf("Failed to clean up work directory %s: %v", workDir, err) + } + } + return log.StopSpinner(spinner, nil) } From d1c2c1143c8d840351f012aaa84cfea702d23ac3 Mon Sep 17 00:00:00 2001 From: Zane Bitter Date: Mon, 30 Mar 2026 12:28:07 +1300 Subject: [PATCH 3/3] Clean up data staging directory after ISO creation The staging directory (/temp/data/) is only needed as an intermediate location for genisoimage to create data.iso. Once the ISO is successfully generated in the cache, the staging directory serves no further purpose. Remove the staging directory immediately after data.iso creation to reduce disk usage during builds. This eliminates one unnecessary copy of the registry data. Assisted-by: Claude Code --- pkg/asset/data/data_iso.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkg/asset/data/data_iso.go b/pkg/asset/data/data_iso.go index e6abfff3..b5eb6024 100644 --- a/pkg/asset/data/data_iso.go +++ b/pkg/asset/data/data_iso.go @@ -141,6 +141,14 @@ func (a *DataISO) Generate(dependencies asset.Parents) error { if err = imageGen.GenerateImage(envConfig.CacheDir, dataIsoName, filepath.Join(envConfig.TempDir, dataDir), dataVolumeName); err != nil { return log.StopSpinner(spinner, err) } + // Clean up staging directory now that data.iso has been created + if envConfig.PreserveTempDirs { + logrus.Infof("Preserving staging directory for debugging: %s", dataDirPath) + } else { + if err = os.RemoveAll(dataDirPath); err != nil { + logrus.Warnf("Failed to clean up staging directory %s: %v", dataDirPath, err) + } + } return log.StopSpinner(spinner, a.updateAsset(envConfig)) }