From d5256100617dd518ef56f1fabe3f1ee9cd0cacc7 Mon Sep 17 00:00:00 2001 From: Jonathan Lebon Date: Tue, 16 Jan 2024 11:33:12 -0500 Subject: [PATCH 1/2] docs/release-notes: tweak dracut module change This makes the release note item more similar to the language used in our release notes. --- docs/release-notes.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/release-notes.md b/docs/release-notes.md index d3603b90b..c1e7b997a 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -8,8 +8,8 @@ nav_order: 9 ### Breaking changes -- The dracut module is not automatically included in initramfs images anymore, - see distributor notes for details. +- Only include dracut module in initramfs if requested (see distributor notes + for details) ### Features From 162d1a6a33a7cebaec344e00d317cc5fda7d59b4 Mon Sep 17 00:00:00 2001 From: Jonathan Lebon Date: Tue, 16 Jan 2024 11:33:52 -0500 Subject: [PATCH 2/2] stages/files: filter out non-existent paths before relabeling The code that handles systemd unit enablement via preset will no op if disabling a systemd unit that is already disabled, which means that we wouldn't create a preset file in that case. But we did mark the preset file as needing relabeling unconditionally. Since `setfiles` errors out if you pass it a path that doesn't exist, this would break boot. Fix this by filtering out all entries that don't exist right before we call `setfiles`. Another approach would've been to only mark the file for relabeling if we actually did write the file, but this is more complex than it seems because the relabeling logic needs to know what is the first component in the path that had to be created. So we'd need logic both before and after file creation. This isn't user-reported; we hit this in a CI test. --- docs/release-notes.md | 5 +++++ internal/exec/stages/files/files.go | 14 +++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/docs/release-notes.md b/docs/release-notes.md index c1e7b997a..ac88f6254 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -13,12 +13,17 @@ nav_order: 9 ### Features + + ### Changes - Require Go 1.20+ ### Bug fixes +- Fix failure when config only disables units already disabled + + ## Ignition 2.17.0 (2023-11-20) Starting with this release, ignition-validate binaries are signed with the diff --git a/internal/exec/stages/files/files.go b/internal/exec/stages/files/files.go index d5c04f290..5ab5242a9 100644 --- a/internal/exec/stages/files/files.go +++ b/internal/exec/stages/files/files.go @@ -17,6 +17,7 @@ package files import ( "errors" "fmt" + "os" "path/filepath" "github.com/coreos/ignition/v2/config/v3_5_experimental/types" @@ -170,7 +171,18 @@ func (s *stage) relabelFiles() error { keys := make([]string, 0, len(s.toRelabel)) for key := range s.toRelabel { - keys = append(keys, key) + // Filter out non-existent entries; some of the code that mark files for + // relabeling may not actually end up creating those files in the end. + if _, err := os.Stat(key); err == nil { + keys = append(keys, key) + } else if !errors.Is(err, os.ErrNotExist) { + return err + } } + + if len(keys) == 0 { + return nil + } + return s.RelabelFiles(keys) }